<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://micro.stanford.edu/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kwkang</id>
	<title>Micro and Nano Mechanics Group - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://micro.stanford.edu/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kwkang"/>
	<link rel="alternate" type="text/html" href="http://micro.stanford.edu/wiki/Special:Contributions/Kwkang"/>
	<updated>2026-07-05T07:52:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6049</id>
		<title>M09 Computing Ideal Strength</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6049"/>
		<updated>2014-11-21T11:49:46Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Matlab Program cal_idealstr.m */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 09 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Computing Ideal Strength&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[Dec. 8]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ideal strength of a material is the maximum stress that it can sustain and is an upper bound to the critical stress for crack and dislocation nucleation in the material.  When the applied stress exceeds the ideal strength, the crystal structure will collapse even at zero temperature.  The mode of failure depends on the type of applied stress.  When the tensile stress exceeds the ideal tensile strength, the crystal is unstable against cleavage fracture.  When the shear stress exceeds the ideal shear strength, the crysal is unstable against slip on crystallographic planes.  Because a real crystal is not perfect but contains defects (such as surfaces, grain boundaries, dislocations, vacancies), its strength is lower than the ideal strength.  When the defect density is made sufficiently small (such as in whiskers), the strength of a real crystal can approach the ideal strength.  The ideal strength is also called the &#039;&#039;theoretical&#039;&#039; strength.&lt;br /&gt;
&lt;br /&gt;
There are two alternative definitions of the ideal strength depending on the way that the deformation is imposed on the perfect crystal structure.  In the first definition, the deformation strain can be applied uniformly to the simulation cell (usually under periodic boundary conditions) resulting in an affine deformation of the entire crystal&amp;lt;ref&amp;gt;D. Roudy and M. L. Cohen, Phys. Rev. B &#039;&#039;&#039;64&#039;&#039;&#039; 212103 (2001))&amp;lt;/ref&amp;gt;.  In the second definition, the deformation strain can be localized between two crystallographic planes&amp;lt;ref name=kangcai2007&amp;gt;Keonwook Kang and Wei Cai, Philosophical Magazine, &#039;&#039;&#039;87&#039;&#039;&#039; 2169–2189 (2007)&amp;lt;/ref&amp;gt;.  The ideal strength values obtained from these two approaches are somewhat different but are also expected to co-relate with each other.  In this manual, we describe how to compute the ideal strength according to the second definition, using diamond-cubic structure of Si as an example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Tensile Strength ==&lt;br /&gt;
Suppose we want to compute the ideal tensile strength of Si along the [1 1 0] direction, i.e., &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt;.  First, we create a simulation cell under periodic boundary condition (PBC) with the three periodicity vectors &amp;lt;math&amp;gt;\mathbf{c}_1 =&lt;br /&gt;
N_x [1 1 0]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[\bar{1} 1 0]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[0 0 1]&amp;lt;/math&amp;gt;.  The coordinate system is defined such that &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; are aligned along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;z&amp;lt;/math&amp;gt; directions, respectively. The crystal just created is surrounded by its own images in all three directions. &lt;br /&gt;
&lt;br /&gt;
Next, we change the length of the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; while keeping the position of all atoms in the simulation cell fixed.  Let &amp;lt;math&amp;gt;\mathbf{c}_1^0&amp;lt;/math&amp;gt; be the original value of the repeat vector along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction and &amp;lt;math&amp;gt;L_x^0 = |\mathbf{c}_1^0|&amp;lt;/math&amp;gt;.  Suppose we assign the new repeat vector to be&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_1 = \left( 1 + \frac{d}{L_x^0}\right) \mathbf{c}_1^0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This will create a gap of width &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; between the crystal in the simulation cell (primary cell) with its images in the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, as shown in Fig. 1(a).  For each value of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we compute the potential energy of the crystal (without relaxing the positions of the atoms).  The excess energy with respect to the case of &amp;lt;math&amp;gt;d=0&amp;lt;/math&amp;gt;, dividied by the cross section area of the simulation cell perpendicular to the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, is defined as function of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
and is plotted in Fig. 2(a).&lt;br /&gt;
&lt;br /&gt;
In MD++, the transformation of the simulation cell as described above can be performed conveniently using the command &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is a 3 by 3 matrix whose three columns correspond to the coordinates of the three repeat vectors, i.e. &amp;lt;math&amp;gt;\mathbf{H} = [\mathbf{c}_1 | \mathbf{c}_2 | \mathbf{c}_3]&amp;lt;/math&amp;gt;.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;i&#039;&#039; &#039;&#039;j&#039;&#039; &#039;&#039;frac&#039;&#039; ] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
This will lead to the following transformation of the repeat vectors&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_i := \mathbf{c}_i + frac \cdot \mathbf{c}_j &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since we want to change the length of &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; without changing its direction, both &#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; should be 1 for computing the ideal tensile strength along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction.  (&#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; will be different when computing the ideal shear strength as described in the next section.)  A related command &#039;&#039;&#039;changeH_keepS&#039;&#039;&#039; performs identical transformations to the repeat vectors, but the scaled coordinates, instead of the real coordinates of the atoms are kept fixed.  This will lead to an affine transformation of the simulation cell and is related to the first definition of the ideal strength as described above.&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;, the potential energy is computed by the command &#039;&#039;&#039;eval&#039;&#039;&#039;.  However, before computing the potential energy, we need to refresh the neighbor list.  MD++ uses the Verlet list algorithm, in which the neighbor list is automatically refreshed whenever any atom is displaced by more than half the skin of the Verlet list since the last time the neighbor list is constructed.  However, since here the atom positions do not change when we change the repeat vectors, the neighbor list will not be refreshed automatically.  We can force the neighbor list to refresh by calling &#039;&#039;&#039;clearR0&#039;&#039;&#039; right after the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
The MD++ script for this calculation is attached at the end of this manual.  A few more commands are used there to facilitate the calculation.  The &#039;&#039;&#039;saveH&#039;&#039;&#039; command saves the current value of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix to &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt;.  The &#039;&#039;&#039;restoreH&#039;&#039;&#039; command copies &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; back to &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;.  This commands are used to make the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is always restored to the original value whenever the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command is called.  The &#039;&#039;&#039;RHtoS&#039;&#039;&#039; command is always called before &#039;&#039;&#039;eval&#039;&#039;&#039; which converts the real coordinates &amp;lt;math&amp;gt;\mathbf{r}_i&amp;lt;/math&amp;gt; of the atoms to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s}_i&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{s}_i = \mathbf{H}^{-1} \mathbf{r}_i&amp;lt;/math&amp;gt;. This is needed because the calculation of potential energy in MD++ is based on the scaled coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Cut-surfL.jpg|(a) Creating a gap between the primary and image crystals on a (1 1 0) plane by changing the length of repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Cut-slip.jpg|(b) Sliding the primary and image crystals w.r.t. each other on a (1 1 1) plane by tilting the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; along the &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; direction.&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fig. 2(a) plots the excess energy per unit area of the simulation cell, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;, as a function of separation distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for the Stillinger-Weber (SW) model of Si.  For large enough &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; reaches a plateau, whose value is &amp;lt;math&amp;gt;2\gamma_s&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\gamma_s&amp;lt;/math&amp;gt; is the (unrelaxed) surface energy of (1 1 0) plane of Si.  The plateau is reached when &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; becomes greater than the cut-off distance of the interatomic potential.  The slope of the &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; has the unit of stress.  The maximum slope of this curve can be interpreted as the maximum stress required to separate two rigid blocks of Si along the [1 1 0] direction, i.e. the ideal tensile strength.  For the SW model of Si, &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt; = 41.7 GPa.  The same procedure described here can also be applied to compute ideal tensile strength by first-principles methods such as VASP.  The shell script for this calculation is attached at the end of this manual. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Sisw_surfE.jpg|(a) The excess energy per unit area as a function of the opening distance for the SW model of Si.&lt;br /&gt;
Image:Sisw_slipE.jpg|(b) The excess energy per unit area as a function of the slip distance for the SW model of Si. &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Shear Strength ==&lt;br /&gt;
The procedure of calculating ideal shear strength is similar to that of ideal tensile strength except that we usually need to deal with two degrees of freedom.  One is the amount of slip &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; in the plane of interest, and the other is the amount of openining &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; in the direction normal to the plane.  The reason is that we usually need to allow &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax when computing the ideal shear strength.&lt;br /&gt;
&lt;br /&gt;
In this example, we will compute the ideal shear strength on a (1 1 1) plane of Si along the &amp;lt;math&amp;gt;[1 0 \bar{1}]&amp;lt;/math&amp;gt; direction, &amp;lt;math&amp;gt;\sigma^{\mathrm{th}}_{(111)[10\bar{1}]}&amp;lt;/math&amp;gt;.  We start by creating a perfect crystal with repeat vectors&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = N_x[1 0 \bar{1}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[1 1 1]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[1 \bar{2} 1]&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Next, we perform the following change to the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; while keeping the real coordinates of the atoms fixed,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \mathbf{c}_2 &amp;amp;= \left(1+ \frac{\delta}{L_z^0}\mathbf{c}_2^0 + \frac{d}{L_x^0}\mathbf{c}_1^0 \right) \\&lt;br /&gt;
                &amp;amp;= (L_z^0 + \delta)\mathbf{n} + d\mathbf{m}&lt;br /&gt;
        \end{align} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The excess energy per unit area is now a function of both the slip distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; and the openning distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d, \delta ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For a given &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we can let the opening distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax, which leads to a one dimensional function&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Gamma = \displaystyle\min_{\{\delta\} }\gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The minimization is performed numerically outside MD++, usually within Matlab, based on the 2-dimensional array output from MD++.  Fig. 2(b) plots the function &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; for SW model of Si.   Due to the periodicity of the lattice, &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; is a periodic function, with the periodicity being the length of the Burgers vector.  Again, the slope of the &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; curve also has the unit of stress.  The maximum slope is defined as the ideal shear strength, which is 9.5 GPa for the SW model of Si.&lt;br /&gt;
&lt;br /&gt;
There are two different sets of (1 1 1) planes in a diamond-cubic crystal: the shuffle-set and the glide-set&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  Since the sliding is localized between the atomic planes at the edge of the simulation cell, whether or not the ideal shear strength is computed on the shuffle-set or the glide-set plane depends on which plane is exposed at the edge of the simulation cell.  This can be changed by periodically shifting the atomic structure within the simulation cell (through command &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039;) before calling &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  The syntax for command &#039;&#039;&#039;pbcshfiftatom&#039;&#039;&#039; is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;dx&#039;&#039; &#039;&#039;dy&#039;&#039; &#039;&#039;dz&#039;&#039; ] pbcshiftatom&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;dx&#039;&#039;, &#039;&#039;dy&#039;&#039; and &#039;&#039;dz&#039;&#039; are scaled coordinates of the shift vector.  Since the [1 1 1] direction is along the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; direction, &#039;&#039;dy&#039;&#039; is the relevant parameter that will change the type of (1 1 1) plane exposed at the edge of the simulation cell. Whether or not &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039; is required and, if so, the necessary magnitude of &#039;&#039;dy&#039;&#039; can be determined by visually inspect the atomic structure in the X-window.  The curves in Fig. 3(a) correspond to the shuffle-set plane&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  The ideal shear strength on the glide-set plane (77.3 GPa for SW model of Si) is much higher than that on the shuffle-set plane.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Glideset_e.jpg |(a) A diamond-cubic structure with glide-set (1 1 1) plane exposed at the edge of the simulation cell (normal to &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Shuffleset.jpg |(b) A diamond-cubic structure with shuffle-set (1 1 1) plane exposed at the edge of the simulation cell.  The structures in (a) and (b) are identical unless slip occurs at the edge of the simulation cell by tilting repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gamma Surface ==&lt;br /&gt;
The above procedure allows us to compute the ideal shear strength on a specified plane along a specific slip direction.  However, there are two orthogonal directions within every plane along which slip can occur.  The excess energy per unit area as a function of the two-dimensional slip vector can be visualized as a surface, and is usually called the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface, or the generalized stacking fault energy.&lt;br /&gt;
&lt;br /&gt;
We have implemented a command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; in MD++ that, together with an external Matlab program, computes the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  The command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; itself computes the misfit energy &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; as a function of three parameters: two for the 2-dimensional slip vector within the plane and one for the opening displacement &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; perpendicular to the plane.  The minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; is performed in the Matlab program.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1 ]&lt;br /&gt;
 calmisfit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input variable needs ten elements, the first of which indicates the surface normal index. For example, if &#039;&#039;surfacenormal&#039;&#039; = 2, the slip plane is normal to the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; vector.  The following nine numbers specifies the range and incremental steps of the offset vector in three directions.  In the case study shown in Figs. 1(b) and 2(b), &#039;&#039;x0&#039;&#039;, &#039;&#039;dx&#039;&#039;, &#039;&#039;x1&#039;&#039; specify the range of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_1|/N_x&amp;lt;/math&amp;gt;.  &#039;&#039;y0&#039;&#039;, &#039;&#039;dy&#039;&#039;, &#039;&#039;y1&#039;&#039; specify the range of &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_2|/N_y&amp;lt;/math&amp;gt;.  Since we are not interested in slip along the &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; direction, we have set &#039;&#039;&#039;z0&#039;&#039;&#039; = &#039;&#039;&#039;dz&#039;&#039;&#039; = &#039;&#039;&#039;z1&#039;&#039;&#039; = 0.&lt;br /&gt;
&lt;br /&gt;
Command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; produces a text output file “Emisfit.out”, which is then analyzed by the Matlab program cal_idealstr.m to perform minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; and to compute the ideal shear strength.  The source code for the cal_idealstr.m program is attached at the end of this manual.&lt;br /&gt;
&lt;br /&gt;
== Computing Ideal Shear Strength without Tilting Simulation Cell ==&lt;br /&gt;
For technical reasons, sometimes we cannot tilt the repeat vectors in MD++ when computing the ideal shear strength.  For example, the &#039;&#039;meam-baskes&#039;&#039; program requires linking the C-programs of MD++ with a set of Fortran programs (provided by Dr. Mike Baskes) that implements the MEAM potential.  Unfortunately, the three repeat vectors are not allowed to tilt arbitrarily in these Fortran programs.  In this case, the approach described above will no longer apply.  A new algorithm is needed to compute the ideal shear strength and the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  This is implemented in command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;calmisfit2&#039;&#039;&#039; litterally moves one block of atoms w.r.t. to the remaining block of atoms, as shown in Fig. 4(a).  This creates an interface between the two blocks of atoms.  To avoid creating another (unwanted) interface at the periodic boundary, we need to remove several layers of atoms at the edge of the simulation cell before calling &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Fig. 4(a) shows the initial configuration in which a few layers at top and bottom are removed in order to have room for atoms to be shifted as shown in Fig. 4(b). Other than that, the rest of process to get the ideal shear strength is identical.&lt;br /&gt;
&lt;br /&gt;
In MD++, we can remove a block of atom using commands &#039;&#039;&#039;fixatoms_by_position&#039;&#039;&#039; and &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.  The syntax is&lt;br /&gt;
&lt;br /&gt;
 input = [&#039;&#039;enable x0 x1 y0 y1 z0 z1&#039;&#039; ] fixatoms_by_position removefixedatoms&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;enable&#039;&#039; = 1 is required to activate the command, and the following 6 parameters specifies a parallelepiped volume (in scaled coordinates).  All atoms within this volume will be labeled as fixed by the command &#039;&#039;&#039;fixatoms_by_positions&#039;&#039;&#039;.  The following command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039; then removes these atoms.  To remove two blocks of atoms at the top and bottom of the simulation cell, as shown in Fig. 4(a), the above commands need to be called twice with different input parameters.&lt;br /&gt;
&lt;br /&gt;
The syntax for calling command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; is the following,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax]&lt;br /&gt;
 calmisfit2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first ten parameters have the same meaning as those for &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The last 6 parameters specify the parallelepiped volume (enclosed by the solid lines in Fig. 4(a)) which will be shifted w.r.t. the remaining part of the crystal.  The command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; also produces a text file, “Emisfit.out”, which has the same format as that produced by &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The same Matlab program (cal_idealstr.m) is able to compute the ideal strength using it as the input.&lt;br /&gt;
&lt;br /&gt;
You may try &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039;. Its syntax is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax&lt;br /&gt;
           nogrp grpid]&lt;br /&gt;
 calmisfit2_rigidrlx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, two more input parameters are added. The atoms in xmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sx&amp;lt;xmax, ymin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sy&amp;lt;ymax, and zmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sz&amp;lt;zmax are grouped and their group ID is given as &#039;&#039;&#039;grpid&#039;&#039;&#039;. And the number of groups &#039;&#039;&#039;nogrp&#039;&#039;&#039; = 1 in most cases, here. The command &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039; rigidly relaxes the group of atoms labeled as &#039;&#039;&#039;grpid&#039;&#039;&#039; along the surface normal direction. So, the &amp;quot;Emisfit.out&amp;quot; already contains relaxed surface energy. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Beforeshift_e.jpg |(a) Atomistic structure for computing ideal shear strength when the periodic repeat vectors are not allowed to tilt.  Several layers of atoms at the top and bottom of the simulation cell are removed.  The atoms inside the volume enclosed by the solid lines will be displaced w.r.t. the remaining atoms.&lt;br /&gt;
Image:Aftershift.jpg |(b) Atomistic structure after the atoms inside the volume specified in (a) are displaced.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
The MD++ script (idealstr.tcl) and the Matlab program (cal_idealstr.m) are attached below.  You can use them to reproduce the results described above.  For example, &lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 0&lt;br /&gt;
&lt;br /&gt;
computes the excess energy per unit area as a function of openning displacement perpendicular to the (1 1 0) plane.  On the other hand,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 1&lt;br /&gt;
&lt;br /&gt;
computes the misfit energy of (1 1 1) plane along &amp;lt;math&amp;gt;[1\, 0\, \bar{1}]&amp;lt;/math&amp;gt; direction by tilting the periodic repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.  Finally,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 2&lt;br /&gt;
&lt;br /&gt;
computes the same misfit energy as above without tilting the periodic repeat vector.&lt;br /&gt;
&lt;br /&gt;
After performing the above MD++ calculation, several files will be generated in the output directory, including Esurf.dat (for tensile strength) and Emisfit.dat (for shear strength).  Copying the Matlab program into the same directory and running this Matlab program will produce energy curves and ideal strength values reported as above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MD++ Input Script idealstr.tcl ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } {&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = runs/si_idealstr&lt;br /&gt;
  MD++ NIC = 200 NNM = 200&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = 0.67 bondradius = 0.3 bondlength = 0&lt;br /&gt;
  atomcolor = orange bondcolor = red backgroundcolor = gray70&lt;br /&gt;
  win_width = 300 win_height = 300&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
  plot_atom_info = 1 # reduced coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 2 # real coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 3 # energy of atoms&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# calculate surface opening energy on (1 1 0).&lt;br /&gt;
  initmd&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si latticeconst = 5.43095&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
    latticesize = [ 1 1 0 5&lt;br /&gt;
                   -1 1 0 5&lt;br /&gt;
                    0 0 1 7 ]&lt;br /&gt;
    makecrystal }&lt;br /&gt;
  MD++ saveH eval&lt;br /&gt;
  set Lx0 [MD++_Get H_11]&lt;br /&gt;
  set Ly0 [MD++_Get H_22]&lt;br /&gt;
  set Lz0 [MD++_Get H_33]&lt;br /&gt;
  set EPOT0 [MD++_Get EPOT]&lt;br /&gt;
  set Area [expr $Ly0 * $Lz0]&lt;br /&gt;
  set fileID [open &amp;quot;Esurf.dat&amp;quot; w]&lt;br /&gt;
  for {set i -10} {$i &amp;lt;= 100} {incr i} {&lt;br /&gt;
    set strain [expr $i/1000.0]&lt;br /&gt;
    MD++ restoreH RHtoS&lt;br /&gt;
    MD++ input = \[ 1 1 $strain \] changeH_keepR&lt;br /&gt;
    MD++ clearR0 # enforce refresh neighbor list&lt;br /&gt;
    MD++ eval&lt;br /&gt;
    set Lx [MD++_Get H_11]&lt;br /&gt;
    set dist [expr $Lx - $Lx0]&lt;br /&gt;
    set EPOT [MD++_Get EPOT]&lt;br /&gt;
    # Esurf2 : excessive energy per area to create 2 free surfaces.&lt;br /&gt;
    set Esurf2 [expr ($EPOT - $EPOT0)/$Area]&lt;br /&gt;
    puts $fileID &amp;quot;[format %18.14e $dist]\t \&lt;br /&gt;
                  [format %18.14e $Esurf2]&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  close $fileID&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.43095&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 4; set Nz 3&lt;br /&gt;
&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
# To make shuffle set of (111) plane exposed&lt;br /&gt;
  MD++ { input = [0 0.05 0 ] pbcshiftatom }&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz \]&lt;br /&gt;
  MD++ calmisfit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.431&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 6; set Nz 3&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
  set xmin -1.00; set xmax 1.00&lt;br /&gt;
  set ymin  0.01; set ymax 1.00&lt;br /&gt;
  set zmin -1.00; set zmax 1.00&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[1 -1 1 0.4 1 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[1 -1 1 -1 -0.42 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz $xmin $xmax $ymin $ymax $zmin $zmax \]&lt;br /&gt;
  MD++ calmisfit2&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 3 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1] w/ calmisfit2_rigidrlx&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.431&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 6; set Nz 3&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot; 0.000 0.010 0.000&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
  set xmin -1.00; set xmax 1.00&lt;br /&gt;
  set ymin  0.01; set ymax 1.00&lt;br /&gt;
  set zmin -1.00; set zmax 1.00&lt;br /&gt;
  set grp_id 5&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[1 -1 1 0.4 1 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[1 -1 1 -1 -0.42 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz $xmin $xmax $ymin $ymax $zmin $zmax 1 $grp_id \]&lt;br /&gt;
  MD++ calmisfit2_rigidrlx&lt;br /&gt;
&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab Program cal_idealstr.m ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%#! /usr/local/bin/octave -qf&lt;br /&gt;
% Matlab script, cal_idealstr.m&lt;br /&gt;
% to calculate ideal tensile strength &amp;quot;sigma&amp;quot; and shear strength &amp;quot;tau&amp;quot;&lt;br /&gt;
clear&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal tensile strength along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
data = load(’Esurf.dat’);&lt;br /&gt;
d = data(:,1);     % openning distance in A&lt;br /&gt;
gamma = data(:,2); % excessive energy per area creating 2 free surfaces (eV/A^2)&lt;br /&gt;
&lt;br /&gt;
sigma = max(gamma(2:end)-gamma(1:end-1))/(d(2) - d(1)) * 160.2;&lt;br /&gt;
disp(sprintf(’Ideal tensile stregnth = %e(GPa)’,sigma));&lt;br /&gt;
&lt;br /&gt;
figure(1)&lt;br /&gt;
set(gca,’fontsize’,14)&lt;br /&gt;
plot(d, gamma, ’.-’), grid&lt;br /&gt;
xlabel(’Opening Distance \it d \rm(Angstrom)’,’fontsize’,16),&lt;br /&gt;
ylabel(’\gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
line([-1 1.1],[gamma(end) gamma(end)],’linewidth’,2,’color’,’k’)&lt;br /&gt;
text(-1.3, gamma(end),’2\gamma_s’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal shear strength on (111) along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
if (~exist(’parameter.m’,’file’))&lt;br /&gt;
    error(’No parameter.m found’)&lt;br /&gt;
else&lt;br /&gt;
    parameter&lt;br /&gt;
&lt;br /&gt;
    dx = dxyz(1,2); dy = dxyz(2,2); dz = dxyz(3,2);&lt;br /&gt;
    vx = latticesize(1,1:3); Lx = latticeconst*norm(vx);&lt;br /&gt;
    vy = latticesize(2,1:3); Ly = latticeconst*norm(vy);&lt;br /&gt;
    vz = latticesize(3,1:3); Lz = latticeconst*norm(vz);&lt;br /&gt;
&lt;br /&gt;
    data = load(’Emisfit.out’);&lt;br /&gt;
    Mx=max(data(:,1)); My=max(data(:,2)); Mz=max(data(:,3));&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% convert data to relaxed energy&lt;br /&gt;
    MM=-sort(-[Mx+1,My+1,Mz+1]);         % Then MM(1) &amp;gt; MM(2) &amp;gt; MM(3)&lt;br /&gt;
    E = reshape(data(:,4),MM(1),MM(2));&lt;br /&gt;
&lt;br /&gt;
    Erlx = zeros(MM(1),1);&lt;br /&gt;
    Zrlx = zeros(MM(1),1);&lt;br /&gt;
&lt;br /&gt;
    normalgrid = dxyz(normaldir,1):dxyz(normaldir,2):dxyz(normaldir,3);&lt;br /&gt;
    normalfinegrid = dxyz(normaldir,1):dxyz(normaldir,2)/1000:dxyz(normaldir,3);&lt;br /&gt;
&lt;br /&gt;
    for i = 1:MM(1),&lt;br /&gt;
        a = E(i,:);&lt;br /&gt;
        if length(a)&amp;gt; 1&lt;br /&gt;
            a_interp = interp1(normalgrid,a,normalfinegrid,&#039;spline&#039;);&lt;br /&gt;
        else&lt;br /&gt;
            a_interp = a;&lt;br /&gt;
        end&lt;br /&gt;
        [Erlx(i), ind] = min(a_interp);&lt;br /&gt;
        Zrlx(i) = normalfinegrid(ind);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
% retrieve unrelaxed energy&lt;br /&gt;
    Eunrlx=E(:,find(abs(normalgrid)&amp;lt;1e-8));&lt;br /&gt;
&lt;br /&gt;
% calculate ideal shear strength&lt;br /&gt;
    tau = max(Erlx(2:end)-Erlx(1:end-1))/(dx*Lx) * 160.2;&lt;br /&gt;
    disp(sprintf(’Ideal shear stregnth = %e(GPa)’,tau));&lt;br /&gt;
&lt;br /&gt;
    figure(2); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx, Erlx-Erlx(1), ’b.-’,...&lt;br /&gt;
         [0:Mx]/Mx, Eunrlx-Eunrlx(1),’r-’);&lt;br /&gt;
    legend(’relaxed’,’unrelaxed’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel(’\Gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
    figure(3); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx,Zrlx, ’r.-’, ...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,1),’b-’,...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,3),’b-’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel({’Lowest energy height,’; ’\delta/|c_2| where c_2 = [1 1 1]’},’fontsize’,16)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Tensile strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, the length of the first lattice vector is changed from 0.9 to 1.6 of its equilibrium length in steps of 0.01.  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
declare -i x=9000&lt;br /&gt;
while (($x &amp;lt;= 16000))&lt;br /&gt;
do&lt;br /&gt;
a=$(echo &amp;quot;scale=3; $x/10000&amp;quot; | bc -l)&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  $a  $a  0.0     first  lattice vector&lt;br /&gt;
 -1.0 1.0 0.0     second lattice vector&lt;br /&gt;
  0.0 0.0 1.0     third  lattice vector&lt;br /&gt;
 16               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
cart           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
 -0.7500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   1.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.7500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   1.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=100&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Shear strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, position of a set of atoms is displaced along the y-direction [1 0 -1] but are allowed to relax in the x-direction [1 1 1].  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
function add() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 + $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function subtract() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 - $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function div() {&lt;br /&gt;
  echo &amp;quot;scale=3; $1 / $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
declare -i x=0&lt;br /&gt;
while (($x &amp;lt;= 50))&lt;br /&gt;
do&lt;br /&gt;
a=$(div $x 100)&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  2.0 2.0  2.0    first  lattice vector&lt;br /&gt;
  1.0 0.0 -1.0     second lattice vector&lt;br /&gt;
 -0.5 1.0 -0.5     third  lattice vector&lt;br /&gt;
 32               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
direct           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.3125000000000000   0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000  -0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000   0.0000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.2708333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.3125000000000000  -0.5000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.1458333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.2708333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1458333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.2708333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1041666666666667  -0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667  -0.5000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
 -0.1458333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.5000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
 -0.2708333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1458333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1041666666666667   0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667   0.0000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.0000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.0000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.5000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=5&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6048</id>
		<title>M09 Computing Ideal Strength</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6048"/>
		<updated>2014-11-21T11:46:51Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD++ Input Script idealstr.tcl */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 09 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Computing Ideal Strength&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[Dec. 8]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ideal strength of a material is the maximum stress that it can sustain and is an upper bound to the critical stress for crack and dislocation nucleation in the material.  When the applied stress exceeds the ideal strength, the crystal structure will collapse even at zero temperature.  The mode of failure depends on the type of applied stress.  When the tensile stress exceeds the ideal tensile strength, the crystal is unstable against cleavage fracture.  When the shear stress exceeds the ideal shear strength, the crysal is unstable against slip on crystallographic planes.  Because a real crystal is not perfect but contains defects (such as surfaces, grain boundaries, dislocations, vacancies), its strength is lower than the ideal strength.  When the defect density is made sufficiently small (such as in whiskers), the strength of a real crystal can approach the ideal strength.  The ideal strength is also called the &#039;&#039;theoretical&#039;&#039; strength.&lt;br /&gt;
&lt;br /&gt;
There are two alternative definitions of the ideal strength depending on the way that the deformation is imposed on the perfect crystal structure.  In the first definition, the deformation strain can be applied uniformly to the simulation cell (usually under periodic boundary conditions) resulting in an affine deformation of the entire crystal&amp;lt;ref&amp;gt;D. Roudy and M. L. Cohen, Phys. Rev. B &#039;&#039;&#039;64&#039;&#039;&#039; 212103 (2001))&amp;lt;/ref&amp;gt;.  In the second definition, the deformation strain can be localized between two crystallographic planes&amp;lt;ref name=kangcai2007&amp;gt;Keonwook Kang and Wei Cai, Philosophical Magazine, &#039;&#039;&#039;87&#039;&#039;&#039; 2169–2189 (2007)&amp;lt;/ref&amp;gt;.  The ideal strength values obtained from these two approaches are somewhat different but are also expected to co-relate with each other.  In this manual, we describe how to compute the ideal strength according to the second definition, using diamond-cubic structure of Si as an example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Tensile Strength ==&lt;br /&gt;
Suppose we want to compute the ideal tensile strength of Si along the [1 1 0] direction, i.e., &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt;.  First, we create a simulation cell under periodic boundary condition (PBC) with the three periodicity vectors &amp;lt;math&amp;gt;\mathbf{c}_1 =&lt;br /&gt;
N_x [1 1 0]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[\bar{1} 1 0]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[0 0 1]&amp;lt;/math&amp;gt;.  The coordinate system is defined such that &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; are aligned along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;z&amp;lt;/math&amp;gt; directions, respectively. The crystal just created is surrounded by its own images in all three directions. &lt;br /&gt;
&lt;br /&gt;
Next, we change the length of the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; while keeping the position of all atoms in the simulation cell fixed.  Let &amp;lt;math&amp;gt;\mathbf{c}_1^0&amp;lt;/math&amp;gt; be the original value of the repeat vector along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction and &amp;lt;math&amp;gt;L_x^0 = |\mathbf{c}_1^0|&amp;lt;/math&amp;gt;.  Suppose we assign the new repeat vector to be&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_1 = \left( 1 + \frac{d}{L_x^0}\right) \mathbf{c}_1^0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This will create a gap of width &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; between the crystal in the simulation cell (primary cell) with its images in the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, as shown in Fig. 1(a).  For each value of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we compute the potential energy of the crystal (without relaxing the positions of the atoms).  The excess energy with respect to the case of &amp;lt;math&amp;gt;d=0&amp;lt;/math&amp;gt;, dividied by the cross section area of the simulation cell perpendicular to the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, is defined as function of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
and is plotted in Fig. 2(a).&lt;br /&gt;
&lt;br /&gt;
In MD++, the transformation of the simulation cell as described above can be performed conveniently using the command &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is a 3 by 3 matrix whose three columns correspond to the coordinates of the three repeat vectors, i.e. &amp;lt;math&amp;gt;\mathbf{H} = [\mathbf{c}_1 | \mathbf{c}_2 | \mathbf{c}_3]&amp;lt;/math&amp;gt;.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;i&#039;&#039; &#039;&#039;j&#039;&#039; &#039;&#039;frac&#039;&#039; ] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
This will lead to the following transformation of the repeat vectors&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_i := \mathbf{c}_i + frac \cdot \mathbf{c}_j &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since we want to change the length of &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; without changing its direction, both &#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; should be 1 for computing the ideal tensile strength along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction.  (&#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; will be different when computing the ideal shear strength as described in the next section.)  A related command &#039;&#039;&#039;changeH_keepS&#039;&#039;&#039; performs identical transformations to the repeat vectors, but the scaled coordinates, instead of the real coordinates of the atoms are kept fixed.  This will lead to an affine transformation of the simulation cell and is related to the first definition of the ideal strength as described above.&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;, the potential energy is computed by the command &#039;&#039;&#039;eval&#039;&#039;&#039;.  However, before computing the potential energy, we need to refresh the neighbor list.  MD++ uses the Verlet list algorithm, in which the neighbor list is automatically refreshed whenever any atom is displaced by more than half the skin of the Verlet list since the last time the neighbor list is constructed.  However, since here the atom positions do not change when we change the repeat vectors, the neighbor list will not be refreshed automatically.  We can force the neighbor list to refresh by calling &#039;&#039;&#039;clearR0&#039;&#039;&#039; right after the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
The MD++ script for this calculation is attached at the end of this manual.  A few more commands are used there to facilitate the calculation.  The &#039;&#039;&#039;saveH&#039;&#039;&#039; command saves the current value of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix to &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt;.  The &#039;&#039;&#039;restoreH&#039;&#039;&#039; command copies &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; back to &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;.  This commands are used to make the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is always restored to the original value whenever the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command is called.  The &#039;&#039;&#039;RHtoS&#039;&#039;&#039; command is always called before &#039;&#039;&#039;eval&#039;&#039;&#039; which converts the real coordinates &amp;lt;math&amp;gt;\mathbf{r}_i&amp;lt;/math&amp;gt; of the atoms to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s}_i&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{s}_i = \mathbf{H}^{-1} \mathbf{r}_i&amp;lt;/math&amp;gt;. This is needed because the calculation of potential energy in MD++ is based on the scaled coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Cut-surfL.jpg|(a) Creating a gap between the primary and image crystals on a (1 1 0) plane by changing the length of repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Cut-slip.jpg|(b) Sliding the primary and image crystals w.r.t. each other on a (1 1 1) plane by tilting the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; along the &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; direction.&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fig. 2(a) plots the excess energy per unit area of the simulation cell, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;, as a function of separation distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for the Stillinger-Weber (SW) model of Si.  For large enough &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; reaches a plateau, whose value is &amp;lt;math&amp;gt;2\gamma_s&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\gamma_s&amp;lt;/math&amp;gt; is the (unrelaxed) surface energy of (1 1 0) plane of Si.  The plateau is reached when &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; becomes greater than the cut-off distance of the interatomic potential.  The slope of the &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; has the unit of stress.  The maximum slope of this curve can be interpreted as the maximum stress required to separate two rigid blocks of Si along the [1 1 0] direction, i.e. the ideal tensile strength.  For the SW model of Si, &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt; = 41.7 GPa.  The same procedure described here can also be applied to compute ideal tensile strength by first-principles methods such as VASP.  The shell script for this calculation is attached at the end of this manual. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Sisw_surfE.jpg|(a) The excess energy per unit area as a function of the opening distance for the SW model of Si.&lt;br /&gt;
Image:Sisw_slipE.jpg|(b) The excess energy per unit area as a function of the slip distance for the SW model of Si. &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Shear Strength ==&lt;br /&gt;
The procedure of calculating ideal shear strength is similar to that of ideal tensile strength except that we usually need to deal with two degrees of freedom.  One is the amount of slip &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; in the plane of interest, and the other is the amount of openining &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; in the direction normal to the plane.  The reason is that we usually need to allow &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax when computing the ideal shear strength.&lt;br /&gt;
&lt;br /&gt;
In this example, we will compute the ideal shear strength on a (1 1 1) plane of Si along the &amp;lt;math&amp;gt;[1 0 \bar{1}]&amp;lt;/math&amp;gt; direction, &amp;lt;math&amp;gt;\sigma^{\mathrm{th}}_{(111)[10\bar{1}]}&amp;lt;/math&amp;gt;.  We start by creating a perfect crystal with repeat vectors&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = N_x[1 0 \bar{1}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[1 1 1]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[1 \bar{2} 1]&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Next, we perform the following change to the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; while keeping the real coordinates of the atoms fixed,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \mathbf{c}_2 &amp;amp;= \left(1+ \frac{\delta}{L_z^0}\mathbf{c}_2^0 + \frac{d}{L_x^0}\mathbf{c}_1^0 \right) \\&lt;br /&gt;
                &amp;amp;= (L_z^0 + \delta)\mathbf{n} + d\mathbf{m}&lt;br /&gt;
        \end{align} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The excess energy per unit area is now a function of both the slip distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; and the openning distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d, \delta ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For a given &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we can let the opening distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax, which leads to a one dimensional function&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Gamma = \displaystyle\min_{\{\delta\} }\gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The minimization is performed numerically outside MD++, usually within Matlab, based on the 2-dimensional array output from MD++.  Fig. 2(b) plots the function &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; for SW model of Si.   Due to the periodicity of the lattice, &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; is a periodic function, with the periodicity being the length of the Burgers vector.  Again, the slope of the &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; curve also has the unit of stress.  The maximum slope is defined as the ideal shear strength, which is 9.5 GPa for the SW model of Si.&lt;br /&gt;
&lt;br /&gt;
There are two different sets of (1 1 1) planes in a diamond-cubic crystal: the shuffle-set and the glide-set&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  Since the sliding is localized between the atomic planes at the edge of the simulation cell, whether or not the ideal shear strength is computed on the shuffle-set or the glide-set plane depends on which plane is exposed at the edge of the simulation cell.  This can be changed by periodically shifting the atomic structure within the simulation cell (through command &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039;) before calling &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  The syntax for command &#039;&#039;&#039;pbcshfiftatom&#039;&#039;&#039; is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;dx&#039;&#039; &#039;&#039;dy&#039;&#039; &#039;&#039;dz&#039;&#039; ] pbcshiftatom&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;dx&#039;&#039;, &#039;&#039;dy&#039;&#039; and &#039;&#039;dz&#039;&#039; are scaled coordinates of the shift vector.  Since the [1 1 1] direction is along the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; direction, &#039;&#039;dy&#039;&#039; is the relevant parameter that will change the type of (1 1 1) plane exposed at the edge of the simulation cell. Whether or not &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039; is required and, if so, the necessary magnitude of &#039;&#039;dy&#039;&#039; can be determined by visually inspect the atomic structure in the X-window.  The curves in Fig. 3(a) correspond to the shuffle-set plane&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  The ideal shear strength on the glide-set plane (77.3 GPa for SW model of Si) is much higher than that on the shuffle-set plane.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Glideset_e.jpg |(a) A diamond-cubic structure with glide-set (1 1 1) plane exposed at the edge of the simulation cell (normal to &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Shuffleset.jpg |(b) A diamond-cubic structure with shuffle-set (1 1 1) plane exposed at the edge of the simulation cell.  The structures in (a) and (b) are identical unless slip occurs at the edge of the simulation cell by tilting repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gamma Surface ==&lt;br /&gt;
The above procedure allows us to compute the ideal shear strength on a specified plane along a specific slip direction.  However, there are two orthogonal directions within every plane along which slip can occur.  The excess energy per unit area as a function of the two-dimensional slip vector can be visualized as a surface, and is usually called the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface, or the generalized stacking fault energy.&lt;br /&gt;
&lt;br /&gt;
We have implemented a command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; in MD++ that, together with an external Matlab program, computes the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  The command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; itself computes the misfit energy &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; as a function of three parameters: two for the 2-dimensional slip vector within the plane and one for the opening displacement &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; perpendicular to the plane.  The minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; is performed in the Matlab program.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1 ]&lt;br /&gt;
 calmisfit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input variable needs ten elements, the first of which indicates the surface normal index. For example, if &#039;&#039;surfacenormal&#039;&#039; = 2, the slip plane is normal to the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; vector.  The following nine numbers specifies the range and incremental steps of the offset vector in three directions.  In the case study shown in Figs. 1(b) and 2(b), &#039;&#039;x0&#039;&#039;, &#039;&#039;dx&#039;&#039;, &#039;&#039;x1&#039;&#039; specify the range of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_1|/N_x&amp;lt;/math&amp;gt;.  &#039;&#039;y0&#039;&#039;, &#039;&#039;dy&#039;&#039;, &#039;&#039;y1&#039;&#039; specify the range of &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_2|/N_y&amp;lt;/math&amp;gt;.  Since we are not interested in slip along the &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; direction, we have set &#039;&#039;&#039;z0&#039;&#039;&#039; = &#039;&#039;&#039;dz&#039;&#039;&#039; = &#039;&#039;&#039;z1&#039;&#039;&#039; = 0.&lt;br /&gt;
&lt;br /&gt;
Command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; produces a text output file “Emisfit.out”, which is then analyzed by the Matlab program cal_idealstr.m to perform minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; and to compute the ideal shear strength.  The source code for the cal_idealstr.m program is attached at the end of this manual.&lt;br /&gt;
&lt;br /&gt;
== Computing Ideal Shear Strength without Tilting Simulation Cell ==&lt;br /&gt;
For technical reasons, sometimes we cannot tilt the repeat vectors in MD++ when computing the ideal shear strength.  For example, the &#039;&#039;meam-baskes&#039;&#039; program requires linking the C-programs of MD++ with a set of Fortran programs (provided by Dr. Mike Baskes) that implements the MEAM potential.  Unfortunately, the three repeat vectors are not allowed to tilt arbitrarily in these Fortran programs.  In this case, the approach described above will no longer apply.  A new algorithm is needed to compute the ideal shear strength and the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  This is implemented in command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;calmisfit2&#039;&#039;&#039; litterally moves one block of atoms w.r.t. to the remaining block of atoms, as shown in Fig. 4(a).  This creates an interface between the two blocks of atoms.  To avoid creating another (unwanted) interface at the periodic boundary, we need to remove several layers of atoms at the edge of the simulation cell before calling &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Fig. 4(a) shows the initial configuration in which a few layers at top and bottom are removed in order to have room for atoms to be shifted as shown in Fig. 4(b). Other than that, the rest of process to get the ideal shear strength is identical.&lt;br /&gt;
&lt;br /&gt;
In MD++, we can remove a block of atom using commands &#039;&#039;&#039;fixatoms_by_position&#039;&#039;&#039; and &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.  The syntax is&lt;br /&gt;
&lt;br /&gt;
 input = [&#039;&#039;enable x0 x1 y0 y1 z0 z1&#039;&#039; ] fixatoms_by_position removefixedatoms&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;enable&#039;&#039; = 1 is required to activate the command, and the following 6 parameters specifies a parallelepiped volume (in scaled coordinates).  All atoms within this volume will be labeled as fixed by the command &#039;&#039;&#039;fixatoms_by_positions&#039;&#039;&#039;.  The following command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039; then removes these atoms.  To remove two blocks of atoms at the top and bottom of the simulation cell, as shown in Fig. 4(a), the above commands need to be called twice with different input parameters.&lt;br /&gt;
&lt;br /&gt;
The syntax for calling command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; is the following,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax]&lt;br /&gt;
 calmisfit2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first ten parameters have the same meaning as those for &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The last 6 parameters specify the parallelepiped volume (enclosed by the solid lines in Fig. 4(a)) which will be shifted w.r.t. the remaining part of the crystal.  The command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; also produces a text file, “Emisfit.out”, which has the same format as that produced by &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The same Matlab program (cal_idealstr.m) is able to compute the ideal strength using it as the input.&lt;br /&gt;
&lt;br /&gt;
You may try &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039;. Its syntax is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax&lt;br /&gt;
           nogrp grpid]&lt;br /&gt;
 calmisfit2_rigidrlx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, two more input parameters are added. The atoms in xmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sx&amp;lt;xmax, ymin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sy&amp;lt;ymax, and zmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sz&amp;lt;zmax are grouped and their group ID is given as &#039;&#039;&#039;grpid&#039;&#039;&#039;. And the number of groups &#039;&#039;&#039;nogrp&#039;&#039;&#039; = 1 in most cases, here. The command &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039; rigidly relaxes the group of atoms labeled as &#039;&#039;&#039;grpid&#039;&#039;&#039; along the surface normal direction. So, the &amp;quot;Emisfit.out&amp;quot; already contains relaxed surface energy. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Beforeshift_e.jpg |(a) Atomistic structure for computing ideal shear strength when the periodic repeat vectors are not allowed to tilt.  Several layers of atoms at the top and bottom of the simulation cell are removed.  The atoms inside the volume enclosed by the solid lines will be displaced w.r.t. the remaining atoms.&lt;br /&gt;
Image:Aftershift.jpg |(b) Atomistic structure after the atoms inside the volume specified in (a) are displaced.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
The MD++ script (idealstr.tcl) and the Matlab program (cal_idealstr.m) are attached below.  You can use them to reproduce the results described above.  For example, &lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 0&lt;br /&gt;
&lt;br /&gt;
computes the excess energy per unit area as a function of openning displacement perpendicular to the (1 1 0) plane.  On the other hand,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 1&lt;br /&gt;
&lt;br /&gt;
computes the misfit energy of (1 1 1) plane along &amp;lt;math&amp;gt;[1\, 0\, \bar{1}]&amp;lt;/math&amp;gt; direction by tilting the periodic repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.  Finally,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 2&lt;br /&gt;
&lt;br /&gt;
computes the same misfit energy as above without tilting the periodic repeat vector.&lt;br /&gt;
&lt;br /&gt;
After performing the above MD++ calculation, several files will be generated in the output directory, including Esurf.dat (for tensile strength) and Emisfit.dat (for shear strength).  Copying the Matlab program into the same directory and running this Matlab program will produce energy curves and ideal strength values reported as above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MD++ Input Script idealstr.tcl ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } {&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = runs/si_idealstr&lt;br /&gt;
  MD++ NIC = 200 NNM = 200&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = 0.67 bondradius = 0.3 bondlength = 0&lt;br /&gt;
  atomcolor = orange bondcolor = red backgroundcolor = gray70&lt;br /&gt;
  win_width = 300 win_height = 300&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
  plot_atom_info = 1 # reduced coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 2 # real coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 3 # energy of atoms&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# calculate surface opening energy on (1 1 0).&lt;br /&gt;
  initmd&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si latticeconst = 5.43095&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
    latticesize = [ 1 1 0 5&lt;br /&gt;
                   -1 1 0 5&lt;br /&gt;
                    0 0 1 7 ]&lt;br /&gt;
    makecrystal }&lt;br /&gt;
  MD++ saveH eval&lt;br /&gt;
  set Lx0 [MD++_Get H_11]&lt;br /&gt;
  set Ly0 [MD++_Get H_22]&lt;br /&gt;
  set Lz0 [MD++_Get H_33]&lt;br /&gt;
  set EPOT0 [MD++_Get EPOT]&lt;br /&gt;
  set Area [expr $Ly0 * $Lz0]&lt;br /&gt;
  set fileID [open &amp;quot;Esurf.dat&amp;quot; w]&lt;br /&gt;
  for {set i -10} {$i &amp;lt;= 100} {incr i} {&lt;br /&gt;
    set strain [expr $i/1000.0]&lt;br /&gt;
    MD++ restoreH RHtoS&lt;br /&gt;
    MD++ input = \[ 1 1 $strain \] changeH_keepR&lt;br /&gt;
    MD++ clearR0 # enforce refresh neighbor list&lt;br /&gt;
    MD++ eval&lt;br /&gt;
    set Lx [MD++_Get H_11]&lt;br /&gt;
    set dist [expr $Lx - $Lx0]&lt;br /&gt;
    set EPOT [MD++_Get EPOT]&lt;br /&gt;
    # Esurf2 : excessive energy per area to create 2 free surfaces.&lt;br /&gt;
    set Esurf2 [expr ($EPOT - $EPOT0)/$Area]&lt;br /&gt;
    puts $fileID &amp;quot;[format %18.14e $dist]\t \&lt;br /&gt;
                  [format %18.14e $Esurf2]&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  close $fileID&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.43095&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 4; set Nz 3&lt;br /&gt;
&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
# To make shuffle set of (111) plane exposed&lt;br /&gt;
  MD++ { input = [0 0.05 0 ] pbcshiftatom }&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz \]&lt;br /&gt;
  MD++ calmisfit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.431&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 6; set Nz 3&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
  set xmin -1.00; set xmax 1.00&lt;br /&gt;
  set ymin  0.01; set ymax 1.00&lt;br /&gt;
  set zmin -1.00; set zmax 1.00&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[1 -1 1 0.4 1 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[1 -1 1 -1 -0.42 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz $xmin $xmax $ymin $ymax $zmin $zmax \]&lt;br /&gt;
  MD++ calmisfit2&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 3 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1] w/ calmisfit2_rigidrlx&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.431&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 6; set Nz 3&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot; 0.000 0.010 0.000&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
  set xmin -1.00; set xmax 1.00&lt;br /&gt;
  set ymin  0.01; set ymax 1.00&lt;br /&gt;
  set zmin -1.00; set zmax 1.00&lt;br /&gt;
  set grp_id 5&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[1 -1 1 0.4 1 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[1 -1 1 -1 -0.42 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz $xmin $xmax $ymin $ymax $zmin $zmax 1 $grp_id \]&lt;br /&gt;
  MD++ calmisfit2_rigidrlx&lt;br /&gt;
&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab Program cal_idealstr.m ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%#! /usr/local/bin/octave -qf&lt;br /&gt;
% Matlab script, cal_idealstr.m&lt;br /&gt;
% to calculate ideal tensile strength &amp;quot;sigma&amp;quot; and shear strength &amp;quot;tau&amp;quot;&lt;br /&gt;
clear&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal tensile strength along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
data = load(’Esurf.dat’);&lt;br /&gt;
d = data(:,1);     % openning distance in A&lt;br /&gt;
gamma = data(:,2); % excessive energy per area creating 2 free surfaces (eV/A^2)&lt;br /&gt;
&lt;br /&gt;
sigma = max(gamma(2:end)-gamma(1:end-1))/(d(2) - d(1)) * 160.2;&lt;br /&gt;
disp(sprintf(’Ideal tensile stregnth = %e(GPa)’,sigma));&lt;br /&gt;
&lt;br /&gt;
figure(1)&lt;br /&gt;
set(gca,’fontsize’,14)&lt;br /&gt;
plot(d, gamma, ’.-’), grid&lt;br /&gt;
xlabel(’Opening Distance \it d \rm(Angstrom)’,’fontsize’,16),&lt;br /&gt;
ylabel(’\gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
line([-1 1.1],[gamma(end) gamma(end)],’linewidth’,2,’color’,’k’)&lt;br /&gt;
text(-1.3, gamma(end),’2\gamma_s’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal shear strength on (111) along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
if (~exist(’parameter.m’,’file’))&lt;br /&gt;
    error(’No parameter.m found’)&lt;br /&gt;
else&lt;br /&gt;
    parameter&lt;br /&gt;
&lt;br /&gt;
    dx = dxyz(1,2); dy = dxyz(2,2); dz = dxyz(3,2);&lt;br /&gt;
    vx = latticesize(1,1:3); Lx = latticeconst*norm(vx);&lt;br /&gt;
    vy = latticesize(2,1:3); Ly = latticeconst*norm(vy);&lt;br /&gt;
    vz = latticesize(3,1:3); Lz = latticeconst*norm(vz);&lt;br /&gt;
&lt;br /&gt;
    data = load(’Emisfit.out’);&lt;br /&gt;
    Mx=max(data(:,1)); My=max(data(:,2)); Mz=max(data(:,3));&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% convert data to relaxed energy&lt;br /&gt;
    MM=-sort(-[Mx+1,My+1,Mz+1]);         % Then MM(1) &amp;gt; MM(2) &amp;gt; MM(3)&lt;br /&gt;
    E = reshape(data(:,4),MM(1),MM(2));&lt;br /&gt;
&lt;br /&gt;
    Erlx = zeros(MM(1),1);&lt;br /&gt;
    Zrlx = zeros(MM(1),1);&lt;br /&gt;
&lt;br /&gt;
    normalgrid = dxyz(normaldir,1):dxyz(normaldir,2):dxyz(normaldir,3);&lt;br /&gt;
    normalfinegrid = dxyz(normaldir,1):dxyz(normaldir,2)/1000:dxyz(normaldir,3);&lt;br /&gt;
&lt;br /&gt;
    for i = 1:MM(1),&lt;br /&gt;
        a = E(i,:);&lt;br /&gt;
        a_interp = interp1(normalgrid,a,normalfinegrid,’spline’);&lt;br /&gt;
        [Erlx(i), ind] = min(a_interp);&lt;br /&gt;
        Zrlx(i) = normalfinegrid(ind);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
% retrieve unrelaxed energy&lt;br /&gt;
    Eunrlx=E(:,find(abs(normalgrid)&amp;lt;1e-8));&lt;br /&gt;
&lt;br /&gt;
% calculate ideal shear strength&lt;br /&gt;
    tau = max(Erlx(2:end)-Erlx(1:end-1))/(dx*Lx) * 160.2;&lt;br /&gt;
    disp(sprintf(’Ideal shear stregnth = %e(GPa)’,tau));&lt;br /&gt;
&lt;br /&gt;
    figure(2); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx, Erlx-Erlx(1), ’b.-’,...&lt;br /&gt;
         [0:Mx]/Mx, Eunrlx-Eunrlx(1),’r-’);&lt;br /&gt;
    legend(’relaxed’,’unrelaxed’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel(’\Gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
    figure(3); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx,Zrlx, ’r.-’, ...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,1),’b-’,...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,3),’b-’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel({’Lowest energy height,’; ’\delta/|c_2| where c_2 = [1 1 1]’},’fontsize’,16)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Tensile strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, the length of the first lattice vector is changed from 0.9 to 1.6 of its equilibrium length in steps of 0.01.  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
declare -i x=9000&lt;br /&gt;
while (($x &amp;lt;= 16000))&lt;br /&gt;
do&lt;br /&gt;
a=$(echo &amp;quot;scale=3; $x/10000&amp;quot; | bc -l)&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  $a  $a  0.0     first  lattice vector&lt;br /&gt;
 -1.0 1.0 0.0     second lattice vector&lt;br /&gt;
  0.0 0.0 1.0     third  lattice vector&lt;br /&gt;
 16               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
cart           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
 -0.7500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   1.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.7500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   1.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=100&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Shear strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, position of a set of atoms is displaced along the y-direction [1 0 -1] but are allowed to relax in the x-direction [1 1 1].  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
function add() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 + $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function subtract() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 - $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function div() {&lt;br /&gt;
  echo &amp;quot;scale=3; $1 / $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
declare -i x=0&lt;br /&gt;
while (($x &amp;lt;= 50))&lt;br /&gt;
do&lt;br /&gt;
a=$(div $x 100)&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  2.0 2.0  2.0    first  lattice vector&lt;br /&gt;
  1.0 0.0 -1.0     second lattice vector&lt;br /&gt;
 -0.5 1.0 -0.5     third  lattice vector&lt;br /&gt;
 32               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
direct           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.3125000000000000   0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000  -0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000   0.0000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.2708333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.3125000000000000  -0.5000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.1458333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.2708333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1458333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.2708333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1041666666666667  -0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667  -0.5000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
 -0.1458333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.5000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
 -0.2708333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1458333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1041666666666667   0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667   0.0000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.0000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.0000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.5000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=5&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6047</id>
		<title>M09 Computing Ideal Strength</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M09_Computing_Ideal_Strength&amp;diff=6047"/>
		<updated>2014-11-21T11:42:35Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Computing Ideal Shear Strength without Tilting Simulation Cell */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 09 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Computing Ideal Strength&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[Dec. 8]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ideal strength of a material is the maximum stress that it can sustain and is an upper bound to the critical stress for crack and dislocation nucleation in the material.  When the applied stress exceeds the ideal strength, the crystal structure will collapse even at zero temperature.  The mode of failure depends on the type of applied stress.  When the tensile stress exceeds the ideal tensile strength, the crystal is unstable against cleavage fracture.  When the shear stress exceeds the ideal shear strength, the crysal is unstable against slip on crystallographic planes.  Because a real crystal is not perfect but contains defects (such as surfaces, grain boundaries, dislocations, vacancies), its strength is lower than the ideal strength.  When the defect density is made sufficiently small (such as in whiskers), the strength of a real crystal can approach the ideal strength.  The ideal strength is also called the &#039;&#039;theoretical&#039;&#039; strength.&lt;br /&gt;
&lt;br /&gt;
There are two alternative definitions of the ideal strength depending on the way that the deformation is imposed on the perfect crystal structure.  In the first definition, the deformation strain can be applied uniformly to the simulation cell (usually under periodic boundary conditions) resulting in an affine deformation of the entire crystal&amp;lt;ref&amp;gt;D. Roudy and M. L. Cohen, Phys. Rev. B &#039;&#039;&#039;64&#039;&#039;&#039; 212103 (2001))&amp;lt;/ref&amp;gt;.  In the second definition, the deformation strain can be localized between two crystallographic planes&amp;lt;ref name=kangcai2007&amp;gt;Keonwook Kang and Wei Cai, Philosophical Magazine, &#039;&#039;&#039;87&#039;&#039;&#039; 2169–2189 (2007)&amp;lt;/ref&amp;gt;.  The ideal strength values obtained from these two approaches are somewhat different but are also expected to co-relate with each other.  In this manual, we describe how to compute the ideal strength according to the second definition, using diamond-cubic structure of Si as an example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Tensile Strength ==&lt;br /&gt;
Suppose we want to compute the ideal tensile strength of Si along the [1 1 0] direction, i.e., &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt;.  First, we create a simulation cell under periodic boundary condition (PBC) with the three periodicity vectors &amp;lt;math&amp;gt;\mathbf{c}_1 =&lt;br /&gt;
N_x [1 1 0]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[\bar{1} 1 0]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[0 0 1]&amp;lt;/math&amp;gt;.  The coordinate system is defined such that &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; are aligned along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;z&amp;lt;/math&amp;gt; directions, respectively. The crystal just created is surrounded by its own images in all three directions. &lt;br /&gt;
&lt;br /&gt;
Next, we change the length of the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; while keeping the position of all atoms in the simulation cell fixed.  Let &amp;lt;math&amp;gt;\mathbf{c}_1^0&amp;lt;/math&amp;gt; be the original value of the repeat vector along the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction and &amp;lt;math&amp;gt;L_x^0 = |\mathbf{c}_1^0|&amp;lt;/math&amp;gt;.  Suppose we assign the new repeat vector to be&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_1 = \left( 1 + \frac{d}{L_x^0}\right) \mathbf{c}_1^0 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This will create a gap of width &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; between the crystal in the simulation cell (primary cell) with its images in the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, as shown in Fig. 1(a).  For each value of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we compute the potential energy of the crystal (without relaxing the positions of the atoms).  The excess energy with respect to the case of &amp;lt;math&amp;gt;d=0&amp;lt;/math&amp;gt;, dividied by the cross section area of the simulation cell perpendicular to the &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction, is defined as function of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
and is plotted in Fig. 2(a).&lt;br /&gt;
&lt;br /&gt;
In MD++, the transformation of the simulation cell as described above can be performed conveniently using the command &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is a 3 by 3 matrix whose three columns correspond to the coordinates of the three repeat vectors, i.e. &amp;lt;math&amp;gt;\mathbf{H} = [\mathbf{c}_1 | \mathbf{c}_2 | \mathbf{c}_3]&amp;lt;/math&amp;gt;.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;i&#039;&#039; &#039;&#039;j&#039;&#039; &#039;&#039;frac&#039;&#039; ] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
This will lead to the following transformation of the repeat vectors&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;\mathbf{c}_i := \mathbf{c}_i + frac \cdot \mathbf{c}_j &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since we want to change the length of &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; without changing its direction, both &#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; should be 1 for computing the ideal tensile strength along &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; direction.  (&#039;&#039;i&#039;&#039; and &#039;&#039;j&#039;&#039; will be different when computing the ideal shear strength as described in the next section.)  A related command &#039;&#039;&#039;changeH_keepS&#039;&#039;&#039; performs identical transformations to the repeat vectors, but the scaled coordinates, instead of the real coordinates of the atoms are kept fixed.  This will lead to an affine transformation of the simulation cell and is related to the first definition of the ideal strength as described above.&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;, the potential energy is computed by the command &#039;&#039;&#039;eval&#039;&#039;&#039;.  However, before computing the potential energy, we need to refresh the neighbor list.  MD++ uses the Verlet list algorithm, in which the neighbor list is automatically refreshed whenever any atom is displaced by more than half the skin of the Verlet list since the last time the neighbor list is constructed.  However, since here the atom positions do not change when we change the repeat vectors, the neighbor list will not be refreshed automatically.  We can force the neighbor list to refresh by calling &#039;&#039;&#039;clearR0&#039;&#039;&#039; right after the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command.&lt;br /&gt;
&lt;br /&gt;
The MD++ script for this calculation is attached at the end of this manual.  A few more commands are used there to facilitate the calculation.  The &#039;&#039;&#039;saveH&#039;&#039;&#039; command saves the current value of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix to &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt;.  The &#039;&#039;&#039;restoreH&#039;&#039;&#039; command copies &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; back to &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;.  This commands are used to make the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is always restored to the original value whenever the &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039; command is called.  The &#039;&#039;&#039;RHtoS&#039;&#039;&#039; command is always called before &#039;&#039;&#039;eval&#039;&#039;&#039; which converts the real coordinates &amp;lt;math&amp;gt;\mathbf{r}_i&amp;lt;/math&amp;gt; of the atoms to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s}_i&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{s}_i = \mathbf{H}^{-1} \mathbf{r}_i&amp;lt;/math&amp;gt;. This is needed because the calculation of potential energy in MD++ is based on the scaled coordinates.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Cut-surfL.jpg|(a) Creating a gap between the primary and image crystals on a (1 1 0) plane by changing the length of repeat vector &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Cut-slip.jpg|(b) Sliding the primary and image crystals w.r.t. each other on a (1 1 1) plane by tilting the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; along the &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt; direction.&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Fig. 2(a) plots the excess energy per unit area of the simulation cell, &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;, as a function of separation distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; for the Stillinger-Weber (SW) model of Si.  For large enough &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; reaches a plateau, whose value is &amp;lt;math&amp;gt;2\gamma_s&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\gamma_s&amp;lt;/math&amp;gt; is the (unrelaxed) surface energy of (1 1 0) plane of Si.  The plateau is reached when &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; becomes greater than the cut-off distance of the interatomic potential.  The slope of the &amp;lt;math&amp;gt;\gamma(d)&amp;lt;/math&amp;gt; has the unit of stress.  The maximum slope of this curve can be interpreted as the maximum stress required to separate two rigid blocks of Si along the [1 1 0] direction, i.e. the ideal tensile strength.  For the SW model of Si, &amp;lt;math&amp;gt;\sigma_{[110]}^{\mathrm{th}}&amp;lt;/math&amp;gt; = 41.7 GPa.  The same procedure described here can also be applied to compute ideal tensile strength by first-principles methods such as VASP.  The shell script for this calculation is attached at the end of this manual. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Sisw_surfE.jpg|(a) The excess energy per unit area as a function of the opening distance for the SW model of Si.&lt;br /&gt;
Image:Sisw_slipE.jpg|(b) The excess energy per unit area as a function of the slip distance for the SW model of Si. &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ideal Shear Strength ==&lt;br /&gt;
The procedure of calculating ideal shear strength is similar to that of ideal tensile strength except that we usually need to deal with two degrees of freedom.  One is the amount of slip &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; in the plane of interest, and the other is the amount of openining &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; in the direction normal to the plane.  The reason is that we usually need to allow &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax when computing the ideal shear strength.&lt;br /&gt;
&lt;br /&gt;
In this example, we will compute the ideal shear strength on a (1 1 1) plane of Si along the &amp;lt;math&amp;gt;[1 0 \bar{1}]&amp;lt;/math&amp;gt; direction, &amp;lt;math&amp;gt;\sigma^{\mathrm{th}}_{(111)[10\bar{1}]}&amp;lt;/math&amp;gt;.  We start by creating a perfect crystal with repeat vectors&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = N_x[1 0 \bar{1}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2 = N_y[1 1 1]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3 = N_z[1 \bar{2} 1]&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Next, we perform the following change to the repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; while keeping the real coordinates of the atoms fixed,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \mathbf{c}_2 &amp;amp;= \left(1+ \frac{\delta}{L_z^0}\mathbf{c}_2^0 + \frac{d}{L_x^0}\mathbf{c}_1^0 \right) \\&lt;br /&gt;
                &amp;amp;= (L_z^0 + \delta)\mathbf{n} + d\mathbf{m}&lt;br /&gt;
        \end{align} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The excess energy per unit area is now a function of both the slip distance &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt; and the openning distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \gamma = \gamma ( d, \delta ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For a given &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, we can let the opening distance &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; to relax, which leads to a one dimensional function&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Gamma = \displaystyle\min_{\{\delta\} }\gamma ( d ) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The minimization is performed numerically outside MD++, usually within Matlab, based on the 2-dimensional array output from MD++.  Fig. 2(b) plots the function &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; for SW model of Si.   Due to the periodicity of the lattice, &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; is a periodic function, with the periodicity being the length of the Burgers vector.  Again, the slope of the &amp;lt;math&amp;gt;\Gamma(d)&amp;lt;/math&amp;gt; curve also has the unit of stress.  The maximum slope is defined as the ideal shear strength, which is 9.5 GPa for the SW model of Si.&lt;br /&gt;
&lt;br /&gt;
There are two different sets of (1 1 1) planes in a diamond-cubic crystal: the shuffle-set and the glide-set&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  Since the sliding is localized between the atomic planes at the edge of the simulation cell, whether or not the ideal shear strength is computed on the shuffle-set or the glide-set plane depends on which plane is exposed at the edge of the simulation cell.  This can be changed by periodically shifting the atomic structure within the simulation cell (through command &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039;) before calling &#039;&#039;&#039;changeH_keepR&#039;&#039;&#039;.  The syntax for command &#039;&#039;&#039;pbcshfiftatom&#039;&#039;&#039; is&lt;br /&gt;
&lt;br /&gt;
 input = [ &#039;&#039;dx&#039;&#039; &#039;&#039;dy&#039;&#039; &#039;&#039;dz&#039;&#039; ] pbcshiftatom&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;dx&#039;&#039;, &#039;&#039;dy&#039;&#039; and &#039;&#039;dz&#039;&#039; are scaled coordinates of the shift vector.  Since the [1 1 1] direction is along the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; direction, &#039;&#039;dy&#039;&#039; is the relevant parameter that will change the type of (1 1 1) plane exposed at the edge of the simulation cell. Whether or not &#039;&#039;&#039;pbcshiftatom&#039;&#039;&#039; is required and, if so, the necessary magnitude of &#039;&#039;dy&#039;&#039; can be determined by visually inspect the atomic structure in the X-window.  The curves in Fig. 3(a) correspond to the shuffle-set plane&amp;lt;ref name=&amp;quot;kangcai2007&amp;quot;/&amp;gt;.  The ideal shear strength on the glide-set plane (77.3 GPa for SW model of Si) is much higher than that on the shuffle-set plane.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Glideset_e.jpg |(a) A diamond-cubic structure with glide-set (1 1 1) plane exposed at the edge of the simulation cell (normal to &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
Image:Shuffleset.jpg |(b) A diamond-cubic structure with shuffle-set (1 1 1) plane exposed at the edge of the simulation cell.  The structures in (a) and (b) are identical unless slip occurs at the edge of the simulation cell by tilting repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Gamma Surface ==&lt;br /&gt;
The above procedure allows us to compute the ideal shear strength on a specified plane along a specific slip direction.  However, there are two orthogonal directions within every plane along which slip can occur.  The excess energy per unit area as a function of the two-dimensional slip vector can be visualized as a surface, and is usually called the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface, or the generalized stacking fault energy.&lt;br /&gt;
&lt;br /&gt;
We have implemented a command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; in MD++ that, together with an external Matlab program, computes the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  The command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; itself computes the misfit energy &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt; as a function of three parameters: two for the 2-dimensional slip vector within the plane and one for the opening displacement &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; perpendicular to the plane.  The minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; is performed in the Matlab program.  The syntax for this command is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1 ]&lt;br /&gt;
 calmisfit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The input variable needs ten elements, the first of which indicates the surface normal index. For example, if &#039;&#039;surfacenormal&#039;&#039; = 2, the slip plane is normal to the &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; vector.  The following nine numbers specifies the range and incremental steps of the offset vector in three directions.  In the case study shown in Figs. 1(b) and 2(b), &#039;&#039;x0&#039;&#039;, &#039;&#039;dx&#039;&#039;, &#039;&#039;x1&#039;&#039; specify the range of &amp;lt;math&amp;gt;d&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_1|/N_x&amp;lt;/math&amp;gt;.  &#039;&#039;y0&#039;&#039;, &#039;&#039;dy&#039;&#039;, &#039;&#039;y1&#039;&#039; specify the range of &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt;, in units of &amp;lt;math&amp;gt;|\mathbf{c}_2|/N_y&amp;lt;/math&amp;gt;.  Since we are not interested in slip along the &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt; direction, we have set &#039;&#039;&#039;z0&#039;&#039;&#039; = &#039;&#039;&#039;dz&#039;&#039;&#039; = &#039;&#039;&#039;z1&#039;&#039;&#039; = 0.&lt;br /&gt;
&lt;br /&gt;
Command &#039;&#039;&#039;calmisfit&#039;&#039;&#039; produces a text output file “Emisfit.out”, which is then analyzed by the Matlab program cal_idealstr.m to perform minimization w.r.t. &amp;lt;math&amp;gt;\delta&amp;lt;/math&amp;gt; and to compute the ideal shear strength.  The source code for the cal_idealstr.m program is attached at the end of this manual.&lt;br /&gt;
&lt;br /&gt;
== Computing Ideal Shear Strength without Tilting Simulation Cell ==&lt;br /&gt;
For technical reasons, sometimes we cannot tilt the repeat vectors in MD++ when computing the ideal shear strength.  For example, the &#039;&#039;meam-baskes&#039;&#039; program requires linking the C-programs of MD++ with a set of Fortran programs (provided by Dr. Mike Baskes) that implements the MEAM potential.  Unfortunately, the three repeat vectors are not allowed to tilt arbitrarily in these Fortran programs.  In this case, the approach described above will no longer apply.  A new algorithm is needed to compute the ideal shear strength and the &amp;lt;math&amp;gt;\gamma&amp;lt;/math&amp;gt;-surface.  This is implemented in command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;calmisfit2&#039;&#039;&#039; litterally moves one block of atoms w.r.t. to the remaining block of atoms, as shown in Fig. 4(a).  This creates an interface between the two blocks of atoms.  To avoid creating another (unwanted) interface at the periodic boundary, we need to remove several layers of atoms at the edge of the simulation cell before calling &#039;&#039;&#039;calmisfit2&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Fig. 4(a) shows the initial configuration in which a few layers at top and bottom are removed in order to have room for atoms to be shifted as shown in Fig. 4(b). Other than that, the rest of process to get the ideal shear strength is identical.&lt;br /&gt;
&lt;br /&gt;
In MD++, we can remove a block of atom using commands &#039;&#039;&#039;fixatoms_by_position&#039;&#039;&#039; and &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.  The syntax is&lt;br /&gt;
&lt;br /&gt;
 input = [&#039;&#039;enable x0 x1 y0 y1 z0 z1&#039;&#039; ] fixatoms_by_position removefixedatoms&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;enable&#039;&#039; = 1 is required to activate the command, and the following 6 parameters specifies a parallelepiped volume (in scaled coordinates).  All atoms within this volume will be labeled as fixed by the command &#039;&#039;&#039;fixatoms_by_positions&#039;&#039;&#039;.  The following command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039; then removes these atoms.  To remove two blocks of atoms at the top and bottom of the simulation cell, as shown in Fig. 4(a), the above commands need to be called twice with different input parameters.&lt;br /&gt;
&lt;br /&gt;
The syntax for calling command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; is the following,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax]&lt;br /&gt;
 calmisfit2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first ten parameters have the same meaning as those for &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The last 6 parameters specify the parallelepiped volume (enclosed by the solid lines in Fig. 4(a)) which will be shifted w.r.t. the remaining part of the crystal.  The command &#039;&#039;&#039;calmisfit2&#039;&#039;&#039; also produces a text file, “Emisfit.out”, which has the same format as that produced by &#039;&#039;&#039;calmisfit&#039;&#039;&#039;.  The same Matlab program (cal_idealstr.m) is able to compute the ideal strength using it as the input.&lt;br /&gt;
&lt;br /&gt;
You may try &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039;. Its syntax is given below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 input = [ surfacenormal&lt;br /&gt;
           x0 dx x1&lt;br /&gt;
           y0 dy y1&lt;br /&gt;
           z0 dz z1&lt;br /&gt;
           xmin xmax ymin ymax zmin zmax&lt;br /&gt;
           nogrp grpid]&lt;br /&gt;
 calmisfit2_rigidrlx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, two more input parameters are added. The atoms in xmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sx&amp;lt;xmax, ymin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sy&amp;lt;ymax, and zmin&amp;lt;math&amp;gt;\le&amp;lt;/math&amp;gt;sz&amp;lt;zmax are grouped and their group ID is given as &#039;&#039;&#039;grpid&#039;&#039;&#039;. And the number of groups &#039;&#039;&#039;nogrp&#039;&#039;&#039; = 1 in most cases, here. The command &#039;&#039;&#039;calmisfit2_rigidrlx&#039;&#039;&#039; rigidly relaxes the group of atoms labeled as &#039;&#039;&#039;grpid&#039;&#039;&#039; along the surface normal direction. So, the &amp;quot;Emisfit.out&amp;quot; already contains relaxed surface energy. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;300px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Beforeshift_e.jpg |(a) Atomistic structure for computing ideal shear strength when the periodic repeat vectors are not allowed to tilt.  Several layers of atoms at the top and bottom of the simulation cell are removed.  The atoms inside the volume enclosed by the solid lines will be displaced w.r.t. the remaining atoms.&lt;br /&gt;
Image:Aftershift.jpg |(b) Atomistic structure after the atoms inside the volume specified in (a) are displaced.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Script ==&lt;br /&gt;
The MD++ script (idealstr.tcl) and the Matlab program (cal_idealstr.m) are attached below.  You can use them to reproduce the results described above.  For example, &lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 0&lt;br /&gt;
&lt;br /&gt;
computes the excess energy per unit area as a function of openning displacement perpendicular to the (1 1 0) plane.  On the other hand,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 1&lt;br /&gt;
&lt;br /&gt;
computes the misfit energy of (1 1 1) plane along &amp;lt;math&amp;gt;[1\, 0\, \bar{1}]&amp;lt;/math&amp;gt; direction by tilting the periodic repeat vector &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt;.  Finally,&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/work/idealstr.tcl 2&lt;br /&gt;
&lt;br /&gt;
computes the same misfit energy as above without tilting the periodic repeat vector.&lt;br /&gt;
&lt;br /&gt;
After performing the above MD++ calculation, several files will be generated in the output directory, including Esurf.dat (for tensile strength) and Emisfit.dat (for shear strength).  Copying the Matlab program into the same directory and running this Matlab program will produce energy curves and ideal strength values reported as above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== MD++ Input Script idealstr.tcl ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } {&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = runs/si_idealstr&lt;br /&gt;
  MD++ NIC = 200 NNM = 200&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = 0.67 bondradius = 0.3 bondlength = 0&lt;br /&gt;
  atomcolor = orange bondcolor = red backgroundcolor = gray70&lt;br /&gt;
  win_width = 300 win_height = 300&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
  plot_atom_info = 1 # reduced coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 2 # real coordinates of atoms&lt;br /&gt;
#  plot_atom_info = 3 # energy of atoms&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# calculate surface opening energy on (1 1 0).&lt;br /&gt;
  initmd&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si latticeconst = 5.43095&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
    latticesize = [ 1 1 0 5&lt;br /&gt;
                   -1 1 0 5&lt;br /&gt;
                    0 0 1 7 ]&lt;br /&gt;
    makecrystal }&lt;br /&gt;
  MD++ saveH eval&lt;br /&gt;
  set Lx0 [MD++_Get H_11]&lt;br /&gt;
  set Ly0 [MD++_Get H_22]&lt;br /&gt;
  set Lz0 [MD++_Get H_33]&lt;br /&gt;
  set EPOT0 [MD++_Get EPOT]&lt;br /&gt;
  set Area [expr $Ly0 * $Lz0]&lt;br /&gt;
  set fileID [open &amp;quot;Esurf.dat&amp;quot; w]&lt;br /&gt;
  for {set i -10} {$i &amp;lt;= 100} {incr i} {&lt;br /&gt;
    set strain [expr $i/1000.0]&lt;br /&gt;
    MD++ restoreH RHtoS&lt;br /&gt;
    MD++ input = \[ 1 1 $strain \] changeH_keepR&lt;br /&gt;
    MD++ clearR0 # enforce refresh neighbor list&lt;br /&gt;
    MD++ eval&lt;br /&gt;
    set Lx [MD++_Get H_11]&lt;br /&gt;
    set dist [expr $Lx - $Lx0]&lt;br /&gt;
    set EPOT [MD++_Get EPOT]&lt;br /&gt;
    # Esurf2 : excessive energy per area to create 2 free surfaces.&lt;br /&gt;
    set Esurf2 [expr ($EPOT - $EPOT0)/$Area]&lt;br /&gt;
    puts $fileID &amp;quot;[format %18.14e $dist]\t \&lt;br /&gt;
                  [format %18.14e $Esurf2]&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
  close $fileID&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.43095&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 4; set Nz 3&lt;br /&gt;
&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
# To make shuffle set of (111) plane exposed&lt;br /&gt;
  MD++ { input = [0 0.05 0 ] pbcshiftatom }&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz \]&lt;br /&gt;
  MD++ calmisfit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# calculate generalized stacking fault energy on (1 1 1) along [1 0 -1]&lt;br /&gt;
  initmd&lt;br /&gt;
# surface normal direction 1/x 2/y 3/z&lt;br /&gt;
  set surfacenormal 2&lt;br /&gt;
  set lattconst 5.431&lt;br /&gt;
  set c1 &amp;quot;1 0 -1&amp;quot;; set c2 &amp;quot;1 1 1&amp;quot;; set c3 &amp;quot;1 -2 1&amp;quot;&lt;br /&gt;
  set Nx 5; set Ny 6; set Nz 3&lt;br /&gt;
  set gridx &amp;quot; 0.000 0.005 0.500&amp;quot;&lt;br /&gt;
  set gridy &amp;quot;-0.050 0.010 0.150&amp;quot;&lt;br /&gt;
  set gridz &amp;quot; 0.000 0.050 0.000&amp;quot;&lt;br /&gt;
  set xmin -1.00; set xmax 1.00&lt;br /&gt;
  set ymin  0.01; set ymax 1.00&lt;br /&gt;
  set zmin -1.00; set zmax 1.00&lt;br /&gt;
&lt;br /&gt;
# write the matlab script&lt;br /&gt;
  set fileID [open &amp;quot;parameter.m&amp;quot; w]&lt;br /&gt;
  puts $fileID &amp;quot;normaldir = $surfacenormal&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticeconst = $lattconst&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;latticesize = \[ $c1 $Nx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c2 $Ny &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;                 $c3 $Nz \]&amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;dxyz = \[ $gridx &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridy &amp;quot;&lt;br /&gt;
  puts $fileID &amp;quot;          $gridz \]&amp;quot;&lt;br /&gt;
  close $fileID&lt;br /&gt;
&lt;br /&gt;
  MD++ {&lt;br /&gt;
    element0 = Si&lt;br /&gt;
    crystalstructure = diamond-cubic&lt;br /&gt;
  }&lt;br /&gt;
  MD++ latticeconst = $lattconst&lt;br /&gt;
  MD++ latticesize = \[$c1 $Nx $c2 $Ny $c3 $Nz\]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ input = \[1 -1 1 0.4 1 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[1 -1 1 -1 -0.42 -1 1 \] fixatoms_by_position removefixedatoms&lt;br /&gt;
  MD++ input = \[ $surfacenormal $gridx $gridy $gridz $xmin $xmax $ymin $ymax $zmin $zmax \]&lt;br /&gt;
  MD++ calmisfit2&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Matlab Program cal_idealstr.m ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%#! /usr/local/bin/octave -qf&lt;br /&gt;
% Matlab script, cal_idealstr.m&lt;br /&gt;
% to calculate ideal tensile strength &amp;quot;sigma&amp;quot; and shear strength &amp;quot;tau&amp;quot;&lt;br /&gt;
clear&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal tensile strength along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
data = load(’Esurf.dat’);&lt;br /&gt;
d = data(:,1);     % openning distance in A&lt;br /&gt;
gamma = data(:,2); % excessive energy per area creating 2 free surfaces (eV/A^2)&lt;br /&gt;
&lt;br /&gt;
sigma = max(gamma(2:end)-gamma(1:end-1))/(d(2) - d(1)) * 160.2;&lt;br /&gt;
disp(sprintf(’Ideal tensile stregnth = %e(GPa)’,sigma));&lt;br /&gt;
&lt;br /&gt;
figure(1)&lt;br /&gt;
set(gca,’fontsize’,14)&lt;br /&gt;
plot(d, gamma, ’.-’), grid&lt;br /&gt;
xlabel(’Opening Distance \it d \rm(Angstrom)’,’fontsize’,16),&lt;br /&gt;
ylabel(’\gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
line([-1 1.1],[gamma(end) gamma(end)],’linewidth’,2,’color’,’k’)&lt;br /&gt;
text(-1.3, gamma(end),’2\gamma_s’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% calculate ideal shear strength on (111) along [110] direction&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
if (~exist(’parameter.m’,’file’))&lt;br /&gt;
    error(’No parameter.m found’)&lt;br /&gt;
else&lt;br /&gt;
    parameter&lt;br /&gt;
&lt;br /&gt;
    dx = dxyz(1,2); dy = dxyz(2,2); dz = dxyz(3,2);&lt;br /&gt;
    vx = latticesize(1,1:3); Lx = latticeconst*norm(vx);&lt;br /&gt;
    vy = latticesize(2,1:3); Ly = latticeconst*norm(vy);&lt;br /&gt;
    vz = latticesize(3,1:3); Lz = latticeconst*norm(vz);&lt;br /&gt;
&lt;br /&gt;
    data = load(’Emisfit.out’);&lt;br /&gt;
    Mx=max(data(:,1)); My=max(data(:,2)); Mz=max(data(:,3));&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% convert data to relaxed energy&lt;br /&gt;
    MM=-sort(-[Mx+1,My+1,Mz+1]);         % Then MM(1) &amp;gt; MM(2) &amp;gt; MM(3)&lt;br /&gt;
    E = reshape(data(:,4),MM(1),MM(2));&lt;br /&gt;
&lt;br /&gt;
    Erlx = zeros(MM(1),1);&lt;br /&gt;
    Zrlx = zeros(MM(1),1);&lt;br /&gt;
&lt;br /&gt;
    normalgrid = dxyz(normaldir,1):dxyz(normaldir,2):dxyz(normaldir,3);&lt;br /&gt;
    normalfinegrid = dxyz(normaldir,1):dxyz(normaldir,2)/1000:dxyz(normaldir,3);&lt;br /&gt;
&lt;br /&gt;
    for i = 1:MM(1),&lt;br /&gt;
        a = E(i,:);&lt;br /&gt;
        a_interp = interp1(normalgrid,a,normalfinegrid,’spline’);&lt;br /&gt;
        [Erlx(i), ind] = min(a_interp);&lt;br /&gt;
        Zrlx(i) = normalfinegrid(ind);&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
% retrieve unrelaxed energy&lt;br /&gt;
    Eunrlx=E(:,find(abs(normalgrid)&amp;lt;1e-8));&lt;br /&gt;
&lt;br /&gt;
% calculate ideal shear strength&lt;br /&gt;
    tau = max(Erlx(2:end)-Erlx(1:end-1))/(dx*Lx) * 160.2;&lt;br /&gt;
    disp(sprintf(’Ideal shear stregnth = %e(GPa)’,tau));&lt;br /&gt;
&lt;br /&gt;
    figure(2); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx, Erlx-Erlx(1), ’b.-’,...&lt;br /&gt;
         [0:Mx]/Mx, Eunrlx-Eunrlx(1),’r-’);&lt;br /&gt;
    legend(’relaxed’,’unrelaxed’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel(’\Gamma (eV/Angstrom^2)’,’fontsize’,16)&lt;br /&gt;
&lt;br /&gt;
    figure(3); set(gca,’fontsize’,14)&lt;br /&gt;
    plot([0:Mx]/Mx,Zrlx, ’r.-’, ...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,1),’b-’,...&lt;br /&gt;
         [0 1],[1 1]*dxyz(normaldir,3),’b-’);&lt;br /&gt;
    xlabel(’Sheared Distance, d/|b| where b = [1 0 1]/2’,’fontsize’,16)&lt;br /&gt;
    ylabel({’Lowest energy height,’; ’\delta/|c_2| where c_2 = [1 1 1]’},’fontsize’,16)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Tensile strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, the length of the first lattice vector is changed from 0.9 to 1.6 of its equilibrium length in steps of 0.01.  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
declare -i x=9000&lt;br /&gt;
while (($x &amp;lt;= 16000))&lt;br /&gt;
do&lt;br /&gt;
a=$(echo &amp;quot;scale=3; $x/10000&amp;quot; | bc -l)&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  $a  $a  0.0     first  lattice vector&lt;br /&gt;
 -1.0 1.0 0.0     second lattice vector&lt;br /&gt;
  0.0 0.0 1.0     third  lattice vector&lt;br /&gt;
 16               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
cart           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
 -0.7500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   0.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
 -0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
 -0.2500000000000000   1.2500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   0.5000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   0.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.7500000000000000   0.7500000000000000   0.2500000000000000 F F F&lt;br /&gt;
  0.2500000000000000   0.7500000000000000   0.7500000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.0000000000000000   0.0000000000000000 F F F&lt;br /&gt;
  0.0000000000000000   1.5000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.5000000000000000   1.0000000000000000   0.5000000000000000 F F F&lt;br /&gt;
  0.2500000000000000   1.2500000000000000   0.2500000000000000 F F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=100&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Shell script for Computing Ideal Shear strength by VASP ===&lt;br /&gt;
The following shell script will create the &#039;&#039;&#039;POSCAR&#039;&#039;&#039; file which specifies the atomic positions for VASP.  You will also need to prepare &#039;&#039;&#039;INCAR&#039;&#039;&#039;, &#039;&#039;&#039;KPOINTS&#039;&#039;&#039;, &#039;&#039;&#039;POTCAR&#039;&#039;&#039; files in the same directory for VASP to run.  This script will run VASP in serial mode.  You can modify it to submit VASP jobs in parallel.&lt;br /&gt;
&lt;br /&gt;
In this script, position of a set of atoms is displaced along the y-direction [1 0 -1] but are allowed to relax in the x-direction [1 1 1].  A VASP calculation is performed for each length of the lattice vector to obtain the potential energy, which is then saved into file &#039;&#039;summary&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
function add() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 + $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function subtract() {&lt;br /&gt;
  echo &amp;quot;scale=17; $1 - $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function div() {&lt;br /&gt;
  echo &amp;quot;scale=3; $1 / $2&amp;quot; | bc -l&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
declare -i x=0&lt;br /&gt;
while (($x &amp;lt;= 50))&lt;br /&gt;
do&lt;br /&gt;
a=$(div $x 100)&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
Si    comment line&lt;br /&gt;
5.389            universal scaling factor&lt;br /&gt;
  2.0 2.0  2.0    first  lattice vector&lt;br /&gt;
  1.0 0.0 -1.0     second lattice vector&lt;br /&gt;
 -0.5 1.0 -0.5     third  lattice vector&lt;br /&gt;
 32               number of atoms per species&lt;br /&gt;
selective dynamics&lt;br /&gt;
direct           direct or cart (only first letter is significant)&lt;br /&gt;
 -0.3125000000000000   0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000  -0.2500000000000000   0.0000000000000000 T F F&lt;br /&gt;
 -0.3125000000000000   0.0000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.2708333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.3125000000000000  -0.5000000000000000  -0.5000000000000000 T F F&lt;br /&gt;
 -0.1458333333333334  -0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.2708333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1458333333333334   0.0000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.2708333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
 -0.1041666666666667  -0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667  -0.5000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
 -0.1458333333333334  -0.5000000000000000   0.1666666666666666 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add -0.5000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
 -0.2708333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1458333333333334   0.2500000000000000  -0.3333333333333334 T F F&lt;br /&gt;
 -0.1041666666666667   0.2500000000000000   0.3333333333333333 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.2500000000000000 $a)   0.3333333333333333 T F F&lt;br /&gt;
 -0.1041666666666667   0.0000000000000000  -0.1666666666666667 T F F&lt;br /&gt;
  0.0208333333333333 $(add  0.0000000000000000 $a)  -0.1666666666666667 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.2500000000000000 $a)   0.0000000000000000 T F F&lt;br /&gt;
  0.1875000000000000 $(add  0.0000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.0625000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
  0.1875000000000000 $(add -0.5000000000000000 $a)  -0.5000000000000000 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.0000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add -0.5000000000000000 $a)   0.1666666666666666 T F F&lt;br /&gt;
  0.2291666666666666 $(add  0.2500000000000000 $a)  -0.3333333333333334 T F F&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
vasp&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E &amp;gt;&amp;gt; summary&lt;br /&gt;
let x+=5&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5960</id>
		<title>MD Potential Files</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5960"/>
		<updated>2014-01-10T15:17:24Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Relation between the parameters in SW potential and in MD++ codes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Potential Types==&lt;br /&gt;
This table contains information about the potentials use in MD++.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name of Potential || executable  ||  Types of Materials &lt;br /&gt;
|-&lt;br /&gt;
| Molecular Dynamics  || md_$(SYS) ||  empty potential, for visualization and atom manipulation &lt;br /&gt;
|-&lt;br /&gt;
| Finnis-Sinclair     || fs_$(SYS) ||  BCC metals (Mo, Ta, W, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Embedded Atom Method || eam_$(SYS) || FCC metals (Cu, Au, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum Glue       || alglue_$(SYS) || Al (FCC metal)&lt;br /&gt;
|-&lt;br /&gt;
| Modified Embedded Atom Method || meam_$(SYS) || FCC metals, BCC metals, semiconductors&lt;br /&gt;
|-&lt;br /&gt;
| Lennard-Jones       || lj_$(SYS) ||  Noble gas (Ar, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Stillinger-Webber   || sw_$(SYS) ||  Semiconductors (Si, Ge, C)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff             || tersoff_$(SYS) || Semiconductors (Si, Ge, C), PRB &#039;&#039;&#039;39&#039;&#039;&#039; 5566 (1989)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff88           || tersoff88_$(SYS) || Si(B) - PRB &#039;&#039;&#039;37&#039;&#039;&#039; 6991 (1988), Si(C) - PRB &#039;&#039;&#039;38&#039;&#039;&#039; 9902 (1988) In default, the parameters are set to Si(C). The parameters can be reset to Si(B) by modifying source code, &amp;quot;tersoff88.cpp&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| Brenner             || brenner_$(SYS) || C, hydrocarbons&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Relation between the parameters in SW potential and in MD++ codes ==&lt;br /&gt;
&lt;br /&gt;
The parameters in SW potential model and in MD++ codes are associated, following the rules described in table below. When changing values of the parameters in MD++ codes, make sure you know what you are changing and how. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameters in Balamane et al (PRB 46 2250) || Parameters in original SW (PRB 31 5262) ||  Variables in MD++ &lt;br /&gt;
|-&lt;br /&gt;
| A_1  || = &amp;amp;epsilon;*A*B*&amp;amp;sigma;^p || bb = A_1/aa = B*&amp;amp;sigma;^(p-q)&lt;br /&gt;
|-&lt;br /&gt;
| A_2  || = &amp;amp;epsilon;*A*&amp;amp;sigma;^q || = aa&lt;br /&gt;
|-&lt;br /&gt;
| Z  || = &amp;amp;epsilon;*&amp;amp;lambda; || = plam&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;mu;  || = &amp;amp;sigma; || = pss&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;alpha;  || = &amp;amp;gamma; || pgam = &amp;amp;gamma;*pss&lt;br /&gt;
|-&lt;br /&gt;
| R_c  || = a*&amp;amp;sigma; || = acut&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;lambda;_1  || = p || = rho&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;lambda;_2  || = q || Not Used (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Potential&amp;quot; Problems==&lt;br /&gt;
&lt;br /&gt;
These are some potential files we used in our simulations of molecular structures.  Please note that since we use a variety of codes, the potential files will be in a variety of formats.  The most common codes used by our group are LAMMPS ( and ParaDyne) and MD++.  These codes use different file formats for EAM potentials, so all files should specify which file format.  We will also try to provide a reference describing the potential.&lt;br /&gt;
&lt;br /&gt;
==Potential Files==&lt;br /&gt;
&lt;br /&gt;
===MD++ Files===&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_aufoiles.txt‎ | EAM Foiles potential for Gold.]] &lt;br /&gt;
Ref: Park, H. S., Zimmerman J. A., Modeling inelasticity and failure in gold nanowires. Phys. Rev. B 72, 054106 (2005).&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_cufoiles.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS SET Files ===&lt;br /&gt;
&lt;br /&gt;
[[media:cufoiles_set.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS FUNC Files===&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5959</id>
		<title>MD Potential Files</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5959"/>
		<updated>2014-01-10T15:15:03Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Potential Types==&lt;br /&gt;
This table contains information about the potentials use in MD++.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name of Potential || executable  ||  Types of Materials &lt;br /&gt;
|-&lt;br /&gt;
| Molecular Dynamics  || md_$(SYS) ||  empty potential, for visualization and atom manipulation &lt;br /&gt;
|-&lt;br /&gt;
| Finnis-Sinclair     || fs_$(SYS) ||  BCC metals (Mo, Ta, W, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Embedded Atom Method || eam_$(SYS) || FCC metals (Cu, Au, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum Glue       || alglue_$(SYS) || Al (FCC metal)&lt;br /&gt;
|-&lt;br /&gt;
| Modified Embedded Atom Method || meam_$(SYS) || FCC metals, BCC metals, semiconductors&lt;br /&gt;
|-&lt;br /&gt;
| Lennard-Jones       || lj_$(SYS) ||  Noble gas (Ar, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Stillinger-Webber   || sw_$(SYS) ||  Semiconductors (Si, Ge, C)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff             || tersoff_$(SYS) || Semiconductors (Si, Ge, C), PRB &#039;&#039;&#039;39&#039;&#039;&#039; 5566 (1989)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff88           || tersoff88_$(SYS) || Si(B) - PRB &#039;&#039;&#039;37&#039;&#039;&#039; 6991 (1988), Si(C) - PRB &#039;&#039;&#039;38&#039;&#039;&#039; 9902 (1988) In default, the parameters are set to Si(C). The parameters can be reset to Si(B) by modifying source code, &amp;quot;tersoff88.cpp&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| Brenner             || brenner_$(SYS) || C, hydrocarbons&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Relation between the parameters in SW potential and in MD++ codes ==&lt;br /&gt;
&lt;br /&gt;
The parameters in SW potential model and in MD++ codes are associated, following the rules described in table below. When changing values of the parameters in MD++ codes, make sure you know what you are changing and how. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Parameters in Balamane et al (PRB 46 2250) || Parameters in original SW (PRB 31 5262) ||  Variables in MD++ &lt;br /&gt;
|-&lt;br /&gt;
| A_1  || = &amp;amp;epsilon;AB&amp;amp;sigma;^p || bb = A_1/aa = B&amp;amp;sigma;^(p-q)&lt;br /&gt;
|-&lt;br /&gt;
| A_2  || = &amp;amp;epsilon;A&amp;amp;sigma;^q || = aa&lt;br /&gt;
|-&lt;br /&gt;
| Z  || = &amp;amp;epsilon;&amp;amp;lambda; || = plam&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;mu;  || = &amp;amp;sigma; || = pss&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;alpha;  || = &amp;amp;gamma; || pgam = &amp;amp;gamma;pss&lt;br /&gt;
|-&lt;br /&gt;
| R_c  || = a&amp;amp;sigma; || = acut&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;lambda;_1  || = p || = rho&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;lambda;_2  || = q || Not Used (0)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Potential&amp;quot; Problems==&lt;br /&gt;
&lt;br /&gt;
These are some potential files we used in our simulations of molecular structures.  Please note that since we use a variety of codes, the potential files will be in a variety of formats.  The most common codes used by our group are LAMMPS ( and ParaDyne) and MD++.  These codes use different file formats for EAM potentials, so all files should specify which file format.  We will also try to provide a reference describing the potential.&lt;br /&gt;
&lt;br /&gt;
==Potential Files==&lt;br /&gt;
&lt;br /&gt;
===MD++ Files===&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_aufoiles.txt‎ | EAM Foiles potential for Gold.]] &lt;br /&gt;
Ref: Park, H. S., Zimmerman J. A., Modeling inelasticity and failure in gold nanowires. Phys. Rev. B 72, 054106 (2005).&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_cufoiles.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS SET Files ===&lt;br /&gt;
&lt;br /&gt;
[[media:cufoiles_set.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS FUNC Files===&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5958</id>
		<title>MD Potential Files</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5958"/>
		<updated>2014-01-10T14:47:54Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* &amp;quot;Potential&amp;quot; Problems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Potential Types==&lt;br /&gt;
This table contains information about the potentials use in MD++.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name of Potential || executable  ||  Types of Materials &lt;br /&gt;
|-&lt;br /&gt;
| Molecular Dynamics  || md_$(SYS) ||  empty potential, for visualization and atom manipulation &lt;br /&gt;
|-&lt;br /&gt;
| Finnis-Sinclair     || fs_$(SYS) ||  BCC metals (Mo, Ta, W, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Embedded Atom Method || eam_$(SYS) || FCC metals (Cu, Au, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum Glue       || alglue_$(SYS) || Al (FCC metal)&lt;br /&gt;
|-&lt;br /&gt;
| Modified Embedded Atom Method || meam_$(SYS) || FCC metals, BCC metals, semiconductors&lt;br /&gt;
|-&lt;br /&gt;
| Lennard-Jones       || lj_$(SYS) ||  Noble gas (Ar, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Stillinger-Webber   || sw_$(SYS) ||  Semiconductors (Si, Ge, C)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff             || tersoff_$(SYS) || Semiconductors (Si, Ge, C), PRB &#039;&#039;&#039;39&#039;&#039;&#039; 5566 (1989)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff88           || tersoff88_$(SYS) || Si(B) - PRB &#039;&#039;&#039;37&#039;&#039;&#039; 6991 (1988), Si(C) - PRB &#039;&#039;&#039;38&#039;&#039;&#039; 9902 (1988) In default, the parameters are set to Si(C). The parameters can be reset to Si(B) by modifying source code, &amp;quot;tersoff88.cpp&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| Brenner             || brenner_$(SYS) || C, hydrocarbons&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Potential&amp;quot; Problems==&lt;br /&gt;
&lt;br /&gt;
These are some potential files we used in our simulations of molecular structures.  Please note that since we use a variety of codes, the potential files will be in a variety of formats.  The most common codes used by our group are LAMMPS ( and ParaDyne) and MD++.  These codes use different file formats for EAM potentials, so all files should specify which file format.  We will also try to provide a reference describing the potential.&lt;br /&gt;
&lt;br /&gt;
==Potential Files==&lt;br /&gt;
&lt;br /&gt;
===MD++ Files===&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_aufoiles.txt‎ | EAM Foiles potential for Gold.]] &lt;br /&gt;
Ref: Park, H. S., Zimmerman J. A., Modeling inelasticity and failure in gold nanowires. Phys. Rev. B 72, 054106 (2005).&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_cufoiles.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS SET Files ===&lt;br /&gt;
&lt;br /&gt;
[[media:cufoiles_set.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS FUNC Files===&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5939</id>
		<title>MD Potential Files</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=MD_Potential_Files&amp;diff=5939"/>
		<updated>2013-10-27T12:27:23Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Potential Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Potential Types==&lt;br /&gt;
This table contains information about the potentials use in MD++.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name of Potential || executable  ||  Types of Materials &lt;br /&gt;
|-&lt;br /&gt;
| Molecular Dynamics  || md_$(SYS) ||  empty potential, for visualization and atom manipulation &lt;br /&gt;
|-&lt;br /&gt;
| Finnis-Sinclair     || fs_$(SYS) ||  BCC metals (Mo, Ta, W, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Embedded Atom Method || eam_$(SYS) || FCC metals (Cu, Au, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum Glue       || alglue_$(SYS) || Al (FCC metal)&lt;br /&gt;
|-&lt;br /&gt;
| Modified Embedded Atom Method || meam_$(SYS) || FCC metals, BCC metals, semiconductors&lt;br /&gt;
|-&lt;br /&gt;
| Lennard-Jones       || lj_$(SYS) ||  Noble gas (Ar, ...)&lt;br /&gt;
|-&lt;br /&gt;
| Stillinger-Webber   || sw_$(SYS) ||  Semiconductors (Si, Ge, C)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff             || tersoff_$(SYS) || Semiconductors (Si, Ge, C), PRB &#039;&#039;&#039;39&#039;&#039;&#039; 5566 (1989)&lt;br /&gt;
|-&lt;br /&gt;
| Tersoff88           || tersoff88_$(SYS) || Si(B) - PRB &#039;&#039;&#039;37&#039;&#039;&#039; 6991 (1988), Si(C) - PRB &#039;&#039;&#039;38&#039;&#039;&#039; 9902 (1988) In default, the parameters are set to Si(C). The parameters can be reset to Si(B) by modifying source code, &amp;quot;tersoff88.cpp&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
| Brenner             || brenner_$(SYS) || C, hydrocarbons&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==&amp;quot;Potential&amp;quot; Problems==&lt;br /&gt;
&lt;br /&gt;
These are some potential files we used in our simulations of molecular structures.  Please note that since we use a variety of codes, the potential files will be in a variety of foremats.  The most common codes used by our group are LAMMPS ( and ParaDyne) and MD++.  These codes use different file formats for EAM potentials, so all files should specify which file format.  We will also try to provide a reference describing the potential.&lt;br /&gt;
&lt;br /&gt;
==Potential Files==&lt;br /&gt;
&lt;br /&gt;
===MD++ Files===&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_aufoiles.txt‎ | EAM Foiles potential for Gold.]] &lt;br /&gt;
Ref: Park, H. S., Zimmerman J. A., Modeling inelasticity and failure in gold nanowires. Phys. Rev. B 72, 054106 (2005).&lt;br /&gt;
&lt;br /&gt;
[[media:eamdata_cufoiles.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS SET Files ===&lt;br /&gt;
&lt;br /&gt;
[[media:cufoiles_set.txt‎ | EAM Foiles potential for Copper.]] &lt;br /&gt;
Ref: Aubry, S. and Hughes, D. A., Reductions in stacking fault widths in fcc crystals: Semiempirical calculations.  Phys. Rev. B 73, 224116 (2006).&lt;br /&gt;
&lt;br /&gt;
===LAMMPS FUNC Files===&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5936</id>
		<title>M02 Making a Perfect Crystal</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5936"/>
		<updated>2013-09-27T04:53:17Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Hexagonal-close-packed (HCP) structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 02 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Making a Perfect Crystal&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 25 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many solid materials have a periodic crystal structure.&amp;lt;ref&amp;gt;Glass is a counter-example, which is noncrystalline. We call it an amorphous material. Sometimes people consider it as supercooled liquid instead of a true solid, because, like a liquid, glass can flow under shear stress, although at very slow rate.&amp;lt;/ref&amp;gt; &lt;br /&gt;
For example, copper and aluminum have the face-centered-cubic (FCC) structure, while molybdenum and tungsten have the body-centered-cubic (BCC) structure under ambient conditions. The periodic arrangement of atoms simplifies the process of setting up&lt;br /&gt;
an atomistic simulation, because we can use a periodic array of atoms as the&lt;br /&gt;
initial condition. Thus, building up a crystal structure is often the first step in&lt;br /&gt;
the atomistic simulation of solids. In this manual, we will learn how to build several&lt;br /&gt;
crystal structures in MD++ with the example scripts.&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Face-centered-cubic crystal ==&lt;br /&gt;
First, let&#039;s make a perfect FCC aluminum crystal. The script file &#039;&#039;&#039;al.script&#039;&#039;&#039;,&lt;br /&gt;
together with other script files discussed in this manual, can be found in the&lt;br /&gt;
directory &#039;&#039;&#039;MD++/scripts/ME346&#039;&#039;&#039;. To run this script file, type&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/Codes/MD++&lt;br /&gt;
 $ bin/md_gpp scripts/ME346/al.script&lt;br /&gt;
&lt;br /&gt;
The executable file, &#039;&#039;&#039;md_gpp&#039;&#039;&#039; does not contain any potential model, but can be&lt;br /&gt;
used to visualize the atomic structure, as mentioned in the [[M01 Introduction to MD++|Manual 01]].&amp;lt;ref&amp;gt;You can compile the executable &#039;&#039;&#039;alglue_gpp&#039;&#039;&#039;, which is a glue potential model for&lt;br /&gt;
aluminum by typing &lt;br /&gt;
 $ make alglue build=R.&amp;lt;/ref&amp;gt; &lt;br /&gt;
Here is the content of the &#039;&#039;&#039;al.script&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/al-example     # To specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.05           # lattice constant for Al (unit: Angstrom)&lt;br /&gt;
latticesize = [ 1 0 0 1       # c1 = 1*[1 0 0] periodicity vec. in x&lt;br /&gt;
                0 1 0 1       # c2 = 1*[0 1 0] periodicity vec. in y&lt;br /&gt;
                0 0 1 1]      # c3 = 1*[0 0 1] periodicity vec. in z&lt;br /&gt;
makecrystal&lt;br /&gt;
&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1.0 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Visualization of FCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:fcc.jpg|(a) Conventional image of FCC unit cell&lt;br /&gt;
Image:al1X1X1.jpg|(b) FCC unit cell in MD++. One corner atom and three face-centered atoms per cell&lt;br /&gt;
Image:al3X3X3.jpg|(c) FCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FCC, as well as HCP (Hexagonal Close Packed), is a close-packed crystal structure. In Fig.1(a), you can see the conventional image of  FCC unit cell structure, where there is an atom at every corner and every face center of the cube. Since each corner atom is shared by 8 adjacent cubes and each face-centered atom is shared by 2 cubes, the total number of atoms per unit cell will be &amp;lt;math&amp;gt;8 \times  1/8 + 6 \times 1/2 = 4&amp;lt;/math&amp;gt;. In MD++, four atoms will be plotted per unti cell as shown in Fig.1(b), which is exactly what you see when you run &#039;&#039;&#039;al.script&#039;&#039;&#039;. Now imagine that the unit cell is replicated periodically in all 3 directions to fill the entire space. This would create an infinitely large crystal. We can create a larger crystal by modifying the &#039;&#039;&#039;latticesize&#039;&#039;&#039; variable, &#039;&#039;e.g.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 latticesize = [ 1 0 0 3&lt;br /&gt;
                 0 1 0 3&lt;br /&gt;
                 0 0 1 3]&lt;br /&gt;
&lt;br /&gt;
This creates a crystal with &amp;lt;math&amp;gt;3 \times 3 \times 3 = 27&amp;lt;/math&amp;gt; unit cells as shown in the Fig.1(c). The &#039;&#039;&#039;plot&#039;&#039;&#039; section of this script file will be explained in Manual 06.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 1&#039;&#039; Make a perfect crystal of copper (Cu) of 4 X 4 X 4 unit&lt;br /&gt;
cells. Cu has an FCC crystal structure and its equilibrium lattice constant&lt;br /&gt;
is &amp;lt;math&amp;gt;a = &amp;lt;/math&amp;gt;3.6030 &amp;amp;Aring;. You can use &#039;&#039;&#039;md_gpp&#039;&#039;&#039; as the executable file&amp;lt;ref&amp;gt;For MD simulations of Cu or Al, the fourth column of latticesize should not be smaller than 4 due to the relatively large cut-off radius in their potential models (&#039;&#039;&#039;eam&#039;&#039;&#039; or &#039;&#039;&#039;alglue&#039;&#039;&#039;).&amp;lt;/ref&amp;gt; if you only want to visualize the structure. Use &#039;&#039;&#039;eam_gpp&#039;&#039;&#039; if you would like to do some computation using the potential model. (For example, the &#039;&#039;&#039;eval&#039;&#039;&#039; command computes the total potential energy of the structure.) For the latter case, you need to insert the following two lines into your script file after &#039;&#039;&#039;dirname&#039;&#039;&#039;.&lt;br /&gt;
 &lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/EAMDATA/eamdata.Cu&lt;br /&gt;
 eamgrid = 5000 readeam&lt;br /&gt;
&lt;br /&gt;
This reads the data needed by the EAM potential model of Cu.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 2&#039;&#039; Make a perfect crystal of argon (Ar) of 4 X 4 X 4 unit cells.&lt;br /&gt;
Ar is inert gas at room temperature but its solid state is face-centered-cubic crystal below its melting temperature &amp;lt;math&amp;gt;T_m = &amp;lt;/math&amp;gt;83.81K. Ar can be simulated&lt;br /&gt;
by the Leonard-Jones potential model or the executable &#039;&#039;&#039;lj_gpp&#039;&#039;&#039;. Modify &#039;&#039;&#039;scripts/ME346/ar.script&#039;&#039;&#039; and run it by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/lj_gpp scripts/ME346/ar.script&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Body-centered-cubic crystal ==&lt;br /&gt;
The BCC structure has an atom at every corner and body-center of each cube&lt;br /&gt;
(unit cell), as shown in Fig.2(a). Molybdenum (Mo) is one example of BCC materials.&lt;br /&gt;
Run &#039;&#039;&#039;mo.script&#039;&#039;&#039; file by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/ME346/mo.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;mo.script&#039;&#039;&#039; file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472         # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3 ]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = orange highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Visualization of BCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Bcc.jpg|(a) Conventional image of BCC unit cell&lt;br /&gt;
Image:mo1X1X1.jpg|(b) BCC unit cell in MD++. One corner atom and one body-centered atom per cell&lt;br /&gt;
Image:mo3X3X3.jpg|(c) BCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Fig.2(c), the simulation box (&#039;&#039;i.e.&#039;&#039; supercell) is defined by three periodicity&lt;br /&gt;
vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = 3[100], \mathbf{c}_2 = 3[010], \mathbf{c}_3 = 3[001]. &amp;lt;/math&amp;gt;&lt;br /&gt;
The command &#039;&#039;&#039;makecrystal&#039;&#039;&#039; generates the perfect crystal of molybdenum based&lt;br /&gt;
on the given variables, &#039;&#039;&#039;crystalstructure&#039;&#039;&#039;&amp;lt;ref&amp;gt;Other possible values for crystalstructure are “simple-cubic”, “face-centered-cubic”,“L1_2”, “L1_0”, “diamond-cubic”, “zinc-blende”, etc. For a complete list, please read&lt;br /&gt;
&#039;&#039;&#039;src/lattice.h&#039;&#039;&#039;.&amp;lt;/ref&amp;gt; , &#039;&#039;&#039;latticeconst&#039;&#039;&#039;, and &#039;&#039;&#039;latticesize&#039;&#039;&#039;. &lt;br /&gt;
The configuration will be saved as &#039;&#039;&#039;perf.cn&#039;&#039;&#039; in the directory of &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; by the command &#039;&#039;&#039;writecn&#039;&#039;&#039;. The configuration file contains the number of atoms and the position of all the atoms in terms of scaled coordinates followed by a 3 X 3 matrix, &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;, whose columns are the three periodicity vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;. The real coordinates of an atom, &amp;lt;math&amp;gt;\mathbf{r} = (x, y, z)^T&amp;lt;/math&amp;gt; is related to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s} = (s_x, s_y, s_z)^T&amp;lt;/math&amp;gt; through matrix multiplication&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r} = a\mathbf{H}\cdot \mathbf{s} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is the lattice constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 3&#039;&#039; Make a perfect crystal of tantalum (Ta) with repeat vectors &amp;lt;math&amp;gt;\mathbf{c}_1 = 3[1 1 0], \mathbf{c}_2 = 3[1 \bar{1} 0], \mathbf{c}_3 = 4[0 0 1]&amp;lt;/math&amp;gt;. &lt;br /&gt;
Ta has a BCC lattice structure with an equilibrium lattice constant &amp;lt;math&amp;gt;a =&amp;lt;/math&amp;gt; 3.3058 &amp;amp;Aring;. &lt;br /&gt;
Read the FS potential file for Ta by inserting the following line in the script.&lt;br /&gt;
&lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/ta_pot readpot&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diamond-cubic crystal ==&lt;br /&gt;
Silicon (Si) has diamond-cubic structure, which can be regarded as two FCC structures oﬀset by [1 1 1]/4. You can run the example script &#039;&#039;&#039;si.script&#039;&#039;&#039; by typing&lt;br /&gt;
&lt;br /&gt;
  $ bin/sw_gpp scripts/ME346/si.script&lt;br /&gt;
&lt;br /&gt;
where the executable &#039;&#039;&#039;sw_gpp&#039;&#039;&#039; contains the SW potential model for Si. The&lt;br /&gt;
visualization window will look like Fig.3(b). Here is the content of the &#039;&#039;&#039;si.script&#039;&#039;&#039; ﬁle.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si-example&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.43095            # (in Angstrom) for Si&lt;br /&gt;
latticesize = [ 1 0 0 2&lt;br /&gt;
                0 1 0 2&lt;br /&gt;
                0 0 1 2 ]&lt;br /&gt;
makecrystal writecn&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = 0.67 bondradius = 0.3 bondlength = 2.8285 &lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 Visualization of DC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Dc_unitcell.jpg|(a) DC unit cell in MD++. 8 atoms per cell&lt;br /&gt;
Image:Dc_2x2x2cell.jpg|(c) DC of 2X2X2 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hexagonal-close-packed (HCP) structure ==&lt;br /&gt;
&lt;br /&gt;
Conventionally, an HCP structure has repeated hexagonal or parallelogram cells (red line in Fig. 4(a)), neither of which satisfies periodic boundary conditions imposed along three orthogonal axes (&#039;&#039;x&#039;&#039;, &#039;&#039;y&#039;&#039;, and &#039;&#039;z&#039;&#039;). So, in MD++ we use a rectangular unit cell (blue line in Fig.4(a)), which contains 4 atoms as shown in Fig.4 (b). The scaled coordinates of these 4 atoms are (0,0,0), (0.5, 0.5, 0), (0.5, 1/6, 0.5) and (0, 2/3, 0.5) in the rectangular unit cell. &lt;br /&gt;
&lt;br /&gt;
The script &#039;&#039;&#039;hcp-mg.tcl&#039;&#039;&#039;, shown below, creates HCP structure. Note that MD++ variable &#039;&#039;&#039;latticeconst&#039;&#039;&#039; now takes three values. The 1st one is the lattice constant &#039;&#039;a&#039;&#039;, and the last one is the lattice constant &#039;&#039;c&#039;&#039;. The 2nd argument can be ignored. For HCP, c is mostly a * sqrt(8/3) = 1.633 a. You can assign the c/a ratio somewhat different from 1.633.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/hcp-mg.tcl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 HCP structure&amp;quot; widths=&amp;quot;400px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Hcp2.gif|(a) HCP conventional unit cell (red) and HCP rectangular unit cell (blue) (b) HCP unit cell in MD++. 4 atoms per cell&lt;br /&gt;
Image:Hcp6X4X4.gif|(c) HCP structure of 6X4X4 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# HCP structure&lt;br /&gt;
MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = runs/HCP&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
set latt0 3.184&lt;br /&gt;
set c_over_a 1.633&lt;br /&gt;
MD++ latticestructure = hexagonal-ortho&lt;br /&gt;
# x-axis: [1 0 0] = [-1 2 -1 0]/3, &lt;br /&gt;
# y-axis: [0 1 0] = [1 0 -1 0], &lt;br /&gt;
# z-axis: [0 0 1] = [0 0 0 1] c-axis&lt;br /&gt;
MD++ latticesize = \[ 1 0 0 6 \&lt;br /&gt;
                      0 1 0 4 \&lt;br /&gt;
                      0 0 1 4 \]  &lt;br /&gt;
MD++ latticeconst = \[$latt0 0.0 [expr $latt0*${c_over_a}] \]&lt;br /&gt;
MD++ makecrystal &lt;br /&gt;
MD++ element0 = Mg atommass = 24.305 # g/mol&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ {&lt;br /&gt;
atomradius = [1.3] #bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor0 = yellow atomcolor1 = &amp;quot;light grey&amp;quot;&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
}&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Zinc Sulphide (ZnS)  ==&lt;br /&gt;
ZnS is a two component material and has two lattice structures (zinc-blende and Wurtzite). Through the following example script, we will learn how to use MD++ to generate multi-component material in zinc-blende strucutre or Wurtzite structure.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/example06a-ZnS.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;example06a-ZnS.script&#039;&#039;&#039; ﬁle, which will creat a Zinc-blende structure of ZnS.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Zincblende structure of ZnS&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = zinc-blende&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = 5.42           #(A) &lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [1.3 1] #bondradius = 0.3 bondlength = 2.8285&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similarly, you can create a Wurtzite structure by the following script, &#039;&#039;&#039;example06b-ZnS.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Wurtzite structure of ZnS&lt;br /&gt;
# (screw dislocation motion under fixed boundary)&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = wurtzite&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = [3.82 0 6.24]  #(in Angstrom)&lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [0.8 1] bondradius = 0.3 bondlength = 3.25&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.5 ZnS structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:ZnS_zincblende.gif|(a) Zinc-blende structure of ZnS&lt;br /&gt;
Image:ZnS_wurtzite.gif|(c) Wurtzite structure of ZnS&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5935</id>
		<title>M02 Making a Perfect Crystal</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5935"/>
		<updated>2013-09-27T04:52:47Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Hexagonal-close-packed (HCP) structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 02 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Making a Perfect Crystal&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 25 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many solid materials have a periodic crystal structure.&amp;lt;ref&amp;gt;Glass is a counter-example, which is noncrystalline. We call it an amorphous material. Sometimes people consider it as supercooled liquid instead of a true solid, because, like a liquid, glass can flow under shear stress, although at very slow rate.&amp;lt;/ref&amp;gt; &lt;br /&gt;
For example, copper and aluminum have the face-centered-cubic (FCC) structure, while molybdenum and tungsten have the body-centered-cubic (BCC) structure under ambient conditions. The periodic arrangement of atoms simplifies the process of setting up&lt;br /&gt;
an atomistic simulation, because we can use a periodic array of atoms as the&lt;br /&gt;
initial condition. Thus, building up a crystal structure is often the first step in&lt;br /&gt;
the atomistic simulation of solids. In this manual, we will learn how to build several&lt;br /&gt;
crystal structures in MD++ with the example scripts.&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Face-centered-cubic crystal ==&lt;br /&gt;
First, let&#039;s make a perfect FCC aluminum crystal. The script file &#039;&#039;&#039;al.script&#039;&#039;&#039;,&lt;br /&gt;
together with other script files discussed in this manual, can be found in the&lt;br /&gt;
directory &#039;&#039;&#039;MD++/scripts/ME346&#039;&#039;&#039;. To run this script file, type&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/Codes/MD++&lt;br /&gt;
 $ bin/md_gpp scripts/ME346/al.script&lt;br /&gt;
&lt;br /&gt;
The executable file, &#039;&#039;&#039;md_gpp&#039;&#039;&#039; does not contain any potential model, but can be&lt;br /&gt;
used to visualize the atomic structure, as mentioned in the [[M01 Introduction to MD++|Manual 01]].&amp;lt;ref&amp;gt;You can compile the executable &#039;&#039;&#039;alglue_gpp&#039;&#039;&#039;, which is a glue potential model for&lt;br /&gt;
aluminum by typing &lt;br /&gt;
 $ make alglue build=R.&amp;lt;/ref&amp;gt; &lt;br /&gt;
Here is the content of the &#039;&#039;&#039;al.script&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/al-example     # To specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.05           # lattice constant for Al (unit: Angstrom)&lt;br /&gt;
latticesize = [ 1 0 0 1       # c1 = 1*[1 0 0] periodicity vec. in x&lt;br /&gt;
                0 1 0 1       # c2 = 1*[0 1 0] periodicity vec. in y&lt;br /&gt;
                0 0 1 1]      # c3 = 1*[0 0 1] periodicity vec. in z&lt;br /&gt;
makecrystal&lt;br /&gt;
&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1.0 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Visualization of FCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:fcc.jpg|(a) Conventional image of FCC unit cell&lt;br /&gt;
Image:al1X1X1.jpg|(b) FCC unit cell in MD++. One corner atom and three face-centered atoms per cell&lt;br /&gt;
Image:al3X3X3.jpg|(c) FCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FCC, as well as HCP (Hexagonal Close Packed), is a close-packed crystal structure. In Fig.1(a), you can see the conventional image of  FCC unit cell structure, where there is an atom at every corner and every face center of the cube. Since each corner atom is shared by 8 adjacent cubes and each face-centered atom is shared by 2 cubes, the total number of atoms per unit cell will be &amp;lt;math&amp;gt;8 \times  1/8 + 6 \times 1/2 = 4&amp;lt;/math&amp;gt;. In MD++, four atoms will be plotted per unti cell as shown in Fig.1(b), which is exactly what you see when you run &#039;&#039;&#039;al.script&#039;&#039;&#039;. Now imagine that the unit cell is replicated periodically in all 3 directions to fill the entire space. This would create an infinitely large crystal. We can create a larger crystal by modifying the &#039;&#039;&#039;latticesize&#039;&#039;&#039; variable, &#039;&#039;e.g.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 latticesize = [ 1 0 0 3&lt;br /&gt;
                 0 1 0 3&lt;br /&gt;
                 0 0 1 3]&lt;br /&gt;
&lt;br /&gt;
This creates a crystal with &amp;lt;math&amp;gt;3 \times 3 \times 3 = 27&amp;lt;/math&amp;gt; unit cells as shown in the Fig.1(c). The &#039;&#039;&#039;plot&#039;&#039;&#039; section of this script file will be explained in Manual 06.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 1&#039;&#039; Make a perfect crystal of copper (Cu) of 4 X 4 X 4 unit&lt;br /&gt;
cells. Cu has an FCC crystal structure and its equilibrium lattice constant&lt;br /&gt;
is &amp;lt;math&amp;gt;a = &amp;lt;/math&amp;gt;3.6030 &amp;amp;Aring;. You can use &#039;&#039;&#039;md_gpp&#039;&#039;&#039; as the executable file&amp;lt;ref&amp;gt;For MD simulations of Cu or Al, the fourth column of latticesize should not be smaller than 4 due to the relatively large cut-off radius in their potential models (&#039;&#039;&#039;eam&#039;&#039;&#039; or &#039;&#039;&#039;alglue&#039;&#039;&#039;).&amp;lt;/ref&amp;gt; if you only want to visualize the structure. Use &#039;&#039;&#039;eam_gpp&#039;&#039;&#039; if you would like to do some computation using the potential model. (For example, the &#039;&#039;&#039;eval&#039;&#039;&#039; command computes the total potential energy of the structure.) For the latter case, you need to insert the following two lines into your script file after &#039;&#039;&#039;dirname&#039;&#039;&#039;.&lt;br /&gt;
 &lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/EAMDATA/eamdata.Cu&lt;br /&gt;
 eamgrid = 5000 readeam&lt;br /&gt;
&lt;br /&gt;
This reads the data needed by the EAM potential model of Cu.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 2&#039;&#039; Make a perfect crystal of argon (Ar) of 4 X 4 X 4 unit cells.&lt;br /&gt;
Ar is inert gas at room temperature but its solid state is face-centered-cubic crystal below its melting temperature &amp;lt;math&amp;gt;T_m = &amp;lt;/math&amp;gt;83.81K. Ar can be simulated&lt;br /&gt;
by the Leonard-Jones potential model or the executable &#039;&#039;&#039;lj_gpp&#039;&#039;&#039;. Modify &#039;&#039;&#039;scripts/ME346/ar.script&#039;&#039;&#039; and run it by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/lj_gpp scripts/ME346/ar.script&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Body-centered-cubic crystal ==&lt;br /&gt;
The BCC structure has an atom at every corner and body-center of each cube&lt;br /&gt;
(unit cell), as shown in Fig.2(a). Molybdenum (Mo) is one example of BCC materials.&lt;br /&gt;
Run &#039;&#039;&#039;mo.script&#039;&#039;&#039; file by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/ME346/mo.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;mo.script&#039;&#039;&#039; file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472         # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3 ]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = orange highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Visualization of BCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Bcc.jpg|(a) Conventional image of BCC unit cell&lt;br /&gt;
Image:mo1X1X1.jpg|(b) BCC unit cell in MD++. One corner atom and one body-centered atom per cell&lt;br /&gt;
Image:mo3X3X3.jpg|(c) BCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Fig.2(c), the simulation box (&#039;&#039;i.e.&#039;&#039; supercell) is defined by three periodicity&lt;br /&gt;
vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = 3[100], \mathbf{c}_2 = 3[010], \mathbf{c}_3 = 3[001]. &amp;lt;/math&amp;gt;&lt;br /&gt;
The command &#039;&#039;&#039;makecrystal&#039;&#039;&#039; generates the perfect crystal of molybdenum based&lt;br /&gt;
on the given variables, &#039;&#039;&#039;crystalstructure&#039;&#039;&#039;&amp;lt;ref&amp;gt;Other possible values for crystalstructure are “simple-cubic”, “face-centered-cubic”,“L1_2”, “L1_0”, “diamond-cubic”, “zinc-blende”, etc. For a complete list, please read&lt;br /&gt;
&#039;&#039;&#039;src/lattice.h&#039;&#039;&#039;.&amp;lt;/ref&amp;gt; , &#039;&#039;&#039;latticeconst&#039;&#039;&#039;, and &#039;&#039;&#039;latticesize&#039;&#039;&#039;. &lt;br /&gt;
The configuration will be saved as &#039;&#039;&#039;perf.cn&#039;&#039;&#039; in the directory of &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; by the command &#039;&#039;&#039;writecn&#039;&#039;&#039;. The configuration file contains the number of atoms and the position of all the atoms in terms of scaled coordinates followed by a 3 X 3 matrix, &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;, whose columns are the three periodicity vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;. The real coordinates of an atom, &amp;lt;math&amp;gt;\mathbf{r} = (x, y, z)^T&amp;lt;/math&amp;gt; is related to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s} = (s_x, s_y, s_z)^T&amp;lt;/math&amp;gt; through matrix multiplication&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r} = a\mathbf{H}\cdot \mathbf{s} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is the lattice constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 3&#039;&#039; Make a perfect crystal of tantalum (Ta) with repeat vectors &amp;lt;math&amp;gt;\mathbf{c}_1 = 3[1 1 0], \mathbf{c}_2 = 3[1 \bar{1} 0], \mathbf{c}_3 = 4[0 0 1]&amp;lt;/math&amp;gt;. &lt;br /&gt;
Ta has a BCC lattice structure with an equilibrium lattice constant &amp;lt;math&amp;gt;a =&amp;lt;/math&amp;gt; 3.3058 &amp;amp;Aring;. &lt;br /&gt;
Read the FS potential file for Ta by inserting the following line in the script.&lt;br /&gt;
&lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/ta_pot readpot&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diamond-cubic crystal ==&lt;br /&gt;
Silicon (Si) has diamond-cubic structure, which can be regarded as two FCC structures oﬀset by [1 1 1]/4. You can run the example script &#039;&#039;&#039;si.script&#039;&#039;&#039; by typing&lt;br /&gt;
&lt;br /&gt;
  $ bin/sw_gpp scripts/ME346/si.script&lt;br /&gt;
&lt;br /&gt;
where the executable &#039;&#039;&#039;sw_gpp&#039;&#039;&#039; contains the SW potential model for Si. The&lt;br /&gt;
visualization window will look like Fig.3(b). Here is the content of the &#039;&#039;&#039;si.script&#039;&#039;&#039; ﬁle.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si-example&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.43095            # (in Angstrom) for Si&lt;br /&gt;
latticesize = [ 1 0 0 2&lt;br /&gt;
                0 1 0 2&lt;br /&gt;
                0 0 1 2 ]&lt;br /&gt;
makecrystal writecn&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = 0.67 bondradius = 0.3 bondlength = 2.8285 &lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 Visualization of DC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Dc_unitcell.jpg|(a) DC unit cell in MD++. 8 atoms per cell&lt;br /&gt;
Image:Dc_2x2x2cell.jpg|(c) DC of 2X2X2 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hexagonal-close-packed (HCP) structure ==&lt;br /&gt;
&lt;br /&gt;
Conventionally, an HCP structure has repeated hexagonal or parallelogram cells (red line in Fig. 4(a)), neither of which satisfies periodic boundary conditions imposed along three orthogonal axes (&#039;&#039;x&#039;&#039;, &#039;&#039;y&#039;&#039;, and &#039;&#039;z&#039;&#039;). So, in MD++ we use a rectangular unit cell (blue line in Fig.4(a)), which contains 4 atoms as shown in Fig.4 (b). The scaled coordinates of these 4 atoms are (0,0,0), (0.5, 0.5, 0), (0.5, 1/6, 0.5) and (0, 2/3, 0.5) in the rectangular unit cell. &lt;br /&gt;
&lt;br /&gt;
The script &#039;&#039;&#039;hcp-mg.tcl&#039;&#039;&#039;, shown below, creates HCP structure. Note that MD++ variable &#039;&#039;&#039;latticeconst&#039;&#039;&#039; now takes three values. The 1st one is the lattice constant &#039;&#039;a&#039;&#039;, and the last one is the lattice constant &#039;&#039;c&#039;&#039;. The 2nd argument can be ignored. For HCP, c is mostly a * sqrt(8/3) = 1.633 a. You can assign the c/a ratio somewhat different from 1.633.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/hcp-mg.tcl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 HCP structure&amp;quot; widths=&amp;quot;400px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Hcp2.gif|(a) HCP conventional unit cell (red) and HCP rectangular unit cell (blue) (b) HCP unit cell in MD++. 4 atoms per cell&lt;br /&gt;
Image:Hcp6X4X4.gif|(c) HCP structure of 6X4X4 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# HCP structure&lt;br /&gt;
MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = runs/HCP&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
set latt0 3.184&lt;br /&gt;
set c_over_a 1.633&lt;br /&gt;
MD++ latticestructure = hexagonal-ortho&lt;br /&gt;
# x-axis: [1 0 0] = [-1 2 -1 0]/3, &lt;br /&gt;
# y-axis: [0 1 0] = [1 0 -1 0], &lt;br /&gt;
# z-axis: [0 0 1] = [0 0 0 1] c-axis&lt;br /&gt;
MD++ latticesize = \[ 1 0 0 6 \&lt;br /&gt;
                      0 1 0 4 \&lt;br /&gt;
                      0 0 1 4 \]  &lt;br /&gt;
MD++ latticeconst = \[$latt0 0.0 [expr $latt0*${c_over_a}] \]&lt;br /&gt;
MD++ makecrystal &lt;br /&gt;
MD++ element0 = Mg atommass = 24.305 # g/mol&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ {&lt;br /&gt;
atomradius = [1.3] #bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor0 = yellow atomcolor1 = &amp;quot;light grey&amp;quot;&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
}&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Zinc Sulphide (ZnS)  ==&lt;br /&gt;
ZnS is a two component material and has two lattice structures (zinc-blende and Wurtzite). Through the following example script, we will learn how to use MD++ to generate multi-component material in zinc-blende strucutre or Wurtzite structure.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/example06a-ZnS.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;example06a-ZnS.script&#039;&#039;&#039; ﬁle, which will creat a Zinc-blende structure of ZnS.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Zincblende structure of ZnS&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = zinc-blende&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = 5.42           #(A) &lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [1.3 1] #bondradius = 0.3 bondlength = 2.8285&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similarly, you can create a Wurtzite structure by the following script, &#039;&#039;&#039;example06b-ZnS.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Wurtzite structure of ZnS&lt;br /&gt;
# (screw dislocation motion under fixed boundary)&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = wurtzite&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = [3.82 0 6.24]  #(in Angstrom)&lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [0.8 1] bondradius = 0.3 bondlength = 3.25&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.5 ZnS structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:ZnS_zincblende.gif|(a) Zinc-blende structure of ZnS&lt;br /&gt;
Image:ZnS_wurtzite.gif|(c) Wurtzite structure of ZnS&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5931</id>
		<title>M02 Making a Perfect Crystal</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5931"/>
		<updated>2013-08-06T10:57:28Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Hexagonal-close-packed (HCP) structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 02 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Making a Perfect Crystal&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 25 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many solid materials have a periodic crystal structure.&amp;lt;ref&amp;gt;Glass is a counter-example, which is noncrystalline. We call it an amorphous material. Sometimes people consider it as supercooled liquid instead of a true solid, because, like a liquid, glass can flow under shear stress, although at very slow rate.&amp;lt;/ref&amp;gt; &lt;br /&gt;
For example, copper and aluminum have the face-centered-cubic (FCC) structure, while molybdenum and tungsten have the body-centered-cubic (BCC) structure under ambient conditions. The periodic arrangement of atoms simplifies the process of setting up&lt;br /&gt;
an atomistic simulation, because we can use a periodic array of atoms as the&lt;br /&gt;
initial condition. Thus, building up a crystal structure is often the first step in&lt;br /&gt;
the atomistic simulation of solids. In this manual, we will learn how to build several&lt;br /&gt;
crystal structures in MD++ with the example scripts.&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Face-centered-cubic crystal ==&lt;br /&gt;
First, let&#039;s make a perfect FCC aluminum crystal. The script file &#039;&#039;&#039;al.script&#039;&#039;&#039;,&lt;br /&gt;
together with other script files discussed in this manual, can be found in the&lt;br /&gt;
directory &#039;&#039;&#039;MD++/scripts/ME346&#039;&#039;&#039;. To run this script file, type&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/Codes/MD++&lt;br /&gt;
 $ bin/md_gpp scripts/ME346/al.script&lt;br /&gt;
&lt;br /&gt;
The executable file, &#039;&#039;&#039;md_gpp&#039;&#039;&#039; does not contain any potential model, but can be&lt;br /&gt;
used to visualize the atomic structure, as mentioned in the [[M01 Introduction to MD++|Manual 01]].&amp;lt;ref&amp;gt;You can compile the executable &#039;&#039;&#039;alglue_gpp&#039;&#039;&#039;, which is a glue potential model for&lt;br /&gt;
aluminum by typing &lt;br /&gt;
 $ make alglue build=R.&amp;lt;/ref&amp;gt; &lt;br /&gt;
Here is the content of the &#039;&#039;&#039;al.script&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/al-example     # To specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.05           # lattice constant for Al (unit: Angstrom)&lt;br /&gt;
latticesize = [ 1 0 0 1       # c1 = 1*[1 0 0] periodicity vec. in x&lt;br /&gt;
                0 1 0 1       # c2 = 1*[0 1 0] periodicity vec. in y&lt;br /&gt;
                0 0 1 1]      # c3 = 1*[0 0 1] periodicity vec. in z&lt;br /&gt;
makecrystal&lt;br /&gt;
&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1.0 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Visualization of FCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:fcc.jpg|(a) Conventional image of FCC unit cell&lt;br /&gt;
Image:al1X1X1.jpg|(b) FCC unit cell in MD++. One corner atom and three face-centered atoms per cell&lt;br /&gt;
Image:al3X3X3.jpg|(c) FCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FCC, as well as HCP (Hexagonal Close Packed), is a close-packed crystal structure. In Fig.1(a), you can see the conventional image of  FCC unit cell structure, where there is an atom at every corner and every face center of the cube. Since each corner atom is shared by 8 adjacent cubes and each face-centered atom is shared by 2 cubes, the total number of atoms per unit cell will be &amp;lt;math&amp;gt;8 \times  1/8 + 6 \times 1/2 = 4&amp;lt;/math&amp;gt;. In MD++, four atoms will be plotted per unti cell as shown in Fig.1(b), which is exactly what you see when you run &#039;&#039;&#039;al.script&#039;&#039;&#039;. Now imagine that the unit cell is replicated periodically in all 3 directions to fill the entire space. This would create an infinitely large crystal. We can create a larger crystal by modifying the &#039;&#039;&#039;latticesize&#039;&#039;&#039; variable, &#039;&#039;e.g.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 latticesize = [ 1 0 0 3&lt;br /&gt;
                 0 1 0 3&lt;br /&gt;
                 0 0 1 3]&lt;br /&gt;
&lt;br /&gt;
This creates a crystal with &amp;lt;math&amp;gt;3 \times 3 \times 3 = 27&amp;lt;/math&amp;gt; unit cells as shown in the Fig.1(c). The &#039;&#039;&#039;plot&#039;&#039;&#039; section of this script file will be explained in Manual 06.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 1&#039;&#039; Make a perfect crystal of copper (Cu) of 4 X 4 X 4 unit&lt;br /&gt;
cells. Cu has an FCC crystal structure and its equilibrium lattice constant&lt;br /&gt;
is &amp;lt;math&amp;gt;a = &amp;lt;/math&amp;gt;3.6030 &amp;amp;Aring;. You can use &#039;&#039;&#039;md_gpp&#039;&#039;&#039; as the executable file&amp;lt;ref&amp;gt;For MD simulations of Cu or Al, the fourth column of latticesize should not be smaller than 4 due to the relatively large cut-off radius in their potential models (&#039;&#039;&#039;eam&#039;&#039;&#039; or &#039;&#039;&#039;alglue&#039;&#039;&#039;).&amp;lt;/ref&amp;gt; if you only want to visualize the structure. Use &#039;&#039;&#039;eam_gpp&#039;&#039;&#039; if you would like to do some computation using the potential model. (For example, the &#039;&#039;&#039;eval&#039;&#039;&#039; command computes the total potential energy of the structure.) For the latter case, you need to insert the following two lines into your script file after &#039;&#039;&#039;dirname&#039;&#039;&#039;.&lt;br /&gt;
 &lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/EAMDATA/eamdata.Cu&lt;br /&gt;
 eamgrid = 5000 readeam&lt;br /&gt;
&lt;br /&gt;
This reads the data needed by the EAM potential model of Cu.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 2&#039;&#039; Make a perfect crystal of argon (Ar) of 4 X 4 X 4 unit cells.&lt;br /&gt;
Ar is inert gas at room temperature but its solid state is face-centered-cubic crystal below its melting temperature &amp;lt;math&amp;gt;T_m = &amp;lt;/math&amp;gt;83.81K. Ar can be simulated&lt;br /&gt;
by the Leonard-Jones potential model or the executable &#039;&#039;&#039;lj_gpp&#039;&#039;&#039;. Modify &#039;&#039;&#039;scripts/ME346/ar.script&#039;&#039;&#039; and run it by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/lj_gpp scripts/ME346/ar.script&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Body-centered-cubic crystal ==&lt;br /&gt;
The BCC structure has an atom at every corner and body-center of each cube&lt;br /&gt;
(unit cell), as shown in Fig.2(a). Molybdenum (Mo) is one example of BCC materials.&lt;br /&gt;
Run &#039;&#039;&#039;mo.script&#039;&#039;&#039; file by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/ME346/mo.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;mo.script&#039;&#039;&#039; file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472         # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3 ]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = orange highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Visualization of BCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Bcc.jpg|(a) Conventional image of BCC unit cell&lt;br /&gt;
Image:mo1X1X1.jpg|(b) BCC unit cell in MD++. One corner atom and one body-centered atom per cell&lt;br /&gt;
Image:mo3X3X3.jpg|(c) BCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Fig.2(c), the simulation box (&#039;&#039;i.e.&#039;&#039; supercell) is defined by three periodicity&lt;br /&gt;
vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = 3[100], \mathbf{c}_2 = 3[010], \mathbf{c}_3 = 3[001]. &amp;lt;/math&amp;gt;&lt;br /&gt;
The command &#039;&#039;&#039;makecrystal&#039;&#039;&#039; generates the perfect crystal of molybdenum based&lt;br /&gt;
on the given variables, &#039;&#039;&#039;crystalstructure&#039;&#039;&#039;&amp;lt;ref&amp;gt;Other possible values for crystalstructure are “simple-cubic”, “face-centered-cubic”,“L1_2”, “L1_0”, “diamond-cubic”, “zinc-blende”, etc. For a complete list, please read&lt;br /&gt;
&#039;&#039;&#039;src/lattice.h&#039;&#039;&#039;.&amp;lt;/ref&amp;gt; , &#039;&#039;&#039;latticeconst&#039;&#039;&#039;, and &#039;&#039;&#039;latticesize&#039;&#039;&#039;. &lt;br /&gt;
The configuration will be saved as &#039;&#039;&#039;perf.cn&#039;&#039;&#039; in the directory of &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; by the command &#039;&#039;&#039;writecn&#039;&#039;&#039;. The configuration file contains the number of atoms and the position of all the atoms in terms of scaled coordinates followed by a 3 X 3 matrix, &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;, whose columns are the three periodicity vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;. The real coordinates of an atom, &amp;lt;math&amp;gt;\mathbf{r} = (x, y, z)^T&amp;lt;/math&amp;gt; is related to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s} = (s_x, s_y, s_z)^T&amp;lt;/math&amp;gt; through matrix multiplication&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r} = a\mathbf{H}\cdot \mathbf{s} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is the lattice constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 3&#039;&#039; Make a perfect crystal of tantalum (Ta) with repeat vectors &amp;lt;math&amp;gt;\mathbf{c}_1 = 3[1 1 0], \mathbf{c}_2 = 3[1 \bar{1} 0], \mathbf{c}_3 = 4[0 0 1]&amp;lt;/math&amp;gt;. &lt;br /&gt;
Ta has a BCC lattice structure with an equilibrium lattice constant &amp;lt;math&amp;gt;a =&amp;lt;/math&amp;gt; 3.3058 &amp;amp;Aring;. &lt;br /&gt;
Read the FS potential file for Ta by inserting the following line in the script.&lt;br /&gt;
&lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/ta_pot readpot&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diamond-cubic crystal ==&lt;br /&gt;
Silicon (Si) has diamond-cubic structure, which can be regarded as two FCC structures oﬀset by [1 1 1]/4. You can run the example script &#039;&#039;&#039;si.script&#039;&#039;&#039; by typing&lt;br /&gt;
&lt;br /&gt;
  $ bin/sw_gpp scripts/ME346/si.script&lt;br /&gt;
&lt;br /&gt;
where the executable &#039;&#039;&#039;sw_gpp&#039;&#039;&#039; contains the SW potential model for Si. The&lt;br /&gt;
visualization window will look like Fig.3(b). Here is the content of the &#039;&#039;&#039;si.script&#039;&#039;&#039; ﬁle.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si-example&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.43095            # (in Angstrom) for Si&lt;br /&gt;
latticesize = [ 1 0 0 2&lt;br /&gt;
                0 1 0 2&lt;br /&gt;
                0 0 1 2 ]&lt;br /&gt;
makecrystal writecn&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = 0.67 bondradius = 0.3 bondlength = 2.8285 &lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 Visualization of DC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Dc_unitcell.jpg|(a) DC unit cell in MD++. 8 atoms per cell&lt;br /&gt;
Image:Dc_2x2x2cell.jpg|(c) DC of 2X2X2 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hexagonal-close-packed (HCP) structure ==&lt;br /&gt;
&lt;br /&gt;
Conventionally, an HCP structure has repeated hexagonal or parallelogram cells (red line in Fig. 4(a)), neither of which satisfies periodic boundary conditions imposed along three orthogonal axes (&#039;&#039;x&#039;&#039;, &#039;&#039;y&#039;&#039;, and &#039;&#039;z&#039;&#039;). So, in MD++ we use a rectangular unit cell (blue line in Fig.4(a)), which contains 4 atoms as shown in Fig.4 (b). The scaled coordinates of these 4 atoms are (0,0,0), (0.5, 0.5, 0), (0.5, 1/6, 0.5) and (0, 2/3, 0.5) in the rectangular unit cell. &lt;br /&gt;
&lt;br /&gt;
The script &#039;&#039;&#039;hcp-mg.tcl&#039;&#039;&#039;, shown below, creates HCP structure. Note that MD++ variable &#039;&#039;&#039;latticeconst&#039;&#039;&#039; now takes three values. The 1st one is the lattice constant &#039;&#039;a&#039;&#039;, and the last one is the lattice constant &#039;&#039;c&#039;&#039;. The 2nd argument can be ignored. For HCP, c is mostly a * sqrt(8/3) = 1.633 a. You can assign the c/a ratio somewhat different from 1.633.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/hcp-mg.tcl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 HCP structure&amp;quot; widths=&amp;quot;400px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Hcp2.gif|(a) HCP conventional unit cell (red) and HCP rectangular unit cell (blue) (b) HCP unit cell in MD++. 4 atoms per cell&lt;br /&gt;
Image:Hcp6X4X4.gif|(c) HCP structure of 6X4X4 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Image:hcp2.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# HCP structure&lt;br /&gt;
MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = runs/HCP&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
set latt0 3.184&lt;br /&gt;
set c_over_a 1.633&lt;br /&gt;
MD++ latticestructure = hexagonal-ortho&lt;br /&gt;
# x-axis: [1 0 0] = [-1 2 -1 0]/3, &lt;br /&gt;
# y-axis: [0 1 0] = [1 0 -1 0], &lt;br /&gt;
# z-axis: [0 0 1] = [0 0 0 1] c-axis&lt;br /&gt;
MD++ latticesize = \[ 1 0 0 6 \&lt;br /&gt;
                      0 1 0 4 \&lt;br /&gt;
                      0 0 1 4 \]  &lt;br /&gt;
MD++ latticeconst = \[$latt0 0.0 [expr $latt0*${c_over_a}] \]&lt;br /&gt;
MD++ makecrystal &lt;br /&gt;
MD++ element0 = Mg atommass = 24.305 # g/mol&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ {&lt;br /&gt;
atomradius = [1.3] #bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor0 = yellow atomcolor1 = &amp;quot;light grey&amp;quot;&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
}&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Zinc Sulphide (ZnS)  ==&lt;br /&gt;
ZnS is a two component material and has two lattice structures (zinc-blende and Wurtzite). Through the following example script, we will learn how to use MD++ to generate multi-component material in zinc-blende strucutre or Wurtzite structure.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/example06a-ZnS.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;example06a-ZnS.script&#039;&#039;&#039; ﬁle, which will creat a Zinc-blende structure of ZnS.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Zincblende structure of ZnS&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = zinc-blende&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = 5.42           #(A) &lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [1.3 1] #bondradius = 0.3 bondlength = 2.8285&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similarly, you can create a Wurtzite structure by the following script, &#039;&#039;&#039;example06b-ZnS.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Wurtzite structure of ZnS&lt;br /&gt;
# (screw dislocation motion under fixed boundary)&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = wurtzite&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = [3.82 0 6.24]  #(in Angstrom)&lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [0.8 1] bondradius = 0.3 bondlength = 3.25&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.5 ZnS structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:ZnS_zincblende.gif|(a) Zinc-blende structure of ZnS&lt;br /&gt;
Image:ZnS_wurtzite.gif|(c) Wurtzite structure of ZnS&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=File:Hcp6X4X4.gif&amp;diff=5930</id>
		<title>File:Hcp6X4X4.gif</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=File:Hcp6X4X4.gif&amp;diff=5930"/>
		<updated>2013-08-06T10:55:27Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5922</id>
		<title>M02 Making a Perfect Crystal</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M02_Making_a_Perfect_Crystal&amp;diff=5922"/>
		<updated>2013-07-24T14:34:59Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 02 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Making a Perfect Crystal&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 25 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many solid materials have a periodic crystal structure.&amp;lt;ref&amp;gt;Glass is a counter-example, which is noncrystalline. We call it an amorphous material. Sometimes people consider it as supercooled liquid instead of a true solid, because, like a liquid, glass can flow under shear stress, although at very slow rate.&amp;lt;/ref&amp;gt; &lt;br /&gt;
For example, copper and aluminum have the face-centered-cubic (FCC) structure, while molybdenum and tungsten have the body-centered-cubic (BCC) structure under ambient conditions. The periodic arrangement of atoms simplifies the process of setting up&lt;br /&gt;
an atomistic simulation, because we can use a periodic array of atoms as the&lt;br /&gt;
initial condition. Thus, building up a crystal structure is often the first step in&lt;br /&gt;
the atomistic simulation of solids. In this manual, we will learn how to build several&lt;br /&gt;
crystal structures in MD++ with the example scripts.&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Face-centered-cubic crystal ==&lt;br /&gt;
First, let&#039;s make a perfect FCC aluminum crystal. The script file &#039;&#039;&#039;al.script&#039;&#039;&#039;,&lt;br /&gt;
together with other script files discussed in this manual, can be found in the&lt;br /&gt;
directory &#039;&#039;&#039;MD++/scripts/ME346&#039;&#039;&#039;. To run this script file, type&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/Codes/MD++&lt;br /&gt;
 $ bin/md_gpp scripts/ME346/al.script&lt;br /&gt;
&lt;br /&gt;
The executable file, &#039;&#039;&#039;md_gpp&#039;&#039;&#039; does not contain any potential model, but can be&lt;br /&gt;
used to visualize the atomic structure, as mentioned in the [[M01 Introduction to MD++|Manual 01]].&amp;lt;ref&amp;gt;You can compile the executable &#039;&#039;&#039;alglue_gpp&#039;&#039;&#039;, which is a glue potential model for&lt;br /&gt;
aluminum by typing &lt;br /&gt;
 $ make alglue build=R.&amp;lt;/ref&amp;gt; &lt;br /&gt;
Here is the content of the &#039;&#039;&#039;al.script&#039;&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/al-example     # To specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.05           # lattice constant for Al (unit: Angstrom)&lt;br /&gt;
latticesize = [ 1 0 0 1       # c1 = 1*[1 0 0] periodicity vec. in x&lt;br /&gt;
                0 1 0 1       # c2 = 1*[0 1 0] periodicity vec. in y&lt;br /&gt;
                0 0 1 1]      # c3 = 1*[0 0 1] periodicity vec. in z&lt;br /&gt;
makecrystal&lt;br /&gt;
&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1.0 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Visualization of FCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:fcc.jpg|(a) Conventional image of FCC unit cell&lt;br /&gt;
Image:al1X1X1.jpg|(b) FCC unit cell in MD++. One corner atom and three face-centered atoms per cell&lt;br /&gt;
Image:al3X3X3.jpg|(c) FCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
FCC, as well as HCP (Hexagonal Close Packed), is a close-packed crystal structure. In Fig.1(a), you can see the conventional image of  FCC unit cell structure, where there is an atom at every corner and every face center of the cube. Since each corner atom is shared by 8 adjacent cubes and each face-centered atom is shared by 2 cubes, the total number of atoms per unit cell will be &amp;lt;math&amp;gt;8 \times  1/8 + 6 \times 1/2 = 4&amp;lt;/math&amp;gt;. In MD++, four atoms will be plotted per unti cell as shown in Fig.1(b), which is exactly what you see when you run &#039;&#039;&#039;al.script&#039;&#039;&#039;. Now imagine that the unit cell is replicated periodically in all 3 directions to fill the entire space. This would create an infinitely large crystal. We can create a larger crystal by modifying the &#039;&#039;&#039;latticesize&#039;&#039;&#039; variable, &#039;&#039;e.g.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 latticesize = [ 1 0 0 3&lt;br /&gt;
                 0 1 0 3&lt;br /&gt;
                 0 0 1 3]&lt;br /&gt;
&lt;br /&gt;
This creates a crystal with &amp;lt;math&amp;gt;3 \times 3 \times 3 = 27&amp;lt;/math&amp;gt; unit cells as shown in the Fig.1(c). The &#039;&#039;&#039;plot&#039;&#039;&#039; section of this script file will be explained in Manual 06.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 1&#039;&#039; Make a perfect crystal of copper (Cu) of 4 X 4 X 4 unit&lt;br /&gt;
cells. Cu has an FCC crystal structure and its equilibrium lattice constant&lt;br /&gt;
is &amp;lt;math&amp;gt;a = &amp;lt;/math&amp;gt;3.6030 &amp;amp;Aring;. You can use &#039;&#039;&#039;md_gpp&#039;&#039;&#039; as the executable file&amp;lt;ref&amp;gt;For MD simulations of Cu or Al, the fourth column of latticesize should not be smaller than 4 due to the relatively large cut-off radius in their potential models (&#039;&#039;&#039;eam&#039;&#039;&#039; or &#039;&#039;&#039;alglue&#039;&#039;&#039;).&amp;lt;/ref&amp;gt; if you only want to visualize the structure. Use &#039;&#039;&#039;eam_gpp&#039;&#039;&#039; if you would like to do some computation using the potential model. (For example, the &#039;&#039;&#039;eval&#039;&#039;&#039; command computes the total potential energy of the structure.) For the latter case, you need to insert the following two lines into your script file after &#039;&#039;&#039;dirname&#039;&#039;&#039;.&lt;br /&gt;
 &lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/EAMDATA/eamdata.Cu&lt;br /&gt;
 eamgrid = 5000 readeam&lt;br /&gt;
&lt;br /&gt;
This reads the data needed by the EAM potential model of Cu.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 2&#039;&#039; Make a perfect crystal of argon (Ar) of 4 X 4 X 4 unit cells.&lt;br /&gt;
Ar is inert gas at room temperature but its solid state is face-centered-cubic crystal below its melting temperature &amp;lt;math&amp;gt;T_m = &amp;lt;/math&amp;gt;83.81K. Ar can be simulated&lt;br /&gt;
by the Leonard-Jones potential model or the executable &#039;&#039;&#039;lj_gpp&#039;&#039;&#039;. Modify &#039;&#039;&#039;scripts/ME346/ar.script&#039;&#039;&#039; and run it by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/lj_gpp scripts/ME346/ar.script&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Body-centered-cubic crystal ==&lt;br /&gt;
The BCC structure has an atom at every corner and body-center of each cube&lt;br /&gt;
(unit cell), as shown in Fig.2(a). Molybdenum (Mo) is one example of BCC materials.&lt;br /&gt;
Run &#039;&#039;&#039;mo.script&#039;&#039;&#039; file by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/ME346/mo.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;mo.script&#039;&#039;&#039; file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472         # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3 ]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = orange highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600 win_height = 600&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Visualization of BCC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Bcc.jpg|(a) Conventional image of BCC unit cell&lt;br /&gt;
Image:mo1X1X1.jpg|(b) BCC unit cell in MD++. One corner atom and one body-centered atom per cell&lt;br /&gt;
Image:mo3X3X3.jpg|(c) BCC of 3X3X3 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Fig.2(c), the simulation box (&#039;&#039;i.e.&#039;&#039; supercell) is defined by three periodicity&lt;br /&gt;
vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;math&amp;gt;\mathbf{c}_1 = 3[100], \mathbf{c}_2 = 3[010], \mathbf{c}_3 = 3[001]. &amp;lt;/math&amp;gt;&lt;br /&gt;
The command &#039;&#039;&#039;makecrystal&#039;&#039;&#039; generates the perfect crystal of molybdenum based&lt;br /&gt;
on the given variables, &#039;&#039;&#039;crystalstructure&#039;&#039;&#039;&amp;lt;ref&amp;gt;Other possible values for crystalstructure are “simple-cubic”, “face-centered-cubic”,“L1_2”, “L1_0”, “diamond-cubic”, “zinc-blende”, etc. For a complete list, please read&lt;br /&gt;
&#039;&#039;&#039;src/lattice.h&#039;&#039;&#039;.&amp;lt;/ref&amp;gt; , &#039;&#039;&#039;latticeconst&#039;&#039;&#039;, and &#039;&#039;&#039;latticesize&#039;&#039;&#039;. &lt;br /&gt;
The configuration will be saved as &#039;&#039;&#039;perf.cn&#039;&#039;&#039; in the directory of &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; by the command &#039;&#039;&#039;writecn&#039;&#039;&#039;. The configuration file contains the number of atoms and the position of all the atoms in terms of scaled coordinates followed by a 3 X 3 matrix, &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;, whose columns are the three periodicity vectors, &amp;lt;math&amp;gt;\mathbf{c}_1&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{c}_2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{c}_3&amp;lt;/math&amp;gt;. The real coordinates of an atom, &amp;lt;math&amp;gt;\mathbf{r} = (x, y, z)^T&amp;lt;/math&amp;gt; is related to the scaled coordinates &amp;lt;math&amp;gt;\mathbf{s} = (s_x, s_y, s_z)^T&amp;lt;/math&amp;gt; through matrix multiplication&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r} = a\mathbf{H}\cdot \mathbf{s} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;a&amp;lt;/math&amp;gt; is the lattice constant.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Ex. 3&#039;&#039; Make a perfect crystal of tantalum (Ta) with repeat vectors &amp;lt;math&amp;gt;\mathbf{c}_1 = 3[1 1 0], \mathbf{c}_2 = 3[1 \bar{1} 0], \mathbf{c}_3 = 4[0 0 1]&amp;lt;/math&amp;gt;. &lt;br /&gt;
Ta has a BCC lattice structure with an equilibrium lattice constant &amp;lt;math&amp;gt;a =&amp;lt;/math&amp;gt; 3.3058 &amp;amp;Aring;. &lt;br /&gt;
Read the FS potential file for Ta by inserting the following line in the script.&lt;br /&gt;
&lt;br /&gt;
 potfile = ~/Codes/MD++/potentials/ta_pot readpot&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diamond-cubic crystal ==&lt;br /&gt;
Silicon (Si) has diamond-cubic structure, which can be regarded as two FCC structures oﬀset by [1 1 1]/4. You can run the example script &#039;&#039;&#039;si.script&#039;&#039;&#039; by typing&lt;br /&gt;
&lt;br /&gt;
  $ bin/sw_gpp scripts/ME346/si.script&lt;br /&gt;
&lt;br /&gt;
where the executable &#039;&#039;&#039;sw_gpp&#039;&#039;&#039; contains the SW potential model for Si. The&lt;br /&gt;
visualization window will look like Fig.3(b). Here is the content of the &#039;&#039;&#039;si.script&#039;&#039;&#039; ﬁle.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si-example&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.43095            # (in Angstrom) for Si&lt;br /&gt;
latticesize = [ 1 0 0 2&lt;br /&gt;
                0 1 0 2&lt;br /&gt;
                0 0 1 2 ]&lt;br /&gt;
makecrystal writecn&lt;br /&gt;
&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = 0.67 bondradius = 0.3 bondlength = 2.8285 &lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 Visualization of DC structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Dc_unitcell.jpg|(a) DC unit cell in MD++. 8 atoms per cell&lt;br /&gt;
Image:Dc_2x2x2cell.jpg|(c) DC of 2X2X2 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Hexagonal-close-packed (HCP) structure ==&lt;br /&gt;
&lt;br /&gt;
Conventionally, an HCP structure has repeated hexagonal or parallelogram cells (red line in Fig. 4(a)), neither of which satisfies periodic boundary conditions imposed along three orthogonal axes (&#039;&#039;x&#039;&#039;, &#039;&#039;y&#039;&#039;, and &#039;&#039;z&#039;&#039;). So, in MD++ we use a rectangular unit cell (blue line in Fig.4(a)), which contains 4 atoms as shown in Fig.4 (b). The scaled coordinates of these 4 atoms are (0,0,0), (0.5, 0.5, 0), (0.5, 1/6, 0.5) and (0, 2/3, 0.5) in the rectangular unit cell. &lt;br /&gt;
&lt;br /&gt;
The script &#039;&#039;&#039;hcp-mg.tcl&#039;&#039;&#039;, shown below, creates HCP structure. Note that MD++ variable &#039;&#039;&#039;latticeconst&#039;&#039;&#039; now takes three values. The 1st one is the lattice constant &#039;&#039;a&#039;&#039;, and the last one is the lattice constant &#039;&#039;c&#039;&#039;. The 2nd argument can be ignored. For HCP, c is mostly a * sqrt(8/3) = 1.633 a. You can assign the c/a ratio somewhat different from 1.633.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/hcp-mg.tcl&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 HCP structure&amp;quot; widths=&amp;quot;400px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Hcp2.gif|(a) HCP conventional unit cell (red) and HCP rectangular unit cell (blue) (b) HCP unit cell in MD++. 4 atoms per cell&lt;br /&gt;
Image:Hcp6X4x4.gif|(c) HCP structure of 6X4X4 cells&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# HCP structure&lt;br /&gt;
MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = runs/HCP&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
set latt0 3.184&lt;br /&gt;
set c_over_a 1.633&lt;br /&gt;
MD++ latticestructure = hexagonal-ortho&lt;br /&gt;
# x-axis: [1 0 0] = [-1 2 -1 0]/3, &lt;br /&gt;
# y-axis: [0 1 0] = [1 0 -1 0], &lt;br /&gt;
# z-axis: [0 0 1] = [0 0 0 1] c-axis&lt;br /&gt;
MD++ latticesize = \[ 1 0 0 6 \&lt;br /&gt;
                      0 1 0 4 \&lt;br /&gt;
                      0 0 1 4 \]  &lt;br /&gt;
MD++ latticeconst = \[$latt0 0.0 [expr $latt0*${c_over_a}] \]&lt;br /&gt;
MD++ makecrystal &lt;br /&gt;
MD++ element0 = Mg atommass = 24.305 # g/mol&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ {&lt;br /&gt;
atomradius = [1.3] #bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor0 = yellow atomcolor1 = &amp;quot;light grey&amp;quot;&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
}&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Zinc Sulphide (ZnS)  ==&lt;br /&gt;
ZnS is a two component material and has two lattice structures (zinc-blende and Wurtzite). Through the following example script, we will learn how to use MD++ to generate multi-component material in zinc-blende strucutre or Wurtzite structure.&lt;br /&gt;
&lt;br /&gt;
  $ bin/md_gpp scripts/Examples/example06a-ZnS.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;example06a-ZnS.script&#039;&#039;&#039; ﬁle, which will creat a Zinc-blende structure of ZnS.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Zincblende structure of ZnS&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = zinc-blende&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = 5.42           #(A) &lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [1.3 1] #bondradius = 0.3 bondlength = 2.8285&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Similarly, you can create a Wurtzite structure by the following script, &#039;&#039;&#039;example06b-ZnS.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Wurtzite structure of ZnS&lt;br /&gt;
# (screw dislocation motion under fixed boundary)&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/ZnS-example&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
latticestructure = wurtzite&lt;br /&gt;
element0 = Zn element1 = S atommass = [65.409 32.065] # g/mol&lt;br /&gt;
latticeconst = [3.82 0 6.24]  #(in Angstrom)&lt;br /&gt;
latticesize = [ 1  0  0  2    #(x)&lt;br /&gt;
                0  1  0  2    #(y)&lt;br /&gt;
                0  0  1  2  ] #(z)&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Plot Configuration&lt;br /&gt;
#&lt;br /&gt;
atomradius = [0.8 1] bondradius = 0.3 bondlength = 3.25&lt;br /&gt;
atomcolor0 = &amp;quot;light grey&amp;quot; atomcolor1 = yellow&lt;br /&gt;
highlightcolor = purple  bondcolor = red backgroundcolor = gray&lt;br /&gt;
fixatomcolor = yellow&lt;br /&gt;
plot_atom_info = 1&lt;br /&gt;
plotfreq = 10&lt;br /&gt;
rotateangles = [ 0 0 0 1.2 ]&lt;br /&gt;
openwin alloccolors rotate saverot refreshnnlist eval plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.5 ZnS structure&amp;quot; widths=&amp;quot;200px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:ZnS_zincblende.gif|(a) Zinc-blende structure of ZnS&lt;br /&gt;
Image:ZnS_wurtzite.gif|(c) Wurtzite structure of ZnS&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M03_Equilibrium_Lattice_Constant_and_Bulk_Modulus&amp;diff=5921</id>
		<title>M03 Equilibrium Lattice Constant and Bulk Modulus</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M03_Equilibrium_Lattice_Constant_and_Bulk_Modulus&amp;diff=5921"/>
		<updated>2013-07-03T12:29:30Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 03 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Equilibrium Lattice Constant and Bulk Modulus&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 26 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading a Log File ==&lt;br /&gt;
In the example scripts of Manual 02, the command &#039;&#039;&#039;setnolog&#039;&#039;&#039; was activated and&lt;br /&gt;
the simulation results were printed out to the standard output, which is usually&lt;br /&gt;
your terminal screen. If you want to keep the record of this information, you&lt;br /&gt;
comment out the &#039;&#039;&#039;setnolog&#039;&#039;&#039; command by adding # before it. This&lt;br /&gt;
will create a log ﬁle &#039;&#039;&#039;A.log&#039;&#039;&#039; in the directory speciﬁed by &#039;&#039;&#039;dirname&#039;&#039;&#039;. For example,&lt;br /&gt;
if you run &#039;&#039;&#039;mo.script&#039;&#039;&#039; in Manual 02 with &#039;&#039;&#039;setnolog&#039;&#039;&#039; commented out,&lt;br /&gt;
then you will ﬁnd a &#039;&#039;&#039;A.log&#039;&#039;&#039; ﬁle in the &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; directory. To read&lt;br /&gt;
this ﬁle, type&lt;br /&gt;
&lt;br /&gt;
 $ more runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
In the log ﬁle, the line starting with &#039;&#039;&#039;ASSIGN&#039;&#039;&#039; shows that a variable &lt;br /&gt;
is assigned to the values as speciﬁed in the script ﬁle. The line with &#039;&#039;&#039;EXEC&#039;&#039;&#039;&lt;br /&gt;
shows the execution of certain command. After the &#039;&#039;&#039;eval&#039;&#039;&#039; command is executed,&lt;br /&gt;
properties such as number of atoms (&#039;&#039;&#039;NP&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), kinetic&lt;br /&gt;
energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), pressure (&#039;&#039;&#039;PRESSURE&#039;&#039;&#039;) and stress (&#039;&#039;&#039;Stress&#039;&#039;&#039;) are also printed.&lt;br /&gt;
Sometimes, the log ﬁle may be zipped as &#039;&#039;&#039;A.log.gz&#039;&#039;&#039;, in which case you can use&lt;br /&gt;
&lt;br /&gt;
 $ gzip -cd runs/mo-example/A.log.gz | more&lt;br /&gt;
&lt;br /&gt;
to see the content. To search for a speciﬁc property (&#039;&#039;e.g.&#039;&#039; &#039;&#039;&#039;EPOT&#039;&#039;&#039;) in the log&lt;br /&gt;
ﬁle, you may use&lt;br /&gt;
&lt;br /&gt;
 $ grep EPOT runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ gzip -cd runs/mo-example/A.log.gz | grep EPOT&lt;br /&gt;
&lt;br /&gt;
depending on whether the log ﬁle is zipped or not. In case you want to “grep” several&lt;br /&gt;
lines before and after your keyword (&#039;&#039;e.g.&#039;&#039; &#039;&#039;&#039;Stress&#039;&#039;&#039;), you can use&lt;br /&gt;
&lt;br /&gt;
 $ grep -3 Stress runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
This will show three lines above and below any line containing the keyword&lt;br /&gt;
“Stress”.&lt;br /&gt;
&lt;br /&gt;
Obviously, this way of extracting the values of MD++ variables is very tedious.  There is a better way to do this, which is to use the Tcl scripting language, as described in [[M08_MD++_Powered_by_Tcl_Language |Manual 08 (will be available soon)]].  The Tcl script for MD++ calculations described in this section is attaced at the end of this manual.&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Lattice Constant and Cohesive Energy ==&lt;br /&gt;
Under ambient condition silicon takes the diamond-cubic (DC) structure.&lt;br /&gt;
But in a computer simulation, we can create Si crystals with diﬀerent hypothet-&lt;br /&gt;
ical structures, such as face-centered-cubic (FCC), body-centered-cubic (BCC),&lt;br /&gt;
or simple-cubic (SC). A good potential model should be able to tell us that the&lt;br /&gt;
DC structure is the one with the lowest energy, hence it is the most favorable&lt;br /&gt;
structure for silicon. In this section, we will perform such calculations using&lt;br /&gt;
MD++.&lt;br /&gt;
&lt;br /&gt;
Let us deﬁne the lattice energy &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; and the number density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Phi = \frac{E_{pot}}{N} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \rho = \frac{N}{V} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;E_{pot}&amp;lt;/math&amp;gt; is the potential energy of the crystal, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is total number of atoms&lt;br /&gt;
in the simulation cell (corresponding to variable &#039;&#039;&#039;NP&#039;&#039;&#039; in MD++) and &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; is the&lt;br /&gt;
volume of the simulation cell. Run MD++ with following command line to use&lt;br /&gt;
the Stillinger-Weber (SW) potential model&amp;lt;ref name=&amp;quot;SW&amp;quot;&amp;gt;F. H. Stillinger and T. A. Weber, Phys. Rev. B &#039;&#039;&#039;31&#039;&#039;&#039;, 5262 (1985).&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;BH&amp;quot;&amp;gt;H. Balamane, T. Halicioglu, and W. A. Tiler, Phys. Rev. B &#039;&#039;&#039;46&#039;&#039;&#039;, 2250 (1992)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/ME346/si_polytype.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;si_polytype.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si_polytype&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.4309529817532409 #(A) for Si&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3]&lt;br /&gt;
makecrystal eval&lt;br /&gt;
latticeconst = 4.850 makecrystal eval&lt;br /&gt;
latticeconst = 4.950 makecrystal eval&lt;br /&gt;
latticeconst = 5.050 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
(many lines omitted here for brevity)&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 5.900 makecrystal eval&lt;br /&gt;
latticeconst = 6.000 makecrystal eval&lt;br /&gt;
latticeconst = 6.100 makecrystal eval&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.105 makecrystal eval&lt;br /&gt;
latticeconst = 4.110 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 4.205 makecrystal eval&lt;br /&gt;
latticeconst = 4.215 makecrystal eval&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.210 makecrystal eval&lt;br /&gt;
latticeconst = 3.220 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 3.320 makecrystal eval&lt;br /&gt;
latticeconst = 3.340 makecrystal eval&lt;br /&gt;
crystalstructure = simple-cubic&lt;br /&gt;
latticeconst = 2.550 makecrystal eval&lt;br /&gt;
latticeconst = 2.600 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 2.640 makecrystal eval&lt;br /&gt;
latticeconst = 2.650 makecrystal eval&lt;br /&gt;
quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the log ﬁle, you can ﬁnd number of atoms &#039;&#039;&#039;NP&#039;&#039;&#039; for the 3 X 3 X 3 DC cell&lt;br /&gt;
to be 216. This number can also be obtained by calculating &amp;lt;math&amp;gt;8 \times 3^3 = 216&amp;lt;/math&amp;gt;, since&lt;br /&gt;
there are eight atoms in the DC unit cell. For other crystal structures, the&lt;br /&gt;
number of atoms in the 3X3X3 cell is given in the following table.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1. Number of atoms in different crystal structures&lt;br /&gt;
| Crystal Structure || No. of atoms in the unit cell || Total No. of atoms&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| SC ||align=&amp;quot;center&amp;quot;|       1       ||align=&amp;quot;center&amp;quot;|       27&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| BCC ||align=&amp;quot;center&amp;quot;|      2       ||align=&amp;quot;center&amp;quot;|       54&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| FCC ||align=&amp;quot;center&amp;quot;|      4       ||align=&amp;quot;center&amp;quot;|      108&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| DC ||align=&amp;quot;center&amp;quot;|       8       ||align=&amp;quot;center&amp;quot;|      216&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The potential energy at each diﬀerent lattice constant can also be read from the&lt;br /&gt;
log ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ grep EPOT runs/si_polytype/A.log&lt;br /&gt;
&lt;br /&gt;
The volume of a simulation cell &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; can be obtained from the determinant of&lt;br /&gt;
the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;.&amp;lt;ref&amp;gt;The matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; deﬁnes size and shape of the simulation cell. &amp;lt;math&amp;gt;\mathbf{H} = [\mathbf{c}_1 \; \mathbf{c}_2 \; \mathbf{c}_3]&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\mathbf{c}_i&amp;lt;/math&amp;gt;&#039;s&lt;br /&gt;
are three periodicity vectors. In MD++, the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; becomes a diagonal matrix when the&lt;br /&gt;
supercell is a rectangular box (after reorienting the coordinate system).&lt;br /&gt;
&amp;lt;/ref&amp;gt; When &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is a diagonal matrix (the same is true for an upper&lt;br /&gt;
triangular matrix),&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; V = \det(\mathbf{H}) = \mathbf{H}(1,1) \mathbf{H}(2,2) \mathbf{H}(3,3) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
                      &lt;br /&gt;
the volume is the product of the entries in the main diagonal of &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;. The unit&lt;br /&gt;
of length in MD++ is &amp;amp;Aring; and the unit of volume is &amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt; . From these, we can&lt;br /&gt;
calculate the lattice energy &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; (in eV) of silicon as a function of the number&lt;br /&gt;
density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; (in 1/&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;), for diﬀerent crystal structures, as shown in Fig.1. &lt;br /&gt;
The structure with the lowest energy is DC. The equilibrium lattice&lt;br /&gt;
constant &amp;lt;math&amp;gt;a_0&amp;lt;/math&amp;gt; corresponds to the number density that gives the minimum of the&lt;br /&gt;
&amp;lt;math&amp;gt;\Phi(\rho)&amp;lt;/math&amp;gt; curve. The minimum of &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; is also called the &#039;&#039;&#039;cohesive energy&#039;&#039;&#039; &amp;lt;math&amp;gt;E_{coh}&amp;lt;/math&amp;gt; . &lt;br /&gt;
For DC silicon, &amp;lt;math&amp;gt;a_0=&amp;lt;/math&amp;gt; 5.431 &amp;amp;Aring; and &amp;lt;math&amp;gt;E_{coh}&amp;lt;/math&amp;gt; = −4.63 eV.&lt;br /&gt;
&lt;br /&gt;
[[Image:E_Si.jpg | frame | center | Fig.1 Lattice energy of Si in different structures. DC Si has the lowest energy well. The inset figure is the zoom-in image of the energy curve of DC Si.]]&lt;br /&gt;
[[Image:E_latt_Si.jpg | frame | center | Fig.2 Lattice energy vs lattice constant of DC Si. The curve is fitted to the quadratic polynomials. The equilibrium lattice constant is estimated to be 5.43095(&amp;amp;Aring;).]]&lt;br /&gt;
&lt;br /&gt;
== Bulk Modulus ==&lt;br /&gt;
The curvature of the &amp;lt;math&amp;gt;\Phi(\rho)&amp;lt;/math&amp;gt; curve near the minimum also tells us the bulk modulus&lt;br /&gt;
of the crystal. The bulk modulus &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is deﬁned as&amp;lt;ref&amp;gt;This is because &amp;lt;math&amp;gt;B =  -V \partial P / \partial V &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;P = - \partial \Phi / \partial V&amp;lt;/math&amp;gt;.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; B = V \frac{\partial^2 \Phi}{\partial V^2}_{V=V_0} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;V_0&amp;lt;/math&amp;gt; is the equilibrium atomic volume (corresponding to the energy minimum). &lt;br /&gt;
To compute the second derivative, plot &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; as a function of &amp;lt;math&amp;gt;V = 1/\rho&amp;lt;/math&amp;gt; and&lt;br /&gt;
ﬁt the &amp;lt;math&amp;gt;\Phi(V)&amp;lt;/math&amp;gt; curve by a quadratic function,&lt;br /&gt;
&#039;&#039;i.e.&#039;&#039; &amp;lt;math&amp;gt;\Phi = c_0 + c_1 V + c_2 V^2&amp;lt;/math&amp;gt;, as shown in Fig.3. This can be done by the Matlab&lt;br /&gt;
command &#039;&#039;&#039;polyfit&#039;&#039;&#039; and the result is c&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 0.016879 (in unit of eV/&amp;amp;Aring;&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt; ). &lt;br /&gt;
Then, with &amp;lt;math&amp;gt;V_0=&amp;lt;/math&amp;gt;20.023 (&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;), the bulk modulus becomes &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; B =  2\times 20.023 \mathrm{(\AA^3)}\times 0.016879 \mathrm{(eV/\AA^6)}\times 160.2 \mathrm{(GPa/(eV/\AA^3))}= 108.3 \mathrm{(GPa)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This result matches with an earlier report in the literature&amp;lt;ref name=&amp;quot;BH&amp;quot;/&amp;gt;. In the elasticity&lt;br /&gt;
theory&amp;lt;ref&amp;gt;J. P. Hirth and J. Lothe, &#039;&#039;Theory of Dislocations&#039;&#039;, (Wiley, New York, 1982)&amp;lt;/ref&amp;gt;, the bulk modulus &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is related to the other elastic constants through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;B = \lambda + \frac{2}{3}\mu &amp;lt;/math&amp;gt; || for isotropic material&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;B = \frac{1}{3}(C_{11} + 2C_{12})&amp;lt;/math&amp;gt; || for cubic material&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; are Lam&amp;amp;eacute;&#039;s constants and &amp;lt;math&amp;gt;C_{11}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_{12}&amp;lt;/math&amp;gt; are cubic elastic constants.&lt;br /&gt;
From this relation, the bulk modulus would be 98.4 GPa if we calculate it from the experimental value of &amp;lt;math&amp;gt;C_{11}=&amp;lt;/math&amp;gt; 165.7(GPa) and &amp;lt;math&amp;gt;C_{12}=&amp;lt;/math&amp;gt; 63.9(GPa) for silicon. &lt;br /&gt;
The discrepancy between the simulation and experimental results in the bulk modulus is partly&lt;br /&gt;
because the simulation results corresponds to the ideal case of T = 0 K,&lt;br /&gt;
while the experimental result is obtained at room temperature T = 300 K. The&lt;br /&gt;
elastic constants generally decreases with increasing temperature. The discrepancy &lt;br /&gt;
may also come from the fact that the potential model has empirical nature. Diﬀerent&lt;br /&gt;
parameterization of the potential model generally leads to diﬀerent predictions&lt;br /&gt;
of the elastic constants.&lt;br /&gt;
[[Image:E_vol_Si.jpg | frame | center | Fig.3 Lattice energy vs atomic volume of DC Si. The equilibrium atomic volume is estimated to be 20.023(&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;).]]&lt;br /&gt;
&lt;br /&gt;
== Tcl version of MD++ script == &lt;br /&gt;
For anyone that wants to reproduce my data, I uploaded the Tcl version of MD++ script &#039;&#039;&#039;si_polytype.tcl&#039;&#039;&#039; and the matlab script for the post-process of the simulation data.&lt;br /&gt;
&lt;br /&gt;
si_polytype.tcl&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } { MD++ {&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si_polytype&lt;br /&gt;
zipfiles = 1   # zip output files&lt;br /&gt;
NIC = 200 NNM = 200&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
proc makecrystal { } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
  MD++ element0 = Si&lt;br /&gt;
  MD++ latticesize = \[ 1 0 0 4 0 1 0 4 0 0 1 4 \]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
proc readnwrite { a fileID } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# read and write properties&lt;br /&gt;
for {set i -50} {$i &amp;lt;= 50} {incr i} {&lt;br /&gt;
  set latt [expr $a + $i/10000.0 ]&lt;br /&gt;
  MD++ latticeconst = $latt&lt;br /&gt;
  makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ eval    &lt;br /&gt;
  set EPOT     [MD++_Get EPOT]&lt;br /&gt;
  set N        [MD++_Get NP]&lt;br /&gt;
  set VOL      [MD++_Get OMEGA]&lt;br /&gt;
  set ELAT     [expr $EPOT / $N]&lt;br /&gt;
  set rho      [expr $N / double($VOL)]&lt;br /&gt;
  set AtomVol  [expr double($VOL) / $N]&lt;br /&gt;
&lt;br /&gt;
  puts $fileID &amp;quot;[format %18.12e $latt]\t \&lt;br /&gt;
                [format %18.12e $rho] \t \&lt;br /&gt;
                [format %18.12e $AtomVol]\t \&lt;br /&gt;
                [format %18.12e $EPOT]\t \&lt;br /&gt;
                [format %18.12e $ELAT]&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = diamond-cubic&lt;br /&gt;
set a 5.4309 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_DC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = face-centered-cubic&lt;br /&gt;
set a 4.1465 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_FCC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = body-centered-cubic&lt;br /&gt;
set a 3.245 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_BCC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = simple-cubic&lt;br /&gt;
set a 2.6120 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_SC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% Matlab script to plot the lattice energy of Si&lt;br /&gt;
% in different structures (DC, FCC, BCC and SC)&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
clf&lt;br /&gt;
&lt;br /&gt;
DC.data = load(&#039;EvsVol_DC.dat&#039;);&lt;br /&gt;
DC.latt = DC.data(:,1);&lt;br /&gt;
DC.rho  = DC.data(:,2);&lt;br /&gt;
DC.atomvol = DC.data(:,3);&lt;br /&gt;
DC.EPOT = DC.data(:,4);&lt;br /&gt;
DC.ELAT = DC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
FCC.data = load(&#039;EvsVol_FCC.dat&#039;);&lt;br /&gt;
FCC.latt = FCC.data(:,1);&lt;br /&gt;
FCC.rho  = FCC.data(:,2);&lt;br /&gt;
FCC.atomvol = FCC.data(:,3);&lt;br /&gt;
FCC.EPOT = FCC.data(:,4);&lt;br /&gt;
FCC.ELAT = FCC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
BCC.data = load(&#039;EvsVol_BCC.dat&#039;);&lt;br /&gt;
BCC.latt = BCC.data(:,1);&lt;br /&gt;
BCC.rho  = BCC.data(:,2);&lt;br /&gt;
BCC.atomvol = BCC.data(:,3);&lt;br /&gt;
BCC.EPOT = BCC.data(:,4);&lt;br /&gt;
BCC.ELAT = BCC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
SC.data = load(&#039;EvsVol_SC.dat&#039;);&lt;br /&gt;
SC.latt = SC.data(:,1);&lt;br /&gt;
SC.rho  = SC.data(:,2);&lt;br /&gt;
SC.atomvol = SC.data(:,3);&lt;br /&gt;
SC.EPOT = SC.data(:,4);&lt;br /&gt;
SC.ELAT = SC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs number density&lt;br /&gt;
% with inset figure&lt;br /&gt;
h1 = figure(1);&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.rho, DC.ELAT, &#039;.-&#039;,FCC.rho, FCC.ELAT, &#039;.-&#039;, ...&lt;br /&gt;
     BCC.rho, BCC.ELAT, &#039;.-&#039;,SC.rho, SC.ELAT, &#039;.-&#039;)&lt;br /&gt;
xlabel(&#039;Number Density, \rho=N/V (1/Angstrom^3)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
legend(&#039;DC&#039;,&#039;FCC&#039;,&#039;BCC&#039;,&#039;SC&#039;,2)&lt;br /&gt;
h2 = get(h1,&#039;CurrentAxes&#039;)&lt;br /&gt;
h3 = axes(&#039;pos&#039;,[.5 .2 .35 .35]);&lt;br /&gt;
&lt;br /&gt;
hold on; plot(DC.rho, DC.ELAT, &#039;.-&#039;)&lt;br /&gt;
yticklong = get(h3,&#039;YTick&#039;);&lt;br /&gt;
set(h3,&#039;xlim&#039;,[0.0498 0.0501],&#039;YTickLabel&#039;,yticklong,&#039;box&#039;,&#039;on&#039;);&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs lattice constant&lt;br /&gt;
% and find the equilibrium lattice constant, a_0&lt;br /&gt;
[P, S] = polyfit(DC.latt,DC.ELAT,2);&lt;br /&gt;
latt_X = linspace(5.4305,5.4315);&lt;br /&gt;
ELAT_Y = polyval(P,latt_X);&lt;br /&gt;
&lt;br /&gt;
figure(2)&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.latt, DC.ELAT, &#039;.-&#039;,latt_X,ELAT_Y,&#039;.-r&#039;)&lt;br /&gt;
xlabel(&#039;Lattice Constant, \it a \rm (Angstrom)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
yticklong = get(gca,&#039;YTick&#039;);&lt;br /&gt;
set(gca,&#039;YTickLabel&#039;,yticklong,&#039;Xlim&#039;,[5.426 5.436]);&lt;br /&gt;
legend(&#039;data&#039;,&#039;fitting curve&#039;)&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs atomic volume&lt;br /&gt;
% and find the bulk modulus, B&lt;br /&gt;
[P2, S2] = polyfit(DC.atomvol,DC.ELAT,2);&lt;br /&gt;
vol_X = linspace(20.01,20.04);&lt;br /&gt;
ELAT_Y2 = polyval(P2,vol_X);&lt;br /&gt;
&lt;br /&gt;
figure(3)&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.atomvol, DC.ELAT, &#039;.-&#039;,vol_X,ELAT_Y2,&#039;.-r&#039;)&lt;br /&gt;
xlabel(&#039;Atomic Volume, \it V \rm (Angstrom^3)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
yticklong = get(gca,&#039;YTick&#039;);&lt;br /&gt;
set(gca,&#039;YTickLabel&#039;,yticklong);&lt;br /&gt;
legend(&#039;data&#039;,&#039;fitting curve&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LAMMPS script == &lt;br /&gt;
For LAMMPS users, I present the LAMMPS script, &#039;&#039;&#039;in.equillatt_bulk_mod&#039;&#039;&#039; to carry out identical computation using the original SW potential model.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;in.equillatt_bulk_mod&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
log log.Si_test&lt;br /&gt;
# log file name&lt;br /&gt;
&lt;br /&gt;
shell rm out.data&lt;br /&gt;
variable latt0 equal 5.43&lt;br /&gt;
variable max_iter equal 101&lt;br /&gt;
variable shift_i  equal ceil(${max_iter}/2.0)&lt;br /&gt;
label loop &lt;br /&gt;
variable i loop ${max_iter}&lt;br /&gt;
  if &amp;quot;$i &amp;gt; ${max_iter}&amp;quot; then &amp;quot;jump in.equillatt_bulk_mod&amp;quot;&lt;br /&gt;
  variable j equal $i-${shift_i}&lt;br /&gt;
  variable latt equal ${latt0}+$j/10000.0&lt;br /&gt;
  &lt;br /&gt;
  clear&lt;br /&gt;
  units metal&lt;br /&gt;
  dimension 3&lt;br /&gt;
  atom_style atomic&lt;br /&gt;
  boundary p p p&lt;br /&gt;
  newton on&lt;br /&gt;
&lt;br /&gt;
  # number of cpus in x, y, and z dimensions&lt;br /&gt;
  processors 1 1 1&lt;br /&gt;
&lt;br /&gt;
  lattice diamond ${latt} orient x 1 0 0 orient y 0 1 0 orient z 0 0 1&lt;br /&gt;
  region  box block 0 4 0 4 0 4 units lattice&lt;br /&gt;
  create_box 1 box&lt;br /&gt;
  create_atoms 1 region box&lt;br /&gt;
&lt;br /&gt;
  mass 1 28.085&lt;br /&gt;
  &lt;br /&gt;
  # Stillinger and Weber, PRB 31, 5262 (1985)&lt;br /&gt;
  pair_style sw&lt;br /&gt;
  pair_coeff * * ../../potentials/Si.sw Si&lt;br /&gt;
&lt;br /&gt;
  neighbor 0.31 bin&lt;br /&gt;
  neigh_modify delay 0 every 1 check yes&lt;br /&gt;
&lt;br /&gt;
  thermo 10&lt;br /&gt;
  thermo_style custom step lx ly lz press pxx pyy pzz pe temp&lt;br /&gt;
  dump    1 all custom 10 Si_DC.dump id type xs ys zs&lt;br /&gt;
  dump_modify 1 format &amp;quot;%d %d %25.17E %25.17E %25.17E&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  variable EPOT equal pe&lt;br /&gt;
  variable NP equal atoms&lt;br /&gt;
  variable ELAT equal pe/${NP}&lt;br /&gt;
  variable VOL equal vol&lt;br /&gt;
  variable rho equal ${NP}/${VOL}&lt;br /&gt;
  variable AtomVol equal ${VOL}/${NP}&lt;br /&gt;
&lt;br /&gt;
  min_style cg&lt;br /&gt;
  minimize 0.0 1e-25 1000 1000&lt;br /&gt;
&lt;br /&gt;
  shell echo ${latt} ${rho} ${AtomVol} ${EPOT} ${ELAT} &amp;gt;&amp;gt; out.data &lt;br /&gt;
  next i&lt;br /&gt;
  jump in.equillatt_bulk_mod loop&lt;br /&gt;
label break&lt;br /&gt;
variable i delete&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5896</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5896"/>
		<updated>2013-02-07T10:29:41Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Contact Information */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang== &lt;br /&gt;
03/01/2013 - Current: Assistant Professor at [http://me.yonsei.ac.kr/_eng Dept. of Mech. Engr., Yonsei Univ.]&amp;lt;br/&amp;gt;&lt;br /&gt;
03/07/2011 - 01/10/2013: Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, V. Bulatov, and W. Cai, &amp;quot;Singular orientations and faceted motion of dislocations in body-centered cubic crystals&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;109&#039;&#039;&#039; 15174 (2012)&lt;br /&gt;
*T. Filleter, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Yin, R. Bernal, K. Sohn, S.-Y. Li, J. Huang, W. Cai, and H. Espinosa, &amp;quot;Nucleation-controlled distributed plasticity in penta-twinned silver nanowires&amp;quot;, &#039;&#039;Small&#039;&#039;, &#039;&#039;&#039;8&#039;&#039;&#039; 2986 (2012)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Wang, and I. J. Beyerlein, &amp;quot;Atomistic structure variations of mechanically stable fcc-bcc interfaces&amp;quot;, &#039;&#039;J. App. Phys.&#039;&#039;, &#039;&#039;&#039;111&#039;&#039;&#039; 053531 (2012)&lt;br /&gt;
*C. R. Weinberger, A. T. Jennings, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and J. R. Greer, &amp;quot;Atomistic simulations and continuum modeling of dislocation nucleation and strength in gold nanowires&amp;quot;, &#039;&#039;JMPS&#039;&#039;, &#039;&#039;&#039;60&#039;&#039;&#039; 84 (2012)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Predicting the dislocation nucleation rate as a function of temperature and stress&amp;quot;, &#039;&#039;J. Mater. Res.&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 2335 (2011)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;108&#039;&#039;&#039; 5174 (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and W. Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, &#039;&#039;&#039;64&#039;&#039;&#039; 1043 (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039; 2169 (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039; 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
:[http://scholar.google.com/citations?hl=en&amp;amp;user=o4AnOQ0AAAAJ google my citation]&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
Office: Engr. Bldg. 1 Rm. A582, Yonsei Univ., S. Korea &amp;lt;br/&amp;gt;&lt;br /&gt;
Work: 82-2-2123-2825 &amp;lt;br/&amp;gt;&lt;br /&gt;
Email: &amp;lt;math&amp;gt;\mathrm{kwkang75\;at\;yonsei\;dot\;ac\;dot\;kr}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!--Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;!--Work: (505)665-2380 &amp;lt;br/&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;!--Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt; --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5895</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5895"/>
		<updated>2013-02-07T10:28:46Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Keonwook Kang */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang== &lt;br /&gt;
03/01/2013 - Current: Assistant Professor at [http://me.yonsei.ac.kr/_eng Dept. of Mech. Engr., Yonsei Univ.]&amp;lt;br/&amp;gt;&lt;br /&gt;
03/07/2011 - 01/10/2013: Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, V. Bulatov, and W. Cai, &amp;quot;Singular orientations and faceted motion of dislocations in body-centered cubic crystals&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;109&#039;&#039;&#039; 15174 (2012)&lt;br /&gt;
*T. Filleter, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Yin, R. Bernal, K. Sohn, S.-Y. Li, J. Huang, W. Cai, and H. Espinosa, &amp;quot;Nucleation-controlled distributed plasticity in penta-twinned silver nanowires&amp;quot;, &#039;&#039;Small&#039;&#039;, &#039;&#039;&#039;8&#039;&#039;&#039; 2986 (2012)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Wang, and I. J. Beyerlein, &amp;quot;Atomistic structure variations of mechanically stable fcc-bcc interfaces&amp;quot;, &#039;&#039;J. App. Phys.&#039;&#039;, &#039;&#039;&#039;111&#039;&#039;&#039; 053531 (2012)&lt;br /&gt;
*C. R. Weinberger, A. T. Jennings, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and J. R. Greer, &amp;quot;Atomistic simulations and continuum modeling of dislocation nucleation and strength in gold nanowires&amp;quot;, &#039;&#039;JMPS&#039;&#039;, &#039;&#039;&#039;60&#039;&#039;&#039; 84 (2012)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Predicting the dislocation nucleation rate as a function of temperature and stress&amp;quot;, &#039;&#039;J. Mater. Res.&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 2335 (2011)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;108&#039;&#039;&#039; 5174 (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and W. Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, &#039;&#039;&#039;64&#039;&#039;&#039; 1043 (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039; 2169 (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039; 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
:[http://scholar.google.com/citations?hl=en&amp;amp;user=o4AnOQ0AAAAJ google my citation]&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
Office: Engr. Bldg. 1 Rm. A582, Yonsei Univ., S. Korea &amp;lt;br/&amp;gt;&lt;br /&gt;
Work: 82-2-2123-2825 &amp;lt;br/&amp;gt;&lt;br /&gt;
Email: &amp;lt;math&amp;gt;\mathrm{kwkang75\;at\;yonsei\;dot\;ac\;kr}&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;!--Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;!--Work: (505)665-2380 &amp;lt;br/&amp;gt; --&amp;gt;&lt;br /&gt;
&amp;lt;!--Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt; --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5886</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5886"/>
		<updated>2012-08-17T20:54:36Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Keonwook Kang */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang== &lt;br /&gt;
03/07/2011 - Current: Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, V. Bulatov, and W. Cai, &amp;quot;Singular orientations and faceted motion of dislocations in body-centered cubic crystals&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, in print (2012)&lt;br /&gt;
*T. Filleter, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Yin, R. Bernal, K. Sohn, S.-Y. Li, J. Huang, W. Cai, and H. Espinosa, &amp;quot;Nucleation-controlled distributed plasticity in penta-twinned silver nanowires&amp;quot;, &#039;&#039;Small&#039;&#039;, in print (2012)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Wang, and I. J. Beyerlein, &amp;quot;Atomistic structure variations of mechanically stable fcc-bcc interfaces&amp;quot;, &#039;&#039;J. App. Phys.&#039;&#039;, &#039;&#039;&#039;111&#039;&#039;&#039; 053531 (2012)&lt;br /&gt;
*C. R. Weinberger, A. T. Jennings, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and J. R. Greer, &amp;quot;Atomistic simulations and continuum modeling of dislocation nucleation and strength in gold nanowires&amp;quot;, &#039;&#039;JMPS&#039;&#039;, &#039;&#039;&#039;60&#039;&#039;&#039; 84 (2012)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Predicting the dislocation nucleation rate as a function of temperature and stress&amp;quot;, &#039;&#039;J. Mater. Res.&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 2335 (2011)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;108&#039;&#039;&#039; 5174 (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and W. Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, &#039;&#039;&#039;64&#039;&#039;&#039; 1043 (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039; 2169 (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039; 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
:[http://scholar.google.com/citations?hl=en&amp;amp;user=o4AnOQ0AAAAJ google my citation]&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
:Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Work: (505)665-2380 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5885</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5885"/>
		<updated>2012-08-17T20:36:13Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Publications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang==&lt;br /&gt;
&lt;br /&gt;
Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, V. Bulatov, and W. Cai, &amp;quot;Singular orientations and faceted motion of dislocations in body-centered cubic crystals&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, in print (2012)&lt;br /&gt;
*T. Filleter, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Yin, R. Bernal, K. Sohn, S.-Y. Li, J. Huang, W. Cai, and H. Espinosa, &amp;quot;Nucleation-controlled distributed plasticity in penta-twinned silver nanowires&amp;quot;, &#039;&#039;Small&#039;&#039;, in print (2012)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, J. Wang, and I. J. Beyerlein, &amp;quot;Atomistic structure variations of mechanically stable fcc-bcc interfaces&amp;quot;, &#039;&#039;J. App. Phys.&#039;&#039;, &#039;&#039;&#039;111&#039;&#039;&#039; 053531 (2012)&lt;br /&gt;
*C. R. Weinberger, A. T. Jennings, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and J. R. Greer, &amp;quot;Atomistic simulations and continuum modeling of dislocation nucleation and strength in gold nanowires&amp;quot;, &#039;&#039;JMPS&#039;&#039;, &#039;&#039;&#039;60&#039;&#039;&#039; 84 (2012)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Predicting the dislocation nucleation rate as a function of temperature and stress&amp;quot;, &#039;&#039;J. Mater. Res.&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 2335 (2011)&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, and W. Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, &#039;&#039;&#039;108&#039;&#039;&#039; 5174 (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and W. Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, &#039;&#039;&#039;64&#039;&#039;&#039; 1043 (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039; 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039; 2169 (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039; 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
:Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Work: (505)665-2380 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5446</id>
		<title>M04 Energy Minimization of Vacancy</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5446"/>
		<updated>2011-09-13T15:14:15Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Vacancy Formation Energy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 04 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Vacancy Formation Energy by Energy Minimization&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 27 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a Vacancy in a Perfect Crystal ==&lt;br /&gt;
A vacancy is a common point defect in solids. It is an&lt;br /&gt;
empty site (&#039;&#039;i.e.&#039;&#039; a missing atom) in an otherwise prefect crystal structure. Here&lt;br /&gt;
we discuss how to introduce a vacancy in a perfect crystal using MD++ and how&lt;br /&gt;
to compute the vacancy formation energy. For more information, see [[media:VFE.pdf‎ | supplementary document: Vacancy formation energy by MD++ ]].&lt;br /&gt;
Consider the following MD++ input ﬁle, &#039;&#039;&#039;movacancy.script&#039;&#039;&#039;, that creates a vacancy in a perfect BCC Molybdenum&lt;br /&gt;
crystal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/movacancy # specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read in potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic latticeconst = 3.1472 #(A)&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
eval # evaluate the potential of perfect crystal&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Vacancy&lt;br /&gt;
input = [ 1      # number of atoms to be fixed&lt;br /&gt;
          0]     # index of an atom to be fixed&lt;br /&gt;
fixatoms_by_ID   # fix a set of atoms by their indices&lt;br /&gt;
removefixedatoms # remove fixed atoms&lt;br /&gt;
finalcnfile = movac.cn writecn&lt;br /&gt;
eval # evaluate the vacancy-formed crystal&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red   fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600    win_height = 600&lt;br /&gt;
plot_atom_info = 3&lt;br /&gt;
color00 = &amp;quot;orange&amp;quot; color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
color06 = &amp;quot;gray80&amp;quot; color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
plot_color_windows = [ 2             # number of color windows&lt;br /&gt;
                      -10  -6.8   6  # color06 = gray80&lt;br /&gt;
                      -6.7 -6.0   0  # color00 = orange&lt;br /&gt;
                     ]&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can run this script ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs gpp scripts/movacancy.script&lt;br /&gt;
&lt;br /&gt;
First, MD++ creates a 5×5×5 perfect cubic crystal of BCC Mo with edges along&lt;br /&gt;
&amp;lt;100&amp;gt; directions. Then it ﬁxes atom 0 by&lt;br /&gt;
&lt;br /&gt;
    input = [ 1         # number of atoms to be fixed&lt;br /&gt;
              0 ]       # index of an atom to be fixed&lt;br /&gt;
    fixatoms_by_ID&lt;br /&gt;
&lt;br /&gt;
and then removs this atom by the command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.&lt;br /&gt;
The ﬁrst number in the input array speciﬁes the number of atoms to be removed.&lt;br /&gt;
For example, if you would like to remove two atoms, say 3 and 8, you can do so&lt;br /&gt;
by &lt;br /&gt;
&lt;br /&gt;
 input = [ 2            #  number of atoms to be fixed&lt;br /&gt;
           3 8 ]        #  index of atoms to be fixed&lt;br /&gt;
 fixatoms_by_ID         #  fix a set of atoms by their index&lt;br /&gt;
 removefixedatoms       # remove fixed atoms&lt;br /&gt;
&lt;br /&gt;
Sometimes, you may want to remove a speciﬁc atom you see in the graphic&lt;br /&gt;
window. You can obtain the index of this atom by clicking the atom with&lt;br /&gt;
your mouse. Depending on the setting of &#039;&#039;&#039;plot_atom_info&#039;&#039;&#039;, other information is&lt;br /&gt;
also displayed when you click on the atom. If &#039;&#039;&#039;plot_atom_info = 1&#039;&#039;&#039;, the atom&lt;br /&gt;
index number and its scaled coordinates are printed when the atom is clicked.&lt;br /&gt;
If &#039;&#039;&#039;plot_atom_info = 2&#039;&#039;&#039;, the atom index and its real coordinate (in &amp;amp;Aring;) will be&lt;br /&gt;
printed. If &#039;&#039;&#039;plot_atom_info = 3&#039;&#039;&#039;, the atom index and its local energy (in eV)&lt;br /&gt;
will be printed.&lt;br /&gt;
&lt;br /&gt;
The script ﬁle also sets up two color windows (&#039;&#039;&#039;plot_color_windows&#039;&#039;&#039;) to&lt;br /&gt;
display the atoms. Atoms with local energy between -10 eV and -6.8 eV are&lt;br /&gt;
shown in gray and the atoms whose energies lie between -6.7 eV and -6.0 eV are&lt;br /&gt;
shown in orange. This will highlight the atoms near the vacancy because they&lt;br /&gt;
usually have a higher local energy. Click the atoms and you will see the actual&lt;br /&gt;
local energy of these atoms. If you compare&lt;br /&gt;
the potential energy of the perfect structure and the vacancy-formed structure,&lt;br /&gt;
you will know which structure has higher energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.1&#039;&#039; If a single atom, whose index is other than 0, is removed from the same perfect structure, &lt;br /&gt;
do we expect the system to have a different potential energy?&lt;br /&gt;
&lt;br /&gt;
== Relaxation ==&lt;br /&gt;
When an atom is removed from a crystal, we expect the neighboring atoms to&lt;br /&gt;
adjust its positions, &#039;&#039;e.g.&#039;&#039; to move toward the vacant site, in order to lower the potential energy. The relaxed structure can be obtained by an energy minimization&lt;br /&gt;
algorithm, such as [[M04A Conjugate Gradient Method in MD++ | the conjugate gradient (CG) method]]. This can be done by&lt;br /&gt;
the following lines.&lt;br /&gt;
&lt;br /&gt;
 #---------------------------------------------&lt;br /&gt;
 # Conjugate-Gradient relaxation&lt;br /&gt;
 conj_ftol = 1e-7          # tolerance on the residual gradient&lt;br /&gt;
 conj_fevalmax = 1000 # max. number of iterations&lt;br /&gt;
 conj_fixbox = 1           # fix the simulation box&lt;br /&gt;
 relax                     # CG relaxation command&lt;br /&gt;
 finalcnfile = relaxed.cn writecn&lt;br /&gt;
 eval                      # evaluate relaxed structure&lt;br /&gt;
&lt;br /&gt;
Let’s copy the above script and paste it to the &#039;&#039;&#039;movacancy.script&#039;&#039;&#039; right before&lt;br /&gt;
the last command, &#039;&#039;&#039;sleep quit&#039;&#039;&#039;. You will see that the potential energy of the&lt;br /&gt;
simulated system keeps decreasing while the relaxation goes on. &lt;br /&gt;
The potential energy printed by the second &#039;&#039;&#039;eval&#039;&#039;&#039; should be lower than that&lt;br /&gt;
printed by the ﬁrst &#039;&#039;&#039;eval&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are several variables controlling the CG relaxation. &#039;&#039;&#039;conj_ftol&#039;&#039;&#039; is the&lt;br /&gt;
tolerance of the residual gradient and &#039;&#039;&#039;conj_fevalmax&#039;&#039;&#039; is the maximum number&lt;br /&gt;
of calls to the potential function (effectively limiting the number of iterations).&lt;br /&gt;
If &#039;&#039;&#039;conj_fixbox = 1&#039;&#039;&#039;, the shape and volume of simulation cell box is ﬁxed and&lt;br /&gt;
only the scaled coordinates of the atoms can change during the relaxation.&lt;br /&gt;
If &#039;&#039;&#039;conj fixbox = 0&#039;&#039;&#039;, then all 9 components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to change.&lt;br /&gt;
Sometimes, we want to ﬁx some components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix while allowing&lt;br /&gt;
other components to vary. This can be done by specifying the &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039;&lt;br /&gt;
matrix. For example, if&lt;br /&gt;
&lt;br /&gt;
 conj_fixbox = 0&lt;br /&gt;
 conj_fixboxvec = [ 0 1 1&lt;br /&gt;
                    1 0 1&lt;br /&gt;
                    1 1 0 ]&lt;br /&gt;
&lt;br /&gt;
then only the diagonal components of the box matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to relax. &lt;br /&gt;
(The corresponding entries in &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039; are zero).&lt;br /&gt;
&lt;br /&gt;
== Vacancy Formation Energy ==&lt;br /&gt;
The vacancy formation energy &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; is the energy increase that is needed to create a&lt;br /&gt;
vacancy in a perfect crystal. It can be used to predict the vacancy concentration&lt;br /&gt;
at thermal equilibrium through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-E_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an approximation because we have ignored the vibration entropy contribution &lt;br /&gt;
&amp;lt;math&amp;gt;S_v&amp;lt;/math&amp;gt; of the vacancy. The exact expression is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-F_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;F_v = E_v - T S_v&amp;lt;/math&amp;gt; is the vacancy formation free energy. These expressions&lt;br /&gt;
are similar to Boltzmann’s distribution and will be derived in the [[#Equilibrium Vacancy Concentration|Appendix]].&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; be the energy of the perfect crystal with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, and &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; be the&lt;br /&gt;
relaxed potential energy of the (N − 1)-atom system (containing the vacancy).&lt;br /&gt;
The vacancy formation energy is not simply the difference between the two, &#039;&#039;i.e.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \neq E_2 - E_1 &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
because the two systems does not have the same number of atoms.&lt;br /&gt;
we need to make sure we compare two systems of the same number of atoms. &lt;br /&gt;
Besides, in a real crystal, no atom is destroyed when a vacancy forms. Instead, when a&lt;br /&gt;
vacancy forms in a real crystal, the missing atom moves to the external surface of the&lt;br /&gt;
crystal (or to grain boundaries). (See Fig.2(a).) Because we have a very small crystal&lt;br /&gt;
in our simulation, subjected to the periodic boundary condition, there&lt;br /&gt;
is no external surface. Therefore, we need to account for this effect in a different&lt;br /&gt;
way. In the perfect crystal, all atoms contributes equally to the total energy.&lt;br /&gt;
Hence, we expect the energy contribution of (N − 1) atoms in the perfect&lt;br /&gt;
crystal structure to be &amp;lt;math&amp;gt;(N-1)/N \times E_1 &amp;lt;/math&amp;gt;(even though we cannot construct a perfect crystal with (N − 1) atoms in a periodic simulation cell). The vacancy formation energy&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; can be computed from&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - \frac{N-1}{N} E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The cohesive energy of the perfect crystal, &amp;lt;math&amp;gt;E_{coh} = E_1 /N&amp;lt;/math&amp;gt; , is the potential energy&lt;br /&gt;
per atom. Hence the vacancy formation energy can also be expressed as,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - (N-1) E_{coh} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv (E_2 + E_{coh}) - E_{1} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The result for BCC Mo using the FS potential is &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt;2.550 eV&amp;lt;ref&amp;gt;This is consistent with the more accurate tight-binding (TB) model which predicts &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt; 2.46 eV from the reference, M. J. Mehl and D. A. Papaconstantopoulos, “Applications of a tight-binding total-energy method for transition and noble metals: Elastic constants, vacancies, and surfaces of monatomic metals”, Physical Review B &#039;&#039;&#039;54&#039;&#039;&#039; 4519-4530 1996&amp;lt;/ref&amp;gt; which leads to [n] ≈ 1.43 × 10−13 at T = 1000K (kB = 8.621 × 10−5 eV/K).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.2&#039;&#039; Can you tell the different physical meanings between two expressions &lt;br /&gt;
&amp;lt;math&amp;gt;E_2 - \frac{N-1}{N}E_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_2 - E_1&amp;lt;/math&amp;gt;? You can use Fig. 2 for your explanation.&lt;br /&gt;
              &lt;br /&gt;
&#039;&#039;Q.3&#039;&#039; Recompute &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; with larger and smaller simulation boxes. How does&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; depend on the number of atoms in the simulation cell?&lt;br /&gt;
&lt;br /&gt;
[[Image:Movacancy.jpg | frame | center | Fig.1: Vacancy-formed BCC molybdenum crystal. &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[100], \mathbf{c}_2 = 4[010]&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\mathbf{c}_3 = 4[001]&amp;lt;/math&amp;gt; are the periodicity vectors. The red dotted circle designates&lt;br /&gt;
the missing atom and the atoms around the vacant site are shown in different&lt;br /&gt;
color due to their relatively high energy than the others. ]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:VacancyVSremoving.jpg | frame | center | Fig.2: (a) In a real crystal, the atom that leaves the interior, thus creating&lt;br /&gt;
a vacancy, moves to the surface of the crystal. (b) If we simply take the energy&lt;br /&gt;
difference between &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; (N − 1 atoms) and &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; (N atoms), we are considering&lt;br /&gt;
the process in which the atom leaves the crystal and moves so far away that it&lt;br /&gt;
does not interact with any other atoms in the crystal. This will lead to a much&lt;br /&gt;
higher potential energy and does not predict &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; correctly.]]&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Vacancy Concentration ==&lt;br /&gt;
Here we derive the equilibrium vacancy concentration, Eq. (2), given the formation&lt;br /&gt;
energy of a single vacancy. Consider a crystal with N sites, n of which&lt;br /&gt;
are occupied by vacancies. We can write the Gibbs free energy of the solid as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; G = G_0 + n E_v - T S_c &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;G_0&amp;lt;/math&amp;gt; is the free energy of the perfect crystal (&amp;lt;math&amp;gt;n = 0&amp;lt;/math&amp;gt;). &lt;br /&gt;
Here we have ignored the interaction between the vacancies. This approximation is valid if &amp;lt;math&amp;gt;n \ll N&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;math&amp;gt;S_c&amp;lt;/math&amp;gt; is the conﬁgurational entropy due to the fact that there are &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; different ways&lt;br /&gt;
to arrange the n vacancies on N sites.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} S_c &amp;amp;= k_B \ln \Omega = k_B \ln \frac{N!}{(N-n)!n!} \\&lt;br /&gt;
                          &amp;amp;= k_B [N\ln N - (N-n)\ln (N-n) - n\ln n ] \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the last step we have used Stirling’s approximation. At equilibrium, the&lt;br /&gt;
Gibbs free energy &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; reaches minimum, which means &amp;lt;math&amp;gt;\partial \Delta G / \partial n = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
        &lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \frac{\partial \Delta G}{\partial n} &amp;amp;= E_v - T\frac{\partial S_c}{\partial n} \\&lt;br /&gt;
                          &amp;amp;= E_v - T k_B \ln \frac{N-n}{n} \\&lt;br /&gt;
                          &amp;amp;\simeq E_v - T k_B \ln \frac{N}{n} = 0 \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \therefore [n] \equiv \frac{n}{N} = \exp (-\frac{E_v}{k_B T})&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5445</id>
		<title>M04 Energy Minimization of Vacancy</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5445"/>
		<updated>2011-09-13T15:11:48Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Equilibrium Vacancy Concentration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 04 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Vacancy Formation Energy by Energy Minimization&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 27 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a Vacancy in a Perfect Crystal ==&lt;br /&gt;
A vacancy is a common point defect in solids. It is an&lt;br /&gt;
empty site (&#039;&#039;i.e.&#039;&#039; a missing atom) in an otherwise prefect crystal structure. Here&lt;br /&gt;
we discuss how to introduce a vacancy in a perfect crystal using MD++ and how&lt;br /&gt;
to compute the vacancy formation energy. For more information, see [[media:VFE.pdf‎ | supplementary document: Vacancy formation energy by MD++ ]].&lt;br /&gt;
Consider the following MD++ input ﬁle, &#039;&#039;&#039;movacancy.script&#039;&#039;&#039;, that creates a vacancy in a perfect BCC Molybdenum&lt;br /&gt;
crystal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/movacancy # specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read in potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic latticeconst = 3.1472 #(A)&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
eval # evaluate the potential of perfect crystal&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Vacancy&lt;br /&gt;
input = [ 1      # number of atoms to be fixed&lt;br /&gt;
          0]     # index of an atom to be fixed&lt;br /&gt;
fixatoms_by_ID   # fix a set of atoms by their indices&lt;br /&gt;
removefixedatoms # remove fixed atoms&lt;br /&gt;
finalcnfile = movac.cn writecn&lt;br /&gt;
eval # evaluate the vacancy-formed crystal&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red   fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600    win_height = 600&lt;br /&gt;
plot_atom_info = 3&lt;br /&gt;
color00 = &amp;quot;orange&amp;quot; color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
color06 = &amp;quot;gray80&amp;quot; color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
plot_color_windows = [ 2             # number of color windows&lt;br /&gt;
                      -10  -6.8   6  # color06 = gray80&lt;br /&gt;
                      -6.7 -6.0   0  # color00 = orange&lt;br /&gt;
                     ]&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can run this script ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs gpp scripts/movacancy.script&lt;br /&gt;
&lt;br /&gt;
First, MD++ creates a 5×5×5 perfect cubic crystal of BCC Mo with edges along&lt;br /&gt;
&amp;lt;100&amp;gt; directions. Then it ﬁxes atom 0 by&lt;br /&gt;
&lt;br /&gt;
    input = [ 1         # number of atoms to be fixed&lt;br /&gt;
              0 ]       # index of an atom to be fixed&lt;br /&gt;
    fixatoms_by_ID&lt;br /&gt;
&lt;br /&gt;
and then removs this atom by the command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.&lt;br /&gt;
The ﬁrst number in the input array speciﬁes the number of atoms to be removed.&lt;br /&gt;
For example, if you would like to remove two atoms, say 3 and 8, you can do so&lt;br /&gt;
by &lt;br /&gt;
&lt;br /&gt;
 input = [ 2            #  number of atoms to be fixed&lt;br /&gt;
           3 8 ]        #  index of atoms to be fixed&lt;br /&gt;
 fixatoms_by_ID         #  fix a set of atoms by their index&lt;br /&gt;
 removefixedatoms       # remove fixed atoms&lt;br /&gt;
&lt;br /&gt;
Sometimes, you may want to remove a speciﬁc atom you see in the graphic&lt;br /&gt;
window. You can obtain the index of this atom by clicking the atom with&lt;br /&gt;
your mouse. Depending on the setting of &#039;&#039;&#039;plot_atom_info&#039;&#039;&#039;, other information is&lt;br /&gt;
also displayed when you click on the atom. If &#039;&#039;&#039;plot_atom_info = 1&#039;&#039;&#039;, the atom&lt;br /&gt;
index number and its scaled coordinates are printed when the atom is clicked.&lt;br /&gt;
If &#039;&#039;&#039;plot_atom_info = 2&#039;&#039;&#039;, the atom index and its real coordinate (in &amp;amp;Aring;) will be&lt;br /&gt;
printed. If &#039;&#039;&#039;plot_atom_info = 3&#039;&#039;&#039;, the atom index and its local energy (in eV)&lt;br /&gt;
will be printed.&lt;br /&gt;
&lt;br /&gt;
The script ﬁle also sets up two color windows (&#039;&#039;&#039;plot_color_windows&#039;&#039;&#039;) to&lt;br /&gt;
display the atoms. Atoms with local energy between -10 eV and -6.8 eV are&lt;br /&gt;
shown in gray and the atoms whose energies lie between -6.7 eV and -6.0 eV are&lt;br /&gt;
shown in orange. This will highlight the atoms near the vacancy because they&lt;br /&gt;
usually have a higher local energy. Click the atoms and you will see the actual&lt;br /&gt;
local energy of these atoms. If you compare&lt;br /&gt;
the potential energy of the perfect structure and the vacancy-formed structure,&lt;br /&gt;
you will know which structure has higher energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.1&#039;&#039; If a single atom, whose index is other than 0, is removed from the same perfect structure, &lt;br /&gt;
do we expect the system to have a different potential energy?&lt;br /&gt;
&lt;br /&gt;
== Relaxation ==&lt;br /&gt;
When an atom is removed from a crystal, we expect the neighboring atoms to&lt;br /&gt;
adjust its positions, &#039;&#039;e.g.&#039;&#039; to move toward the vacant site, in order to lower the potential energy. The relaxed structure can be obtained by an energy minimization&lt;br /&gt;
algorithm, such as [[M04A Conjugate Gradient Method in MD++ | the conjugate gradient (CG) method]]. This can be done by&lt;br /&gt;
the following lines.&lt;br /&gt;
&lt;br /&gt;
 #---------------------------------------------&lt;br /&gt;
 # Conjugate-Gradient relaxation&lt;br /&gt;
 conj_ftol = 1e-7          # tolerance on the residual gradient&lt;br /&gt;
 conj_fevalmax = 1000 # max. number of iterations&lt;br /&gt;
 conj_fixbox = 1           # fix the simulation box&lt;br /&gt;
 relax                     # CG relaxation command&lt;br /&gt;
 finalcnfile = relaxed.cn writecn&lt;br /&gt;
 eval                      # evaluate relaxed structure&lt;br /&gt;
&lt;br /&gt;
Let’s copy the above script and paste it to the &#039;&#039;&#039;movacancy.script&#039;&#039;&#039; right before&lt;br /&gt;
the last command, &#039;&#039;&#039;sleep quit&#039;&#039;&#039;. You will see that the potential energy of the&lt;br /&gt;
simulated system keeps decreasing while the relaxation goes on. &lt;br /&gt;
The potential energy printed by the second &#039;&#039;&#039;eval&#039;&#039;&#039; should be lower than that&lt;br /&gt;
printed by the ﬁrst &#039;&#039;&#039;eval&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are several variables controlling the CG relaxation. &#039;&#039;&#039;conj_ftol&#039;&#039;&#039; is the&lt;br /&gt;
tolerance of the residual gradient and &#039;&#039;&#039;conj_fevalmax&#039;&#039;&#039; is the maximum number&lt;br /&gt;
of calls to the potential function (effectively limiting the number of iterations).&lt;br /&gt;
If &#039;&#039;&#039;conj_fixbox = 1&#039;&#039;&#039;, the shape and volume of simulation cell box is ﬁxed and&lt;br /&gt;
only the scaled coordinates of the atoms can change during the relaxation.&lt;br /&gt;
If &#039;&#039;&#039;conj fixbox = 0&#039;&#039;&#039;, then all 9 components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to change.&lt;br /&gt;
Sometimes, we want to ﬁx some components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix while allowing&lt;br /&gt;
other components to vary. This can be done by specifying the &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039;&lt;br /&gt;
matrix. For example, if&lt;br /&gt;
&lt;br /&gt;
 conj_fixbox = 0&lt;br /&gt;
 conj_fixboxvec = [ 0 1 1&lt;br /&gt;
                    1 0 1&lt;br /&gt;
                    1 1 0 ]&lt;br /&gt;
&lt;br /&gt;
then only the diagonal components of the box matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to relax. &lt;br /&gt;
(The corresponding entries in &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039; are zero).&lt;br /&gt;
&lt;br /&gt;
== Vacancy Formation Energy ==&lt;br /&gt;
The vacancy formation energy &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; is the energy increase that is needed to create a&lt;br /&gt;
vacancy in a perfect crystal. It can be used to predict the vacancy concentration&lt;br /&gt;
at thermal equilibrium through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-E_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an approximation because we have ignored the vibration entropy contribution &lt;br /&gt;
&amp;lt;math&amp;gt;S_v&amp;lt;/math&amp;gt; of the vacancy. The exact expression is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-F_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;F_v = E_v - T S_v&amp;lt;/math&amp;gt; is the vacancy formation free energy. These expressions&lt;br /&gt;
are similar to Boltzmann’s distribution and will be derived in the [[#Equilibrium Vacancy Concentration|Appendix]].&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; be the energy of the perfect crystal with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, and &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; be the&lt;br /&gt;
relaxed potential energy of the (N − 1)-atom system (containing the vacancy).&lt;br /&gt;
The vacancy formation energy is not simply the difference between the two, &#039;&#039;i.e.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \neq E_2 - E_1 &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
because the two systems does not have the same number of atoms.&lt;br /&gt;
we need to make sure we compare two systems of the same number of atoms. &lt;br /&gt;
Besides, in a real crystal, no atom is destroyed when a vacancy forms. Instead, when a&lt;br /&gt;
vacancy forms in a real crystal, the missing atom moves to the external surface of the&lt;br /&gt;
crystal (or to grain boundaries). (See Fig.2(a).) Because we have a very small crystal&lt;br /&gt;
in our simulation, subjected to the periodic boundary condition, there&lt;br /&gt;
is no external surface. Therefore, we need to account for this effect in a different&lt;br /&gt;
way. In the perfect crystal, all atoms contributes equally to the total energy.&lt;br /&gt;
Hence, we expect the energy contribution of (N − 1) atoms in the perfect&lt;br /&gt;
crystal structure to be &amp;lt;math&amp;gt;(N-1)/N \times E_1 &amp;lt;/math&amp;gt;(even though we cannot construct a perfect crystal with (N − 1) atoms in a periodic simulation cell). The vacancy formation energy&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; can be computed from&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - \frac{N-1}{N} E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The cohesive energy of the perfect crystal, &amp;lt;math&amp;gt;E_{coh} = E_1 /N&amp;lt;/math&amp;gt; , is the potential energy&lt;br /&gt;
per atom. Hence the vacancy formation energy can also be expressed as,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - (N-1) E_{coh} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv (E_2 + E_{coh}) - E_{1} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The result for BCC Mo using the FS potential is &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt;2.550 eV&amp;lt;ref&amp;gt;This is consistent with the more accurate tight-binding (TB) model which predicts &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt; 2.46 eV from the reference, M. J. Mehl and D. A. Papaconstantopoulos, “Applications of a tight-binding total-energy method for transition and noble metals: Elastic constants, vacancies, and surfaces of monatomic metals”, Physical Review B &#039;&#039;&#039;54&#039;&#039;&#039; 4519-4530 1996&amp;lt;/ref&amp;gt; which leads to [n] ≈ 1.43 × 10−13 at T = 1000K (kB = 8.621 × 10−5 eV/K).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.2&#039;&#039; Can you tell the different physical meanings between two expressions &lt;br /&gt;
&amp;lt;math&amp;gt;E_2 - \frac{N-1}{N}E_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_2 - E_1&amp;lt;/math&amp;gt;? You can use Fig. 2 for your explanation.&lt;br /&gt;
              &lt;br /&gt;
&#039;&#039;Q.3&#039;&#039; Recompute &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; with larger and smaller simulation boxes. How does&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; depend on the number of atoms in the simulation cell?&lt;br /&gt;
&lt;br /&gt;
[[Image:Movacancy.jpg | frame | center | Fig.1: Vacancy-formed BCC molybdenum crystal. &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[100], \mathbf{c}_2 = 4[010]&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[001]&amp;lt;/math&amp;gt; are the periodicity vectors. The red dotted circle designates&lt;br /&gt;
the missing atom and the atoms around the vacant site are shown in different&lt;br /&gt;
color due to their relatively high energy than the others. ]]&lt;br /&gt;
[[Image:VacancyVSremoving.jpg | frame | center | Fig.2: (a) In a real crystal, the atom that leaves the interior, thus creating&lt;br /&gt;
a vacancy, moves to the surface of the crystal. (b) If we simply take the energy&lt;br /&gt;
difference between &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; (N − 1 atoms) and &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; (N atoms), we are considering&lt;br /&gt;
the process in which the atom leaves the crystal and moves so far away that it&lt;br /&gt;
does not interact with any other atoms in the crystal. This will lead to a much&lt;br /&gt;
higher potential energy and does not predict &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; correctly.]]&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Vacancy Concentration ==&lt;br /&gt;
Here we derive the equilibrium vacancy concentration, Eq. (2), given the formation&lt;br /&gt;
energy of a single vacancy. Consider a crystal with N sites, n of which&lt;br /&gt;
are occupied by vacancies. We can write the Gibbs free energy of the solid as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; G = G_0 + n E_v - T S_c &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;G_0&amp;lt;/math&amp;gt; is the free energy of the perfect crystal (&amp;lt;math&amp;gt;n = 0&amp;lt;/math&amp;gt;). &lt;br /&gt;
Here we have ignored the interaction between the vacancies. This approximation is valid if &amp;lt;math&amp;gt;n \ll N&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;math&amp;gt;S_c&amp;lt;/math&amp;gt; is the conﬁgurational entropy due to the fact that there are &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; different ways&lt;br /&gt;
to arrange the n vacancies on N sites.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} S_c &amp;amp;= k_B \ln \Omega = k_B \ln \frac{N!}{(N-n)!n!} \\&lt;br /&gt;
                          &amp;amp;= k_B [N\ln N - (N-n)\ln (N-n) - n\ln n ] \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the last step we have used Stirling’s approximation. At equilibrium, the&lt;br /&gt;
Gibbs free energy &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; reaches minimum, which means &amp;lt;math&amp;gt;\partial \Delta G / \partial n = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
        &lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \frac{\partial \Delta G}{\partial n} &amp;amp;= E_v - T\frac{\partial S_c}{\partial n} \\&lt;br /&gt;
                          &amp;amp;= E_v - T k_B \ln \frac{N-n}{n} \\&lt;br /&gt;
                          &amp;amp;\simeq E_v - T k_B \ln \frac{N}{n} = 0 \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \therefore [n] \equiv \frac{n}{N} = \exp (-\frac{E_v}{k_B T})&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5444</id>
		<title>M04 Energy Minimization of Vacancy</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5444"/>
		<updated>2011-09-13T15:09:32Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Vacancy Formation Energy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 04 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Vacancy Formation Energy by Energy Minimization&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 27 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a Vacancy in a Perfect Crystal ==&lt;br /&gt;
A vacancy is a common point defect in solids. It is an&lt;br /&gt;
empty site (&#039;&#039;i.e.&#039;&#039; a missing atom) in an otherwise prefect crystal structure. Here&lt;br /&gt;
we discuss how to introduce a vacancy in a perfect crystal using MD++ and how&lt;br /&gt;
to compute the vacancy formation energy. For more information, see [[media:VFE.pdf‎ | supplementary document: Vacancy formation energy by MD++ ]].&lt;br /&gt;
Consider the following MD++ input ﬁle, &#039;&#039;&#039;movacancy.script&#039;&#039;&#039;, that creates a vacancy in a perfect BCC Molybdenum&lt;br /&gt;
crystal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/movacancy # specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read in potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic latticeconst = 3.1472 #(A)&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
eval # evaluate the potential of perfect crystal&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Vacancy&lt;br /&gt;
input = [ 1      # number of atoms to be fixed&lt;br /&gt;
          0]     # index of an atom to be fixed&lt;br /&gt;
fixatoms_by_ID   # fix a set of atoms by their indices&lt;br /&gt;
removefixedatoms # remove fixed atoms&lt;br /&gt;
finalcnfile = movac.cn writecn&lt;br /&gt;
eval # evaluate the vacancy-formed crystal&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red   fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600    win_height = 600&lt;br /&gt;
plot_atom_info = 3&lt;br /&gt;
color00 = &amp;quot;orange&amp;quot; color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
color06 = &amp;quot;gray80&amp;quot; color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
plot_color_windows = [ 2             # number of color windows&lt;br /&gt;
                      -10  -6.8   6  # color06 = gray80&lt;br /&gt;
                      -6.7 -6.0   0  # color00 = orange&lt;br /&gt;
                     ]&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can run this script ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs gpp scripts/movacancy.script&lt;br /&gt;
&lt;br /&gt;
First, MD++ creates a 5×5×5 perfect cubic crystal of BCC Mo with edges along&lt;br /&gt;
&amp;lt;100&amp;gt; directions. Then it ﬁxes atom 0 by&lt;br /&gt;
&lt;br /&gt;
    input = [ 1         # number of atoms to be fixed&lt;br /&gt;
              0 ]       # index of an atom to be fixed&lt;br /&gt;
    fixatoms_by_ID&lt;br /&gt;
&lt;br /&gt;
and then removs this atom by the command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.&lt;br /&gt;
The ﬁrst number in the input array speciﬁes the number of atoms to be removed.&lt;br /&gt;
For example, if you would like to remove two atoms, say 3 and 8, you can do so&lt;br /&gt;
by &lt;br /&gt;
&lt;br /&gt;
 input = [ 2            #  number of atoms to be fixed&lt;br /&gt;
           3 8 ]        #  index of atoms to be fixed&lt;br /&gt;
 fixatoms_by_ID         #  fix a set of atoms by their index&lt;br /&gt;
 removefixedatoms       # remove fixed atoms&lt;br /&gt;
&lt;br /&gt;
Sometimes, you may want to remove a speciﬁc atom you see in the graphic&lt;br /&gt;
window. You can obtain the index of this atom by clicking the atom with&lt;br /&gt;
your mouse. Depending on the setting of &#039;&#039;&#039;plot_atom_info&#039;&#039;&#039;, other information is&lt;br /&gt;
also displayed when you click on the atom. If &#039;&#039;&#039;plot_atom_info = 1&#039;&#039;&#039;, the atom&lt;br /&gt;
index number and its scaled coordinates are printed when the atom is clicked.&lt;br /&gt;
If &#039;&#039;&#039;plot_atom_info = 2&#039;&#039;&#039;, the atom index and its real coordinate (in &amp;amp;Aring;) will be&lt;br /&gt;
printed. If &#039;&#039;&#039;plot_atom_info = 3&#039;&#039;&#039;, the atom index and its local energy (in eV)&lt;br /&gt;
will be printed.&lt;br /&gt;
&lt;br /&gt;
The script ﬁle also sets up two color windows (&#039;&#039;&#039;plot_color_windows&#039;&#039;&#039;) to&lt;br /&gt;
display the atoms. Atoms with local energy between -10 eV and -6.8 eV are&lt;br /&gt;
shown in gray and the atoms whose energies lie between -6.7 eV and -6.0 eV are&lt;br /&gt;
shown in orange. This will highlight the atoms near the vacancy because they&lt;br /&gt;
usually have a higher local energy. Click the atoms and you will see the actual&lt;br /&gt;
local energy of these atoms. If you compare&lt;br /&gt;
the potential energy of the perfect structure and the vacancy-formed structure,&lt;br /&gt;
you will know which structure has higher energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.1&#039;&#039; If a single atom, whose index is other than 0, is removed from the same perfect structure, &lt;br /&gt;
do we expect the system to have a different potential energy?&lt;br /&gt;
&lt;br /&gt;
== Relaxation ==&lt;br /&gt;
When an atom is removed from a crystal, we expect the neighboring atoms to&lt;br /&gt;
adjust its positions, &#039;&#039;e.g.&#039;&#039; to move toward the vacant site, in order to lower the potential energy. The relaxed structure can be obtained by an energy minimization&lt;br /&gt;
algorithm, such as [[M04A Conjugate Gradient Method in MD++ | the conjugate gradient (CG) method]]. This can be done by&lt;br /&gt;
the following lines.&lt;br /&gt;
&lt;br /&gt;
 #---------------------------------------------&lt;br /&gt;
 # Conjugate-Gradient relaxation&lt;br /&gt;
 conj_ftol = 1e-7          # tolerance on the residual gradient&lt;br /&gt;
 conj_fevalmax = 1000 # max. number of iterations&lt;br /&gt;
 conj_fixbox = 1           # fix the simulation box&lt;br /&gt;
 relax                     # CG relaxation command&lt;br /&gt;
 finalcnfile = relaxed.cn writecn&lt;br /&gt;
 eval                      # evaluate relaxed structure&lt;br /&gt;
&lt;br /&gt;
Let’s copy the above script and paste it to the &#039;&#039;&#039;movacancy.script&#039;&#039;&#039; right before&lt;br /&gt;
the last command, &#039;&#039;&#039;sleep quit&#039;&#039;&#039;. You will see that the potential energy of the&lt;br /&gt;
simulated system keeps decreasing while the relaxation goes on. &lt;br /&gt;
The potential energy printed by the second &#039;&#039;&#039;eval&#039;&#039;&#039; should be lower than that&lt;br /&gt;
printed by the ﬁrst &#039;&#039;&#039;eval&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are several variables controlling the CG relaxation. &#039;&#039;&#039;conj_ftol&#039;&#039;&#039; is the&lt;br /&gt;
tolerance of the residual gradient and &#039;&#039;&#039;conj_fevalmax&#039;&#039;&#039; is the maximum number&lt;br /&gt;
of calls to the potential function (effectively limiting the number of iterations).&lt;br /&gt;
If &#039;&#039;&#039;conj_fixbox = 1&#039;&#039;&#039;, the shape and volume of simulation cell box is ﬁxed and&lt;br /&gt;
only the scaled coordinates of the atoms can change during the relaxation.&lt;br /&gt;
If &#039;&#039;&#039;conj fixbox = 0&#039;&#039;&#039;, then all 9 components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to change.&lt;br /&gt;
Sometimes, we want to ﬁx some components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix while allowing&lt;br /&gt;
other components to vary. This can be done by specifying the &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039;&lt;br /&gt;
matrix. For example, if&lt;br /&gt;
&lt;br /&gt;
 conj_fixbox = 0&lt;br /&gt;
 conj_fixboxvec = [ 0 1 1&lt;br /&gt;
                    1 0 1&lt;br /&gt;
                    1 1 0 ]&lt;br /&gt;
&lt;br /&gt;
then only the diagonal components of the box matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to relax. &lt;br /&gt;
(The corresponding entries in &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039; are zero).&lt;br /&gt;
&lt;br /&gt;
== Vacancy Formation Energy ==&lt;br /&gt;
The vacancy formation energy &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; is the energy increase that is needed to create a&lt;br /&gt;
vacancy in a perfect crystal. It can be used to predict the vacancy concentration&lt;br /&gt;
at thermal equilibrium through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-E_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an approximation because we have ignored the vibration entropy contribution &lt;br /&gt;
&amp;lt;math&amp;gt;S_v&amp;lt;/math&amp;gt; of the vacancy. The exact expression is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-F_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;F_v = E_v - T S_v&amp;lt;/math&amp;gt; is the vacancy formation free energy. These expressions&lt;br /&gt;
are similar to Boltzmann’s distribution and will be derived in the [[#Equilibrium Vacancy Concentration|Appendix]].&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; be the energy of the perfect crystal with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, and &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; be the&lt;br /&gt;
relaxed potential energy of the (N − 1)-atom system (containing the vacancy).&lt;br /&gt;
The vacancy formation energy is not simply the difference between the two, &#039;&#039;i.e.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \neq E_2 - E_1 &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
because the two systems does not have the same number of atoms.&lt;br /&gt;
we need to make sure we compare two systems of the same number of atoms. &lt;br /&gt;
Besides, in a real crystal, no atom is destroyed when a vacancy forms. Instead, when a&lt;br /&gt;
vacancy forms in a real crystal, the missing atom moves to the external surface of the&lt;br /&gt;
crystal (or to grain boundaries). (See Fig.2(a).) Because we have a very small crystal&lt;br /&gt;
in our simulation, subjected to the periodic boundary condition, there&lt;br /&gt;
is no external surface. Therefore, we need to account for this effect in a different&lt;br /&gt;
way. In the perfect crystal, all atoms contributes equally to the total energy.&lt;br /&gt;
Hence, we expect the energy contribution of (N − 1) atoms in the perfect&lt;br /&gt;
crystal structure to be &amp;lt;math&amp;gt;(N-1)/N \times E_1 &amp;lt;/math&amp;gt;(even though we cannot construct a perfect crystal with (N − 1) atoms in a periodic simulation cell). The vacancy formation energy&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; can be computed from&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - \frac{N-1}{N} E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The cohesive energy of the perfect crystal, &amp;lt;math&amp;gt;E_{coh} = E_1 /N&amp;lt;/math&amp;gt; , is the potential energy&lt;br /&gt;
per atom. Hence the vacancy formation energy can also be expressed as,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - (N-1) E_{coh} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv (E_2 + E_{coh}) - E_{1} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The result for BCC Mo using the FS potential is &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt;2.550 eV&amp;lt;ref&amp;gt;This is consistent with the more accurate tight-binding (TB) model which predicts &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt; 2.46 eV from the reference, M. J. Mehl and D. A. Papaconstantopoulos, “Applications of a tight-binding total-energy method for transition and noble metals: Elastic constants, vacancies, and surfaces of monatomic metals”, Physical Review B &#039;&#039;&#039;54&#039;&#039;&#039; 4519-4530 1996&amp;lt;/ref&amp;gt; which leads to [n] ≈ 1.43 × 10−13 at T = 1000K (kB = 8.621 × 10−5 eV/K).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.2&#039;&#039; Can you tell the different physical meanings between two expressions &lt;br /&gt;
&amp;lt;math&amp;gt;E_2 - \frac{N-1}{N}E_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_2 - E_1&amp;lt;/math&amp;gt;? You can use Fig. 2 for your explanation.&lt;br /&gt;
              &lt;br /&gt;
&#039;&#039;Q.3&#039;&#039; Recompute &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; with larger and smaller simulation boxes. How does&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; depend on the number of atoms in the simulation cell?&lt;br /&gt;
&lt;br /&gt;
[[Image:Movacancy.jpg | frame | center | Fig.1: Vacancy-formed BCC molybdenum crystal. &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[100], \mathbf{c}_2 = 4[010]&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[001]&amp;lt;/math&amp;gt; are the periodicity vectors. The red dotted circle designates&lt;br /&gt;
the missing atom and the atoms around the vacant site are shown in different&lt;br /&gt;
color due to their relatively high energy than the others. ]]&lt;br /&gt;
[[Image:VacancyVSremoving.jpg | frame | center | Fig.2: (a) In a real crystal, the atom that leaves the interior, thus creating&lt;br /&gt;
a vacancy, moves to the surface of the crystal. (b) If we simply take the energy&lt;br /&gt;
difference between &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; (N − 1 atoms) and &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; (N atoms), we are considering&lt;br /&gt;
the process in which the atom leaves the crystal and moves so far away that it&lt;br /&gt;
does not interact with any other atoms in the crystal. This will lead to a much&lt;br /&gt;
higher potential energy and does not predict &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; correctly.]]&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Vacancy Concentration ==&lt;br /&gt;
Here we derive the equilibrium vacancy concentration, Eq. (2), given the formation&lt;br /&gt;
energy of a single vacancy. Consider a crystal with N sites, n of which&lt;br /&gt;
are occupied by vacancies. We can write the Gibbs free energy of the solid as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; G = G_0 + n E_v - T S_c &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;G_0&amp;lt;/math&amp;gt; is the free energy of the perfect crystal (&amp;lt;math&amp;gt;n = 0&amp;lt;/math&amp;gt;). &lt;br /&gt;
Here we have ignored the interaction between the vacancies. This approximation is valid if &amp;lt;math&amp;gt;n \ll N&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;math&amp;gt;S_c&amp;lt;/math&amp;gt; is the conﬁgurational entropy due to the fact that there are &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; diﬀerent ways&lt;br /&gt;
to arrange the n vacancies on N sites.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} S_c &amp;amp;= k_B \ln \Omega = k_B \ln \frac{N!}{(N-n)!n!} \\&lt;br /&gt;
                          &amp;amp;= k_B [N\ln N - (N-n)\ln (N-n) - n\ln n ] \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the last step we have used Stirling’s approximation. At equilibrium, the&lt;br /&gt;
Gibbs free energy &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; reaches minimum, which means &amp;lt;math&amp;gt;\partial \Delta G / \partial n = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
        &lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \frac{\partial \Delta G}{\partial n} &amp;amp;= E_v - T\frac{\partial S_c}{\partial n} \\&lt;br /&gt;
                          &amp;amp;= E_v - T k_B \ln \frac{N-n}{n} \\&lt;br /&gt;
                          &amp;amp;\simeq E_v - T k_B \ln \frac{N}{n} = 0 \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \therefore [n] \equiv \frac{n}{N} = \exp (-\frac{E_v}{k_B T})&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5443</id>
		<title>M04 Energy Minimization of Vacancy</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5443"/>
		<updated>2011-09-13T14:57:44Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Relaxation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 04 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Vacancy Formation Energy by Energy Minimization&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 27 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a Vacancy in a Perfect Crystal ==&lt;br /&gt;
A vacancy is a common point defect in solids. It is an&lt;br /&gt;
empty site (&#039;&#039;i.e.&#039;&#039; a missing atom) in an otherwise prefect crystal structure. Here&lt;br /&gt;
we discuss how to introduce a vacancy in a perfect crystal using MD++ and how&lt;br /&gt;
to compute the vacancy formation energy. For more information, see [[media:VFE.pdf‎ | supplementary document: Vacancy formation energy by MD++ ]].&lt;br /&gt;
Consider the following MD++ input ﬁle, &#039;&#039;&#039;movacancy.script&#039;&#039;&#039;, that creates a vacancy in a perfect BCC Molybdenum&lt;br /&gt;
crystal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/movacancy # specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read in potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic latticeconst = 3.1472 #(A)&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
eval # evaluate the potential of perfect crystal&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Vacancy&lt;br /&gt;
input = [ 1      # number of atoms to be fixed&lt;br /&gt;
          0]     # index of an atom to be fixed&lt;br /&gt;
fixatoms_by_ID   # fix a set of atoms by their indices&lt;br /&gt;
removefixedatoms # remove fixed atoms&lt;br /&gt;
finalcnfile = movac.cn writecn&lt;br /&gt;
eval # evaluate the vacancy-formed crystal&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red   fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600    win_height = 600&lt;br /&gt;
plot_atom_info = 3&lt;br /&gt;
color00 = &amp;quot;orange&amp;quot; color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
color06 = &amp;quot;gray80&amp;quot; color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
plot_color_windows = [ 2             # number of color windows&lt;br /&gt;
                      -10  -6.8   6  # color06 = gray80&lt;br /&gt;
                      -6.7 -6.0   0  # color00 = orange&lt;br /&gt;
                     ]&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can run this script ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs gpp scripts/movacancy.script&lt;br /&gt;
&lt;br /&gt;
First, MD++ creates a 5×5×5 perfect cubic crystal of BCC Mo with edges along&lt;br /&gt;
&amp;lt;100&amp;gt; directions. Then it ﬁxes atom 0 by&lt;br /&gt;
&lt;br /&gt;
    input = [ 1         # number of atoms to be fixed&lt;br /&gt;
              0 ]       # index of an atom to be fixed&lt;br /&gt;
    fixatoms_by_ID&lt;br /&gt;
&lt;br /&gt;
and then removs this atom by the command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.&lt;br /&gt;
The ﬁrst number in the input array speciﬁes the number of atoms to be removed.&lt;br /&gt;
For example, if you would like to remove two atoms, say 3 and 8, you can do so&lt;br /&gt;
by &lt;br /&gt;
&lt;br /&gt;
 input = [ 2            #  number of atoms to be fixed&lt;br /&gt;
           3 8 ]        #  index of atoms to be fixed&lt;br /&gt;
 fixatoms_by_ID         #  fix a set of atoms by their index&lt;br /&gt;
 removefixedatoms       # remove fixed atoms&lt;br /&gt;
&lt;br /&gt;
Sometimes, you may want to remove a speciﬁc atom you see in the graphic&lt;br /&gt;
window. You can obtain the index of this atom by clicking the atom with&lt;br /&gt;
your mouse. Depending on the setting of &#039;&#039;&#039;plot_atom_info&#039;&#039;&#039;, other information is&lt;br /&gt;
also displayed when you click on the atom. If &#039;&#039;&#039;plot_atom_info = 1&#039;&#039;&#039;, the atom&lt;br /&gt;
index number and its scaled coordinates are printed when the atom is clicked.&lt;br /&gt;
If &#039;&#039;&#039;plot_atom_info = 2&#039;&#039;&#039;, the atom index and its real coordinate (in &amp;amp;Aring;) will be&lt;br /&gt;
printed. If &#039;&#039;&#039;plot_atom_info = 3&#039;&#039;&#039;, the atom index and its local energy (in eV)&lt;br /&gt;
will be printed.&lt;br /&gt;
&lt;br /&gt;
The script ﬁle also sets up two color windows (&#039;&#039;&#039;plot_color_windows&#039;&#039;&#039;) to&lt;br /&gt;
display the atoms. Atoms with local energy between -10 eV and -6.8 eV are&lt;br /&gt;
shown in gray and the atoms whose energies lie between -6.7 eV and -6.0 eV are&lt;br /&gt;
shown in orange. This will highlight the atoms near the vacancy because they&lt;br /&gt;
usually have a higher local energy. Click the atoms and you will see the actual&lt;br /&gt;
local energy of these atoms. If you compare&lt;br /&gt;
the potential energy of the perfect structure and the vacancy-formed structure,&lt;br /&gt;
you will know which structure has higher energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.1&#039;&#039; If a single atom, whose index is other than 0, is removed from the same perfect structure, &lt;br /&gt;
do we expect the system to have a different potential energy?&lt;br /&gt;
&lt;br /&gt;
== Relaxation ==&lt;br /&gt;
When an atom is removed from a crystal, we expect the neighboring atoms to&lt;br /&gt;
adjust its positions, &#039;&#039;e.g.&#039;&#039; to move toward the vacant site, in order to lower the potential energy. The relaxed structure can be obtained by an energy minimization&lt;br /&gt;
algorithm, such as [[M04A Conjugate Gradient Method in MD++ | the conjugate gradient (CG) method]]. This can be done by&lt;br /&gt;
the following lines.&lt;br /&gt;
&lt;br /&gt;
 #---------------------------------------------&lt;br /&gt;
 # Conjugate-Gradient relaxation&lt;br /&gt;
 conj_ftol = 1e-7          # tolerance on the residual gradient&lt;br /&gt;
 conj_fevalmax = 1000 # max. number of iterations&lt;br /&gt;
 conj_fixbox = 1           # fix the simulation box&lt;br /&gt;
 relax                     # CG relaxation command&lt;br /&gt;
 finalcnfile = relaxed.cn writecn&lt;br /&gt;
 eval                      # evaluate relaxed structure&lt;br /&gt;
&lt;br /&gt;
Let’s copy the above script and paste it to the &#039;&#039;&#039;movacancy.script&#039;&#039;&#039; right before&lt;br /&gt;
the last command, &#039;&#039;&#039;sleep quit&#039;&#039;&#039;. You will see that the potential energy of the&lt;br /&gt;
simulated system keeps decreasing while the relaxation goes on. &lt;br /&gt;
The potential energy printed by the second &#039;&#039;&#039;eval&#039;&#039;&#039; should be lower than that&lt;br /&gt;
printed by the ﬁrst &#039;&#039;&#039;eval&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are several variables controlling the CG relaxation. &#039;&#039;&#039;conj_ftol&#039;&#039;&#039; is the&lt;br /&gt;
tolerance of the residual gradient and &#039;&#039;&#039;conj_fevalmax&#039;&#039;&#039; is the maximum number&lt;br /&gt;
of calls to the potential function (effectively limiting the number of iterations).&lt;br /&gt;
If &#039;&#039;&#039;conj_fixbox = 1&#039;&#039;&#039;, the shape and volume of simulation cell box is ﬁxed and&lt;br /&gt;
only the scaled coordinates of the atoms can change during the relaxation.&lt;br /&gt;
If &#039;&#039;&#039;conj fixbox = 0&#039;&#039;&#039;, then all 9 components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to change.&lt;br /&gt;
Sometimes, we want to ﬁx some components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix while allowing&lt;br /&gt;
other components to vary. This can be done by specifying the &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039;&lt;br /&gt;
matrix. For example, if&lt;br /&gt;
&lt;br /&gt;
 conj_fixbox = 0&lt;br /&gt;
 conj_fixboxvec = [ 0 1 1&lt;br /&gt;
                    1 0 1&lt;br /&gt;
                    1 1 0 ]&lt;br /&gt;
&lt;br /&gt;
then only the diagonal components of the box matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to relax. &lt;br /&gt;
(The corresponding entries in &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039; are zero).&lt;br /&gt;
&lt;br /&gt;
== Vacancy Formation Energy ==&lt;br /&gt;
The vacancy formation energy &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; is the energy increase that is needed to create a&lt;br /&gt;
vacancy in a perfect crystal. It can be used to predict the vacancy concentration&lt;br /&gt;
at thermal equilibrium through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-E_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an approximation because we have ignored the vibration entropy contribution &lt;br /&gt;
&amp;lt;math&amp;gt;S_v&amp;lt;/math&amp;gt; of the vacancy. The exact expression is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-F_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;F_v = E_v - T S_v&amp;lt;/math&amp;gt; is the vacancy formation free energy. These expressions&lt;br /&gt;
are similar to Boltzmann’s distribution and will be derived in the [[#Equilibrium Vacancy Concentration|Appendix]].&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; be the energy of the perfect crystal with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, and &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; be the&lt;br /&gt;
relaxed potential energy of the (N − 1)-atom system (containing the vacancy).&lt;br /&gt;
The vacancy formation energy is not simply the diﬀerence between the two, &#039;&#039;i.e.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \neq E_2 - E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
because the two systems does not have the same number of atoms.&lt;br /&gt;
we need to make sure we compare two systems of the same number of atoms. &lt;br /&gt;
Besides, in a real crystal, no atom is destroyed when a vacancy forms. Instead, when a&lt;br /&gt;
vacancy forms in a real crystal, the missing atom moves to the external surface of the&lt;br /&gt;
crystal (or to grain boundaries). (See Fig.2(a).) Because we have a very small crystal&lt;br /&gt;
in our simulation, which is subjected to the periodic boundary condition, there&lt;br /&gt;
is no external surface. Therefore, we need to account for this eﬀect in a diﬀerent&lt;br /&gt;
way. In the perfect crystal, all atoms contributes equally to the total energy.&lt;br /&gt;
Therefore, we expect the energy contribution of (N − 1) atoms in the perfect&lt;br /&gt;
crystal structure to be &amp;lt;math&amp;gt;(N-1)/N \times E_1 &amp;lt;/math&amp;gt;(even though we cannot ﬁt a perfect crystal with&lt;br /&gt;
(N − 1) atoms in to a periodic simulation cell). The vacancy formation energy&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; can be computed from&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - \frac{N-1}{N} E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The cohesive energy of the perfect crystal, &amp;lt;math&amp;gt;E_{coh} = E_1 /N&amp;lt;/math&amp;gt; , is the potential energy&lt;br /&gt;
per atom. Hence the vacancy formation energy can also be expressed as,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - (N-1) E_{coh} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The result for BCC Mo using the FS potential is &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt;2.550 eV&amp;lt;ref&amp;gt;This is consistent with the more accurate tight-binding (TB) model which predicts &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt; 2.46 eV from the reference, M. J. Mehl and D. A. Papaconstantopoulos, “Applications of a tight-binding total-energy method for transition and noble metals: Elastic constants, vacancies, and surfaces of monatomic metals”, Physical Review B &#039;&#039;&#039;54&#039;&#039;&#039; 4519-4530 1996&amp;lt;/ref&amp;gt; which leads to [n] ≈ 1.43 × 10−13 at T = 1000K (kB = 8.621 × 10−5 eV/K).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.2&#039;&#039; Can you tell the diﬀerent physical meanings between two expressions &lt;br /&gt;
&amp;lt;math&amp;gt;E_2 - \frac{N-1}{N}E_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_2 - E_1&amp;lt;/math&amp;gt;? You can use Fig. 2 for your explanation.&lt;br /&gt;
              &lt;br /&gt;
&#039;&#039;Q.3&#039;&#039; Recompute &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; with larger and smaller simulation boxes. How does&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; depend on the number of atoms in the simulation cell?&lt;br /&gt;
&lt;br /&gt;
[[Image:Movacancy.jpg | frame | center | Fig.1: Vacancy-formed BCC molybdenum crystal. &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[100], \mathbf{c}_2 = 4[010]&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[001]&amp;lt;/math&amp;gt; are the periodicity vectors. The red dotted circle designates&lt;br /&gt;
the missing atom and the atoms around the vacant site are shown in diﬀerent&lt;br /&gt;
color due to their relatively high energy than the others. ]]&lt;br /&gt;
[[Image:VacancyVSremoving.jpg | frame | center | Fig.2: (a) In a real crystal, the atom that leaves the interior, thus creating&lt;br /&gt;
a vacancy, moves to the surface of the crystal. (b) If we simply take the energy&lt;br /&gt;
diﬀerence between &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; (N − 1 atoms) and &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; (N atoms), we are considering&lt;br /&gt;
the process in which the atom leaves the crystal and moves so far away that it&lt;br /&gt;
does not interact with any other atoms in the crystal. This will lead to a much&lt;br /&gt;
higher potential energy and does not predict &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; correctly.]]&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Vacancy Concentration ==&lt;br /&gt;
Here we derive the equilibrium vacancy concentration, Eq. (2), given the formation&lt;br /&gt;
energy of a single vacancy. Consider a crystal with N sites, n of which&lt;br /&gt;
are occupied by vacancies. We can write the Gibbs free energy of the solid as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; G = G_0 + n E_v - T S_c &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;G_0&amp;lt;/math&amp;gt; is the free energy of the perfect crystal (&amp;lt;math&amp;gt;n = 0&amp;lt;/math&amp;gt;). &lt;br /&gt;
Here we have ignored the interaction between the vacancies. This approximation is valid if &amp;lt;math&amp;gt;n \ll N&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;math&amp;gt;S_c&amp;lt;/math&amp;gt; is the conﬁgurational entropy due to the fact that there are &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; diﬀerent ways&lt;br /&gt;
to arrange the n vacancies on N sites.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} S_c &amp;amp;= k_B \ln \Omega = k_B \ln \frac{N!}{(N-n)!n!} \\&lt;br /&gt;
                          &amp;amp;= k_B [N\ln N - (N-n)\ln (N-n) - n\ln n ] \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the last step we have used Stirling’s approximation. At equilibrium, the&lt;br /&gt;
Gibbs free energy &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; reaches minimum, which means &amp;lt;math&amp;gt;\partial \Delta G / \partial n = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
        &lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \frac{\partial \Delta G}{\partial n} &amp;amp;= E_v - T\frac{\partial S_c}{\partial n} \\&lt;br /&gt;
                          &amp;amp;= E_v - T k_B \ln \frac{N-n}{n} \\&lt;br /&gt;
                          &amp;amp;\simeq E_v - T k_B \ln \frac{N}{n} = 0 \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \therefore [n] \equiv \frac{n}{N} = \exp (-\frac{E_v}{k_B T})&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5442</id>
		<title>M04 Energy Minimization of Vacancy</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M04_Energy_Minimization_of_Vacancy&amp;diff=5442"/>
		<updated>2011-09-13T14:52:45Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Creating a Vacancy in a Perfect Crystal */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 04 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Vacancy Formation Energy by Energy Minimization&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 27 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a Vacancy in a Perfect Crystal ==&lt;br /&gt;
A vacancy is a common point defect in solids. It is an&lt;br /&gt;
empty site (&#039;&#039;i.e.&#039;&#039; a missing atom) in an otherwise prefect crystal structure. Here&lt;br /&gt;
we discuss how to introduce a vacancy in a perfect crystal using MD++ and how&lt;br /&gt;
to compute the vacancy formation energy. For more information, see [[media:VFE.pdf‎ | supplementary document: Vacancy formation energy by MD++ ]].&lt;br /&gt;
Consider the following MD++ input ﬁle, &#039;&#039;&#039;movacancy.script&#039;&#039;&#039;, that creates a vacancy in a perfect BCC Molybdenum&lt;br /&gt;
crystal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/movacancy # specify run directory&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Read in potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
crystalstructure = body-centered-cubic latticeconst = 3.1472 #(A)&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
eval # evaluate the potential of perfect crystal&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Vacancy&lt;br /&gt;
input = [ 1      # number of atoms to be fixed&lt;br /&gt;
          0]     # index of an atom to be fixed&lt;br /&gt;
fixatoms_by_ID   # fix a set of atoms by their indices&lt;br /&gt;
removefixedatoms # remove fixed atoms&lt;br /&gt;
finalcnfile = movac.cn writecn&lt;br /&gt;
eval # evaluate the vacancy-formed crystal&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 0&lt;br /&gt;
atomcolor = blue highlightcolor = purple backgroundcolor = gray&lt;br /&gt;
bondcolor = red   fixatomcolor = yellow&lt;br /&gt;
plotfreq = 10 win_width = 600    win_height = 600&lt;br /&gt;
plot_atom_info = 3&lt;br /&gt;
color00 = &amp;quot;orange&amp;quot; color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
color06 = &amp;quot;gray80&amp;quot; color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
plot_color_windows = [ 2             # number of color windows&lt;br /&gt;
                      -10  -6.8   6  # color06 = gray80&lt;br /&gt;
                      -6.7 -6.0   0  # color00 = orange&lt;br /&gt;
                     ]&lt;br /&gt;
rotateangles = [ 0 0 0 1 ]&lt;br /&gt;
openwin alloccolors rotate saverot plot&lt;br /&gt;
sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can run this script ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs gpp scripts/movacancy.script&lt;br /&gt;
&lt;br /&gt;
First, MD++ creates a 5×5×5 perfect cubic crystal of BCC Mo with edges along&lt;br /&gt;
&amp;lt;100&amp;gt; directions. Then it ﬁxes atom 0 by&lt;br /&gt;
&lt;br /&gt;
    input = [ 1         # number of atoms to be fixed&lt;br /&gt;
              0 ]       # index of an atom to be fixed&lt;br /&gt;
    fixatoms_by_ID&lt;br /&gt;
&lt;br /&gt;
and then removs this atom by the command &#039;&#039;&#039;removefixedatoms&#039;&#039;&#039;.&lt;br /&gt;
The ﬁrst number in the input array speciﬁes the number of atoms to be removed.&lt;br /&gt;
For example, if you would like to remove two atoms, say 3 and 8, you can do so&lt;br /&gt;
by &lt;br /&gt;
&lt;br /&gt;
 input = [ 2            #  number of atoms to be fixed&lt;br /&gt;
           3 8 ]        #  index of atoms to be fixed&lt;br /&gt;
 fixatoms_by_ID         #  fix a set of atoms by their index&lt;br /&gt;
 removefixedatoms       # remove fixed atoms&lt;br /&gt;
&lt;br /&gt;
Sometimes, you may want to remove a speciﬁc atom you see in the graphic&lt;br /&gt;
window. You can obtain the index of this atom by clicking the atom with&lt;br /&gt;
your mouse. Depending on the setting of &#039;&#039;&#039;plot_atom_info&#039;&#039;&#039;, other information is&lt;br /&gt;
also displayed when you click on the atom. If &#039;&#039;&#039;plot_atom_info = 1&#039;&#039;&#039;, the atom&lt;br /&gt;
index number and its scaled coordinates are printed when the atom is clicked.&lt;br /&gt;
If &#039;&#039;&#039;plot_atom_info = 2&#039;&#039;&#039;, the atom index and its real coordinate (in &amp;amp;Aring;) will be&lt;br /&gt;
printed. If &#039;&#039;&#039;plot_atom_info = 3&#039;&#039;&#039;, the atom index and its local energy (in eV)&lt;br /&gt;
will be printed.&lt;br /&gt;
&lt;br /&gt;
The script ﬁle also sets up two color windows (&#039;&#039;&#039;plot_color_windows&#039;&#039;&#039;) to&lt;br /&gt;
display the atoms. Atoms with local energy between -10 eV and -6.8 eV are&lt;br /&gt;
shown in gray and the atoms whose energies lie between -6.7 eV and -6.0 eV are&lt;br /&gt;
shown in orange. This will highlight the atoms near the vacancy because they&lt;br /&gt;
usually have a higher local energy. Click the atoms and you will see the actual&lt;br /&gt;
local energy of these atoms. If you compare&lt;br /&gt;
the potential energy of the perfect structure and the vacancy-formed structure,&lt;br /&gt;
you will know which structure has higher energy.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.1&#039;&#039; If a single atom, whose index is other than 0, is removed from the same perfect structure, &lt;br /&gt;
do we expect the system to have a different potential energy?&lt;br /&gt;
&lt;br /&gt;
== Relaxation ==&lt;br /&gt;
When an atom is removed from a crystal, we expect the neighboring atoms to&lt;br /&gt;
adjust its positions, &#039;&#039;e.g.&#039;&#039; to move toward the vacant site, to lower the poten-&lt;br /&gt;
tial energy. The relaxed structure can be obtained by an energy minimization&lt;br /&gt;
algorithm, such as [[M04A Conjugate Gradient Method in MD++ | the conjugate gradient (CG) method]]. This can be done by&lt;br /&gt;
the following lines.&lt;br /&gt;
&lt;br /&gt;
 #---------------------------------------------&lt;br /&gt;
 # Conjugate-Gradient relaxation&lt;br /&gt;
 conj_ftol = 1e-7          # tolerance on the residual gradient&lt;br /&gt;
 conj_fevalmax = 1000 # max. number of iterations&lt;br /&gt;
 conj_fixbox = 1           # fix the simulation box&lt;br /&gt;
 relax                     # CG relaxation command&lt;br /&gt;
 finalcnfile = relaxed.cn writecn&lt;br /&gt;
 eval                      # evaluate relaxed structure&lt;br /&gt;
&lt;br /&gt;
Let’s copy the above script and paste it to the &#039;&#039;&#039;movacancy.script&#039;&#039;&#039; right before&lt;br /&gt;
the last command, &#039;&#039;&#039;sleep quit&#039;&#039;&#039;. You will watch the potential energy of the&lt;br /&gt;
simulated system keeps decreasing while the relaxation goes on. &lt;br /&gt;
The potential energy printed by the second &#039;&#039;&#039;eval&#039;&#039;&#039; should be lower than that&lt;br /&gt;
printed by the ﬁrst &#039;&#039;&#039;eval&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are several variables controlling the CG relaxation. &#039;&#039;&#039;conj_ftol&#039;&#039;&#039; is the&lt;br /&gt;
tolerance of the residual gradient and &#039;&#039;&#039;conj_fevalmax&#039;&#039;&#039; is the maximum number&lt;br /&gt;
of calls to the potential function (eﬀectively limiting the number of iterations).&lt;br /&gt;
If &#039;&#039;&#039;conj_fixbox = 1&#039;&#039;&#039;, the shape and volume of simulation cell box is ﬁxed and&lt;br /&gt;
only the scaled coordinates of the atoms can change during the relaxation.&lt;br /&gt;
If &#039;&#039;&#039;conj fixbox = 0&#039;&#039;&#039;, then all 9 components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to move.&lt;br /&gt;
Sometimes, we want to ﬁx some components of the &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; matrix while allowing&lt;br /&gt;
other components to move. This can be done by specifying the &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039;&lt;br /&gt;
matrix. For example, if&lt;br /&gt;
&lt;br /&gt;
 conj_fixbox = 0&lt;br /&gt;
 conj_fixboxvec = [ 0 1 1&lt;br /&gt;
                    1 0 1&lt;br /&gt;
                    1 1 0 ]&lt;br /&gt;
&lt;br /&gt;
then only the diagonal components of the box matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; are allowed to relax. &lt;br /&gt;
(The corresponding entries in &#039;&#039;&#039;conj_fixboxvec&#039;&#039;&#039; are zero).&lt;br /&gt;
&lt;br /&gt;
== Vacancy Formation Energy ==&lt;br /&gt;
The vacancy formation energy &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; is the energy increase that is needed to create a&lt;br /&gt;
vacancy in a perfect crystal. It can be used to predict the vacancy concentration&lt;br /&gt;
at thermal equilibrium through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-E_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an approximation because we have ignored the vibration entropy contribution &lt;br /&gt;
&amp;lt;math&amp;gt;S_v&amp;lt;/math&amp;gt; of the vacancy. The exact expression is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; [n] = \exp(-F_v / k_B T) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;F_v = E_v - T S_v&amp;lt;/math&amp;gt; is the vacancy formation free energy. These expressions&lt;br /&gt;
are similar to Boltzmann’s distribution and will be derived in the [[#Equilibrium Vacancy Concentration|Appendix]].&lt;br /&gt;
&lt;br /&gt;
Let &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; be the energy of the perfect crystal with &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; atoms, and &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; be the&lt;br /&gt;
relaxed potential energy of the (N − 1)-atom system (containing the vacancy).&lt;br /&gt;
The vacancy formation energy is not simply the diﬀerence between the two, &#039;&#039;i.e.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \neq E_2 - E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
because the two systems does not have the same number of atoms.&lt;br /&gt;
we need to make sure we compare two systems of the same number of atoms. &lt;br /&gt;
Besides, in a real crystal, no atom is destroyed when a vacancy forms. Instead, when a&lt;br /&gt;
vacancy forms in a real crystal, the missing atom moves to the external surface of the&lt;br /&gt;
crystal (or to grain boundaries). (See Fig.2(a).) Because we have a very small crystal&lt;br /&gt;
in our simulation, which is subjected to the periodic boundary condition, there&lt;br /&gt;
is no external surface. Therefore, we need to account for this eﬀect in a diﬀerent&lt;br /&gt;
way. In the perfect crystal, all atoms contributes equally to the total energy.&lt;br /&gt;
Therefore, we expect the energy contribution of (N − 1) atoms in the perfect&lt;br /&gt;
crystal structure to be &amp;lt;math&amp;gt;(N-1)/N \times E_1 &amp;lt;/math&amp;gt;(even though we cannot ﬁt a perfect crystal with&lt;br /&gt;
(N − 1) atoms in to a periodic simulation cell). The vacancy formation energy&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; can be computed from&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - \frac{N-1}{N} E_1 &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The cohesive energy of the perfect crystal, &amp;lt;math&amp;gt;E_{coh} = E_1 /N&amp;lt;/math&amp;gt; , is the potential energy&lt;br /&gt;
per atom. Hence the vacancy formation energy can also be expressed as,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; E_v \equiv E_2 - (N-1) E_{coh} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The result for BCC Mo using the FS potential is &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt;2.550 eV&amp;lt;ref&amp;gt;This is consistent with the more accurate tight-binding (TB) model which predicts &amp;lt;math&amp;gt;E_v=&amp;lt;/math&amp;gt; 2.46 eV from the reference, M. J. Mehl and D. A. Papaconstantopoulos, “Applications of a tight-binding total-energy method for transition and noble metals: Elastic constants, vacancies, and surfaces of monatomic metals”, Physical Review B &#039;&#039;&#039;54&#039;&#039;&#039; 4519-4530 1996&amp;lt;/ref&amp;gt; which leads to [n] ≈ 1.43 × 10−13 at T = 1000K (kB = 8.621 × 10−5 eV/K).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q.2&#039;&#039; Can you tell the diﬀerent physical meanings between two expressions &lt;br /&gt;
&amp;lt;math&amp;gt;E_2 - \frac{N-1}{N}E_1&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_2 - E_1&amp;lt;/math&amp;gt;? You can use Fig. 2 for your explanation.&lt;br /&gt;
              &lt;br /&gt;
&#039;&#039;Q.3&#039;&#039; Recompute &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; with larger and smaller simulation boxes. How does&lt;br /&gt;
&amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; depend on the number of atoms in the simulation cell?&lt;br /&gt;
&lt;br /&gt;
[[Image:Movacancy.jpg | frame | center | Fig.1: Vacancy-formed BCC molybdenum crystal. &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[100], \mathbf{c}_2 = 4[010]&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;\mathbf{c}_1 = 4[001]&amp;lt;/math&amp;gt; are the periodicity vectors. The red dotted circle designates&lt;br /&gt;
the missing atom and the atoms around the vacant site are shown in diﬀerent&lt;br /&gt;
color due to their relatively high energy than the others. ]]&lt;br /&gt;
[[Image:VacancyVSremoving.jpg | frame | center | Fig.2: (a) In a real crystal, the atom that leaves the interior, thus creating&lt;br /&gt;
a vacancy, moves to the surface of the crystal. (b) If we simply take the energy&lt;br /&gt;
diﬀerence between &amp;lt;math&amp;gt;E_2&amp;lt;/math&amp;gt; (N − 1 atoms) and &amp;lt;math&amp;gt;E_1&amp;lt;/math&amp;gt; (N atoms), we are considering&lt;br /&gt;
the process in which the atom leaves the crystal and moves so far away that it&lt;br /&gt;
does not interact with any other atoms in the crystal. This will lead to a much&lt;br /&gt;
higher potential energy and does not predict &amp;lt;math&amp;gt;E_v&amp;lt;/math&amp;gt; correctly.]]&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Vacancy Concentration ==&lt;br /&gt;
Here we derive the equilibrium vacancy concentration, Eq. (2), given the formation&lt;br /&gt;
energy of a single vacancy. Consider a crystal with N sites, n of which&lt;br /&gt;
are occupied by vacancies. We can write the Gibbs free energy of the solid as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; G = G_0 + n E_v - T S_c &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;G_0&amp;lt;/math&amp;gt; is the free energy of the perfect crystal (&amp;lt;math&amp;gt;n = 0&amp;lt;/math&amp;gt;). &lt;br /&gt;
Here we have ignored the interaction between the vacancies. This approximation is valid if &amp;lt;math&amp;gt;n \ll N&amp;lt;/math&amp;gt;.&lt;br /&gt;
&amp;lt;math&amp;gt;S_c&amp;lt;/math&amp;gt; is the conﬁgurational entropy due to the fact that there are &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; diﬀerent ways&lt;br /&gt;
to arrange the n vacancies on N sites.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} S_c &amp;amp;= k_B \ln \Omega = k_B \ln \frac{N!}{(N-n)!n!} \\&lt;br /&gt;
                          &amp;amp;= k_B [N\ln N - (N-n)\ln (N-n) - n\ln n ] \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the last step we have used Stirling’s approximation. At equilibrium, the&lt;br /&gt;
Gibbs free energy &amp;lt;math&amp;gt;G&amp;lt;/math&amp;gt; reaches minimum, which means &amp;lt;math&amp;gt;\partial \Delta G / \partial n = 0&amp;lt;/math&amp;gt;.&lt;br /&gt;
        &lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{align} \frac{\partial \Delta G}{\partial n} &amp;amp;= E_v - T\frac{\partial S_c}{\partial n} \\&lt;br /&gt;
                          &amp;amp;= E_v - T k_B \ln \frac{N-n}{n} \\&lt;br /&gt;
                          &amp;amp;\simeq E_v - T k_B \ln \frac{N}{n} = 0 \end{align} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \therefore [n] \equiv \frac{n}{N} = \exp (-\frac{E_v}{k_B T})&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5203</id>
		<title>M10 DisregistryAnalysis</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5203"/>
		<updated>2011-05-19T05:57:24Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 10 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Visualize Disregistry Vector&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ May 18 ]], [[2011]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you use &#039;&#039;&#039;ddrij&#039;&#039;&#039; to visualize or analyze disregistry vectors in your simulation results, please cite the following paper:&lt;br /&gt;
&lt;br /&gt;
Keonwook Kang and Wei Cai, Int. J. of Plasticity &#039;&#039;&#039;26&#039;&#039;&#039; (2010) 1387&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compile execution file ==&lt;br /&gt;
&lt;br /&gt;
 $ make ddrij build=R SYS=gpp&lt;br /&gt;
&lt;br /&gt;
== Run example file ==&lt;br /&gt;
&lt;br /&gt;
Identify bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 0&lt;br /&gt;
&lt;br /&gt;
Read/plot bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 1&lt;br /&gt;
&lt;br /&gt;
Read bonds and calculate the disregistry vector&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 2&lt;br /&gt;
&lt;br /&gt;
Plot disregistry vectors&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 3&lt;br /&gt;
 &lt;br /&gt;
[[Image:Testdisreg1.gif | thumb | center | 600px | Fig.1 ]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Testdisreg2.gif | thumb | center | 600px | Fig.2 ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = &amp;quot;runs/test-disreg&amp;quot;&lt;br /&gt;
  MD++ NIC = 200 NNM = 400&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc DotProd {a b} {&lt;br /&gt;
# Calculate dot product of a and b&lt;br /&gt;
    if {[llength $a] &amp;lt; 3 || [llength $b] &amp;lt; 3} {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    scan $b &amp;quot;%f %f %f&amp;quot; bx by bz&lt;br /&gt;
&lt;br /&gt;
    return [format %22.16e [expr $ax*$bx + $ay*$by + $az*$bz]]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc VectorNorm { a } {&lt;br /&gt;
# Calculate |a|.&lt;br /&gt;
    if { [llength $a] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    #scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    set ax [lindex $a 0]; set ay [lindex $a 1]; set az [lindex $a 2];&lt;br /&gt;
&lt;br /&gt;
    set d [format %22.16e [expr sqrt($ax*$ax + $ay*$ay + $az*$az)]]&lt;br /&gt;
    return $d&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc normalize {v} {&lt;br /&gt;
&lt;br /&gt;
    if {[llength $v] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    set vx [lindex $v 0]; set vy [lindex $v 1]; set vz [lindex $v 2]&lt;br /&gt;
&lt;br /&gt;
    #set v2 [format %22.16e [expr $vx*$vx + $vy*$vy + $vz*$vz]]&lt;br /&gt;
    #set v_mag [format %22.16e [expr sqrt($v2)]]&lt;br /&gt;
    set v_mag [VectorNorm $v]&lt;br /&gt;
&lt;br /&gt;
    set ex [format %22.16e [expr $vx/$v_mag]]&lt;br /&gt;
    set ey [format %22.16e [expr $vy/$v_mag]]&lt;br /&gt;
    set ez [format %22.16e [expr $vz/$v_mag]]&lt;br /&gt;
&lt;br /&gt;
    return [list $ex $ey $ez]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc fix_atoms_on_tilted_plane { sx0 sy0 sz0 d } {&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Select atoms to fix for dislocation nucleation&lt;br /&gt;
#&lt;br /&gt;
  set C1 {0  0  1}; set C2 {1 -1  0}; set C3 {1 1  0}&lt;br /&gt;
  #set n  { 1  1 -1}; &lt;br /&gt;
  set n  { 0.85  0.85 -1}; &lt;br /&gt;
&lt;br /&gt;
  set e1 [normalize $C1];  set e2 [normalize $C2];  set e3 [normalize $C3]&lt;br /&gt;
  set nx [DotProd $n $e1]; set ny [DotProd $n $e2]; set nz [DotProd $n $e3]&lt;br /&gt;
  set n [list $nx $ny $nz]; &lt;br /&gt;
  puts &amp;quot;n = ([format %10.6e $nx], [format %10.6e $ny], [format %10.6e $nz])\&lt;br /&gt;
        in unit of a in lab coordinate.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  set NP [MD++_Get NP]&lt;br /&gt;
  set Lx [MD++_Get H_11]; set Ly [MD++_Get H_22]; set Lz [MD++_Get H_33]&lt;br /&gt;
  set x0 [expr $sx0*$Lx]; set y0 [expr $sy0*$Ly]; set z0 [expr $sz0*$Lz];&lt;br /&gt;
&lt;br /&gt;
  set N_fixed 0&lt;br /&gt;
  for { set i 0 } { $i &amp;lt; $NP } { incr i 1 } {&lt;br /&gt;
    set sx [MD++_Get SR( [expr $i*3  ] ) ]&lt;br /&gt;
    set sy [MD++_Get SR( [expr $i*3+1] ) ]&lt;br /&gt;
    set sz [MD++_Get SR( [expr $i*3+2] ) ]&lt;br /&gt;
    set x  [expr $Lx*$sx ]&lt;br /&gt;
    set y  [expr $Ly*$sy ]&lt;br /&gt;
    set z  [expr $Lz*$sz ]&lt;br /&gt;
    #puts &amp;quot;atom ($i) ($x $y $z)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    set ndotx [expr ($x-$x0)*$nx + ($y-$y0)*$ny + ($z-$z0)*$nz]&lt;br /&gt;
    if { [expr abs($ndotx)] &amp;lt;= $d } {&lt;br /&gt;
      MD++ fixed($i) = 1&lt;br /&gt;
      set N_fixed [expr $N_fixed + 1]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  puts &amp;quot;Number of fixed atoms : $N_fixed&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc setup_window { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = [0.3 0.4] bondradius = 0.3 &lt;br /&gt;
  atomcolor0 = SandyBrown atomcolor1 = LightGrey&lt;br /&gt;
  bondcolor = red backgroundcolor = white #gray70&lt;br /&gt;
  fixatomcolor = yellow&lt;br /&gt;
  color00 = &amp;quot;orange&amp;quot;  color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
  color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
  color06 = &amp;quot;gray80&amp;quot;  color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  plot_map_pbc = 1&lt;br /&gt;
  plot_color_axis = 0&lt;br /&gt;
&lt;br /&gt;
  win_width = 1200 win_height = 1000&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 30 -10 0 1.25 ]&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { &lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot&lt;br /&gt;
  #MD++ calcentralsymmetry input = \[ 0 20 100 \] GnuPlotHistogram&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $argc &amp;gt;= 0 &amp;amp;&amp;amp; $argc &amp;lt;= 1 } {&lt;br /&gt;
  set n 0; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 1 &amp;amp;&amp;amp; $argc &amp;lt;=2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m [lindex $argv 2]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;n = $n, m = $m&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# lattice constant of DC Si&lt;br /&gt;
set a_Si 5.431&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# Identify bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # cut-off distance to declare a bond between two atoms&lt;br /&gt;
  # usu. the distance to the 1st neighbor&lt;br /&gt;
  set rc [expr $a_Si*sqrt(3)/4]&lt;br /&gt;
  # Add buffer distance.&lt;br /&gt;
  set rc [expr 1.3*$rc]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
&lt;br /&gt;
  # Read the reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Will be used to determine the bond direction.&lt;br /&gt;
  # If dot(slip_normal,r_{ij}) &amp;lt; 0, then r_{ij} := -r_{ij}.&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  # Specify the region where the diregistry analysis is applied&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \]&lt;br /&gt;
  MD++ input = \[ $rc \] identify_bonds&lt;br /&gt;
&lt;br /&gt;
  # Write bond data: &lt;br /&gt;
  #    [bond.i bond.j bond.center.x bond.center.y bond.center.z bond.type]&lt;br /&gt;
  MD++ finalcnfile = bonds.dat write_bonds&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# Read/Plob bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_bonds&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# Read bonds and calculate the displacement difference (or disregistry) vector ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # Will be used to tag a bond if its |ddrij| &amp;gt; rc &lt;br /&gt;
  set rc  [expr sqrt(2)/2*$a_Si]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  # The deformed configuration &lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/deformed-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  # The reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn&lt;br /&gt;
  MD++ input = $rc calddrij&lt;br /&gt;
&lt;br /&gt;
  # Write disregistry data:&lt;br /&gt;
  #    [ddrij.disreg.x ddrij.disreg.y ddrij.disreg.z ddrij.norm ddrij.tag]&lt;br /&gt;
  MD++ finalcnfile = ddrij.dat write_ddrij&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 3 } {&lt;br /&gt;
# Read/Plot ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
  MD++ incnfile = ddrij.dat read_ddrij&lt;br /&gt;
&lt;br /&gt;
  fix_atoms_on_tilted_plane 0.0 0.0 -0.095 8 &lt;br /&gt;
  MD++ reversefixedatoms removefixedatoms&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  MD++ plot_limits = \[ 1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_ddrij&lt;br /&gt;
&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
  puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
  MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5202</id>
		<title>M10 DisregistryAnalysis</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5202"/>
		<updated>2011-05-19T05:53:34Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Run example file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 10 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Visualize Disregistry Vector&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ May 18 ]], [[2011]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you use &#039;&#039;&#039;ddrij&#039;&#039;&#039; to visualize or analyze disregistry vectors in your simulation results, you are asked to cite the following paper:&lt;br /&gt;
&lt;br /&gt;
Keonwook Kang and Wei Cai, Int. J. of Plasticity &#039;&#039;&#039;26&#039;&#039;&#039; (2010) 1387&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compile execution file ==&lt;br /&gt;
&lt;br /&gt;
 $ make ddrij build=R SYS=gpp&lt;br /&gt;
&lt;br /&gt;
== Run example file ==&lt;br /&gt;
&lt;br /&gt;
Identify bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 0&lt;br /&gt;
&lt;br /&gt;
Read/plot bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 1&lt;br /&gt;
&lt;br /&gt;
Read bonds and calculate the disregistry vector&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 2&lt;br /&gt;
&lt;br /&gt;
Plot disregistry vectors&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 3&lt;br /&gt;
 &lt;br /&gt;
[[Image:Testdisreg1.gif | thumb | center | 600px | Fig.1 ]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Testdisreg2.gif | thumb | center | 600px | Fig.2 ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = &amp;quot;runs/test-disreg&amp;quot;&lt;br /&gt;
  MD++ NIC = 200 NNM = 400&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc DotProd {a b} {&lt;br /&gt;
# Calculate dot product of a and b&lt;br /&gt;
    if {[llength $a] &amp;lt; 3 || [llength $b] &amp;lt; 3} {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    scan $b &amp;quot;%f %f %f&amp;quot; bx by bz&lt;br /&gt;
&lt;br /&gt;
    return [format %22.16e [expr $ax*$bx + $ay*$by + $az*$bz]]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc VectorNorm { a } {&lt;br /&gt;
# Calculate |a|.&lt;br /&gt;
    if { [llength $a] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    #scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    set ax [lindex $a 0]; set ay [lindex $a 1]; set az [lindex $a 2];&lt;br /&gt;
&lt;br /&gt;
    set d [format %22.16e [expr sqrt($ax*$ax + $ay*$ay + $az*$az)]]&lt;br /&gt;
    return $d&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc normalize {v} {&lt;br /&gt;
&lt;br /&gt;
    if {[llength $v] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    set vx [lindex $v 0]; set vy [lindex $v 1]; set vz [lindex $v 2]&lt;br /&gt;
&lt;br /&gt;
    #set v2 [format %22.16e [expr $vx*$vx + $vy*$vy + $vz*$vz]]&lt;br /&gt;
    #set v_mag [format %22.16e [expr sqrt($v2)]]&lt;br /&gt;
    set v_mag [VectorNorm $v]&lt;br /&gt;
&lt;br /&gt;
    set ex [format %22.16e [expr $vx/$v_mag]]&lt;br /&gt;
    set ey [format %22.16e [expr $vy/$v_mag]]&lt;br /&gt;
    set ez [format %22.16e [expr $vz/$v_mag]]&lt;br /&gt;
&lt;br /&gt;
    return [list $ex $ey $ez]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc fix_atoms_on_tilted_plane { sx0 sy0 sz0 d } {&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Select atoms to fix for dislocation nucleation&lt;br /&gt;
#&lt;br /&gt;
  set C1 {0  0  1}; set C2 {1 -1  0}; set C3 {1 1  0}&lt;br /&gt;
  #set n  { 1  1 -1}; &lt;br /&gt;
  set n  { 0.85  0.85 -1}; &lt;br /&gt;
&lt;br /&gt;
  set e1 [normalize $C1];  set e2 [normalize $C2];  set e3 [normalize $C3]&lt;br /&gt;
  set nx [DotProd $n $e1]; set ny [DotProd $n $e2]; set nz [DotProd $n $e3]&lt;br /&gt;
  set n [list $nx $ny $nz]; &lt;br /&gt;
  puts &amp;quot;n = ([format %10.6e $nx], [format %10.6e $ny], [format %10.6e $nz])\&lt;br /&gt;
        in unit of a in lab coordinate.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  set NP [MD++_Get NP]&lt;br /&gt;
  set Lx [MD++_Get H_11]; set Ly [MD++_Get H_22]; set Lz [MD++_Get H_33]&lt;br /&gt;
  set x0 [expr $sx0*$Lx]; set y0 [expr $sy0*$Ly]; set z0 [expr $sz0*$Lz];&lt;br /&gt;
&lt;br /&gt;
  set N_fixed 0&lt;br /&gt;
  for { set i 0 } { $i &amp;lt; $NP } { incr i 1 } {&lt;br /&gt;
    set sx [MD++_Get SR( [expr $i*3  ] ) ]&lt;br /&gt;
    set sy [MD++_Get SR( [expr $i*3+1] ) ]&lt;br /&gt;
    set sz [MD++_Get SR( [expr $i*3+2] ) ]&lt;br /&gt;
    set x  [expr $Lx*$sx ]&lt;br /&gt;
    set y  [expr $Ly*$sy ]&lt;br /&gt;
    set z  [expr $Lz*$sz ]&lt;br /&gt;
    #puts &amp;quot;atom ($i) ($x $y $z)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    set ndotx [expr ($x-$x0)*$nx + ($y-$y0)*$ny + ($z-$z0)*$nz]&lt;br /&gt;
    if { [expr abs($ndotx)] &amp;lt;= $d } {&lt;br /&gt;
      MD++ fixed($i) = 1&lt;br /&gt;
      set N_fixed [expr $N_fixed + 1]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  puts &amp;quot;Number of fixed atoms : $N_fixed&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc setup_window { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = [0.3 0.4] bondradius = 0.3 &lt;br /&gt;
  atomcolor0 = SandyBrown atomcolor1 = LightGrey&lt;br /&gt;
  bondcolor = red backgroundcolor = white #gray70&lt;br /&gt;
  fixatomcolor = yellow&lt;br /&gt;
  color00 = &amp;quot;orange&amp;quot;  color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
  color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
  color06 = &amp;quot;gray80&amp;quot;  color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  plot_map_pbc = 1&lt;br /&gt;
  plot_color_axis = 0&lt;br /&gt;
&lt;br /&gt;
  win_width = 1200 win_height = 1000&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 30 -10 0 1.25 ]&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { &lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot&lt;br /&gt;
  #MD++ calcentralsymmetry input = \[ 0 20 100 \] GnuPlotHistogram&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $argc &amp;gt;= 0 &amp;amp;&amp;amp; $argc &amp;lt;= 1 } {&lt;br /&gt;
  set n 0; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 1 &amp;amp;&amp;amp; $argc &amp;lt;=2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m [lindex $argv 2]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;n = $n, m = $m&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# lattice constant of DC Si&lt;br /&gt;
set a_Si 5.431&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# Identify bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # cut-off distance to declare a bond between two atoms&lt;br /&gt;
  # usu. the distance to the 1st neighbor&lt;br /&gt;
  set rc [expr $a_Si*sqrt(3)/4]&lt;br /&gt;
  # Add buffer distance.&lt;br /&gt;
  set rc [expr 1.3*$rc]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
&lt;br /&gt;
  # Read the reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Will be used to determine the bond direction.&lt;br /&gt;
  # If dot(slip_normal,r_{ij}) &amp;lt; 0, then r_{ij} := -r_{ij}.&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  # Specify the region where the diregistry analysis is applied&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \]&lt;br /&gt;
  MD++ input = \[ $rc \] identify_bonds&lt;br /&gt;
&lt;br /&gt;
  # Write bond data: &lt;br /&gt;
  #    [bond.i bond.j bond.center.x bond.center.y bond.center.z bond.type]&lt;br /&gt;
  MD++ finalcnfile = bonds.dat write_bonds&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# Read/Plob bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_bonds&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# Read bonds and calculate the displacement difference (or disregistry) vector ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # Will be used to tag a bond if its |ddrij| &amp;gt; rc &lt;br /&gt;
  set rc  [expr sqrt(2)/2*$a_Si]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  # The deformed configuration &lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/deformed-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  # The reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn&lt;br /&gt;
  MD++ input = $rc calddrij&lt;br /&gt;
&lt;br /&gt;
  # Write disregistry data:&lt;br /&gt;
  #    [ddrij.disreg.x ddrij.disreg.y ddrij.disreg.z ddrij.norm ddrij.tag]&lt;br /&gt;
  MD++ finalcnfile = ddrij.dat write_ddrij&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 3 } {&lt;br /&gt;
# Read/Plot ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
  MD++ incnfile = ddrij.dat read_ddrij&lt;br /&gt;
&lt;br /&gt;
  fix_atoms_on_tilted_plane 0.0 0.0 -0.095 8 &lt;br /&gt;
  MD++ reversefixedatoms removefixedatoms&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  MD++ plot_limits = \[ 1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_ddrij&lt;br /&gt;
&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
  puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
  MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=File:Testdisreg2.gif&amp;diff=5201</id>
		<title>File:Testdisreg2.gif</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=File:Testdisreg2.gif&amp;diff=5201"/>
		<updated>2011-05-19T05:45:27Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=File:Testdisreg1.gif&amp;diff=5200</id>
		<title>File:Testdisreg1.gif</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=File:Testdisreg1.gif&amp;diff=5200"/>
		<updated>2011-05-19T05:45:07Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5199</id>
		<title>M10 DisregistryAnalysis</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_DisregistryAnalysis&amp;diff=5199"/>
		<updated>2011-05-19T05:44:37Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: Created page with &amp;#039;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 10 for MD++ &amp;lt;/FONT&amp;gt;  &amp;lt;BR&amp;gt; Visualize Disregistry Vector&amp;lt;/H1&amp;gt; &amp;lt;DIV&amp;gt;  &amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt; &amp;lt;/DI…&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 10 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Visualize Disregistry Vector&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ May 18 ]], [[2011]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you use &#039;&#039;&#039;ddrij&#039;&#039;&#039; to visualize or analyze disregistry vectors in your simulation results, you are asked to cite the following paper:&lt;br /&gt;
&lt;br /&gt;
Keonwook Kang and Wei Cai, Int. J. of Plasticity &#039;&#039;&#039;26&#039;&#039;&#039; (2010) 1387&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compile execution file ==&lt;br /&gt;
&lt;br /&gt;
 $ make ddrij build=R SYS=gpp&lt;br /&gt;
&lt;br /&gt;
== Run example file ==&lt;br /&gt;
&lt;br /&gt;
Identify bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 0&lt;br /&gt;
&lt;br /&gt;
Read/plot bonds&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 1&lt;br /&gt;
&lt;br /&gt;
Read bonds and calculate the disregistry vector&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 2&lt;br /&gt;
&lt;br /&gt;
Plot disregistry vectors&lt;br /&gt;
 $ bin/ddrij_cpp ./scripts/Examples/example09-disreg.tcl 3&lt;br /&gt;
 &lt;br /&gt;
[[Image:Testdisreg1.gif | frame | center | Fig.1 ]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Testdisreg2.gif | frame | center | Fig.2 ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
source &amp;quot;scripts/Examples/Tcl/startup.tcl&amp;quot;&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
  MD++ setoverwrite&lt;br /&gt;
  MD++ dirname = &amp;quot;runs/test-disreg&amp;quot;&lt;br /&gt;
  MD++ NIC = 200 NNM = 400&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc DotProd {a b} {&lt;br /&gt;
# Calculate dot product of a and b&lt;br /&gt;
    if {[llength $a] &amp;lt; 3 || [llength $b] &amp;lt; 3} {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    scan $b &amp;quot;%f %f %f&amp;quot; bx by bz&lt;br /&gt;
&lt;br /&gt;
    return [format %22.16e [expr $ax*$bx + $ay*$by + $az*$bz]]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc VectorNorm { a } {&lt;br /&gt;
# Calculate |a|.&lt;br /&gt;
    if { [llength $a] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    #scan $a &amp;quot;%f %f %f&amp;quot; ax ay az&lt;br /&gt;
    set ax [lindex $a 0]; set ay [lindex $a 1]; set az [lindex $a 2];&lt;br /&gt;
&lt;br /&gt;
    set d [format %22.16e [expr sqrt($ax*$ax + $ay*$ay + $az*$az)]]&lt;br /&gt;
    return $d&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc normalize {v} {&lt;br /&gt;
&lt;br /&gt;
    if {[llength $v] &amp;lt; 3 } {&lt;br /&gt;
        return -code error &amp;quot;Vectors must have 3 components!&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    set vx [lindex $v 0]; set vy [lindex $v 1]; set vz [lindex $v 2]&lt;br /&gt;
&lt;br /&gt;
    #set v2 [format %22.16e [expr $vx*$vx + $vy*$vy + $vz*$vz]]&lt;br /&gt;
    #set v_mag [format %22.16e [expr sqrt($v2)]]&lt;br /&gt;
    set v_mag [VectorNorm $v]&lt;br /&gt;
&lt;br /&gt;
    set ex [format %22.16e [expr $vx/$v_mag]]&lt;br /&gt;
    set ey [format %22.16e [expr $vy/$v_mag]]&lt;br /&gt;
    set ez [format %22.16e [expr $vz/$v_mag]]&lt;br /&gt;
&lt;br /&gt;
    return [list $ex $ey $ez]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc fix_atoms_on_tilted_plane { sx0 sy0 sz0 d } {&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Select atoms to fix for dislocation nucleation&lt;br /&gt;
#&lt;br /&gt;
  set C1 {0  0  1}; set C2 {1 -1  0}; set C3 {1 1  0}&lt;br /&gt;
  #set n  { 1  1 -1}; &lt;br /&gt;
  set n  { 0.85  0.85 -1}; &lt;br /&gt;
&lt;br /&gt;
  set e1 [normalize $C1];  set e2 [normalize $C2];  set e3 [normalize $C3]&lt;br /&gt;
  set nx [DotProd $n $e1]; set ny [DotProd $n $e2]; set nz [DotProd $n $e3]&lt;br /&gt;
  set n [list $nx $ny $nz]; &lt;br /&gt;
  puts &amp;quot;n = ([format %10.6e $nx], [format %10.6e $ny], [format %10.6e $nz])\&lt;br /&gt;
        in unit of a in lab coordinate.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  set NP [MD++_Get NP]&lt;br /&gt;
  set Lx [MD++_Get H_11]; set Ly [MD++_Get H_22]; set Lz [MD++_Get H_33]&lt;br /&gt;
  set x0 [expr $sx0*$Lx]; set y0 [expr $sy0*$Ly]; set z0 [expr $sz0*$Lz];&lt;br /&gt;
&lt;br /&gt;
  set N_fixed 0&lt;br /&gt;
  for { set i 0 } { $i &amp;lt; $NP } { incr i 1 } {&lt;br /&gt;
    set sx [MD++_Get SR( [expr $i*3  ] ) ]&lt;br /&gt;
    set sy [MD++_Get SR( [expr $i*3+1] ) ]&lt;br /&gt;
    set sz [MD++_Get SR( [expr $i*3+2] ) ]&lt;br /&gt;
    set x  [expr $Lx*$sx ]&lt;br /&gt;
    set y  [expr $Ly*$sy ]&lt;br /&gt;
    set z  [expr $Lz*$sz ]&lt;br /&gt;
    #puts &amp;quot;atom ($i) ($x $y $z)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    set ndotx [expr ($x-$x0)*$nx + ($y-$y0)*$ny + ($z-$z0)*$nz]&lt;br /&gt;
    if { [expr abs($ndotx)] &amp;lt;= $d } {&lt;br /&gt;
      MD++ fixed($i) = 1&lt;br /&gt;
      set N_fixed [expr $N_fixed + 1]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  puts &amp;quot;Number of fixed atoms : $N_fixed&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
proc setup_window { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
  atomradius = [0.3 0.4] bondradius = 0.3 &lt;br /&gt;
  atomcolor0 = SandyBrown atomcolor1 = LightGrey&lt;br /&gt;
  bondcolor = red backgroundcolor = white #gray70&lt;br /&gt;
  fixatomcolor = yellow&lt;br /&gt;
  color00 = &amp;quot;orange&amp;quot;  color01 = &amp;quot;purple&amp;quot; color02 = &amp;quot;green&amp;quot;&lt;br /&gt;
  color03 = &amp;quot;magenta&amp;quot; color04 = &amp;quot;cyan&amp;quot;   color05 = &amp;quot;purple&amp;quot;&lt;br /&gt;
  color06 = &amp;quot;gray80&amp;quot;  color07 = &amp;quot;white&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  plot_map_pbc = 1&lt;br /&gt;
  plot_color_axis = 0&lt;br /&gt;
&lt;br /&gt;
  win_width = 1200 win_height = 1000&lt;br /&gt;
  plotfreq = 10 rotateangles = [ 30 -10 0 1.25 ]&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
proc openwindow { } { &lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot&lt;br /&gt;
  #MD++ calcentralsymmetry input = \[ 0 20 100 \] GnuPlotHistogram&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
if { $argc == 0 } {&lt;br /&gt;
  set status 0&lt;br /&gt;
} elseif { $argc &amp;gt; 0 } {&lt;br /&gt;
  set status [lindex $argv 0]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;status = $status&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if { $argc &amp;gt;= 0 &amp;amp;&amp;amp; $argc &amp;lt;= 1 } {&lt;br /&gt;
  set n 0; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 1 &amp;amp;&amp;amp; $argc &amp;lt;=2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m 0&lt;br /&gt;
} elseif { $argc &amp;gt; 2 } {&lt;br /&gt;
  set n [lindex $argv 1]; set m [lindex $argv 2]&lt;br /&gt;
}&lt;br /&gt;
puts &amp;quot;n = $n, m = $m&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# lattice constant of DC Si&lt;br /&gt;
set a_Si 5.431&lt;br /&gt;
&lt;br /&gt;
if { $status == 0 } {&lt;br /&gt;
# Identify bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # cut-off distance to declare a bond between two atoms&lt;br /&gt;
  # usu. the distance to the 1st neighbor&lt;br /&gt;
  set rc [expr $a_Si*sqrt(3)/4]&lt;br /&gt;
  # Add buffer distance.&lt;br /&gt;
  set rc [expr 1.3*$rc]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
&lt;br /&gt;
  # Read the reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Will be used to determine the bond direction.&lt;br /&gt;
  # If dot(slip_normal,r_{ij}) &amp;lt; 0, then r_{ij} := -r_{ij}.&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  # Specify the region where the diregistry analysis is applied&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \]&lt;br /&gt;
  MD++ input = \[ $rc \] identify_bonds&lt;br /&gt;
&lt;br /&gt;
  # Write bond data: &lt;br /&gt;
  #    [bond.i bond.j bond.center.x bond.center.y bond.center.z bond.type]&lt;br /&gt;
  MD++ finalcnfile = bonds.dat write_bonds&lt;br /&gt;
&lt;br /&gt;
  openwindow&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 1 } {&lt;br /&gt;
# Read/Plob bonds&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval &lt;br /&gt;
&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ plot_limits = \[1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_bonds&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 2 } {&lt;br /&gt;
# Read bonds and calculate the displacement difference (or disregistry) vector ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # Will be used to tag a bond if its |ddrij| &amp;gt; rc &lt;br /&gt;
  set rc  [expr sqrt(2)/2*$a_Si]&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  # Read bond data&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
&lt;br /&gt;
  # The deformed configuration &lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/deformed-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  # The reference configuration&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn&lt;br /&gt;
  MD++ input = $rc calddrij&lt;br /&gt;
&lt;br /&gt;
  # Write disregistry data:&lt;br /&gt;
  #    [ddrij.disreg.x ddrij.disreg.y ddrij.disreg.z ddrij.norm ddrij.tag]&lt;br /&gt;
  MD++ finalcnfile = ddrij.dat write_ddrij&lt;br /&gt;
  MD++ quit&lt;br /&gt;
&lt;br /&gt;
} elseif { $status == 3 } {&lt;br /&gt;
# Read/Plot ddrij&lt;br /&gt;
  MD++ setnolog&lt;br /&gt;
  initmd &amp;quot; &amp;quot;&lt;br /&gt;
&lt;br /&gt;
  MD++ RLIST = 4.1490&lt;br /&gt;
  MD++ incnfile = ../../structures/Examples/ref-testdisreg.cn readcn eval&lt;br /&gt;
&lt;br /&gt;
  MD++ incnfile = bonds.dat read_bonds&lt;br /&gt;
  MD++ incnfile = ddrij.dat read_ddrij&lt;br /&gt;
&lt;br /&gt;
  fix_atoms_on_tilted_plane 0.0 0.0 -0.095 8 &lt;br /&gt;
  MD++ reversefixedatoms removefixedatoms&lt;br /&gt;
&lt;br /&gt;
  setup_window&lt;br /&gt;
  MD++ slip_normal = \[ -1.0  0.0  1.414214 \]&lt;br /&gt;
  MD++ plot_limits = \[ 1 -1 1 -1 1 -0.150 -0.031 \] &lt;br /&gt;
  MD++ openwin alloccolors rotate saverot eval plot_ddrij&lt;br /&gt;
&lt;br /&gt;
  MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
  puts &amp;quot;unknown status = $status&amp;quot;&lt;br /&gt;
  MD++ quit&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=MD%2B%2B_Manuals&amp;diff=5198</id>
		<title>MD++ Manuals</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=MD%2B%2B_Manuals&amp;diff=5198"/>
		<updated>2011-05-19T05:26:53Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H4&amp;gt;Manuals&amp;lt;/H4&amp;gt;&lt;br /&gt;
&amp;lt;UL&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M01 Introduction to MD++]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M02 Making a Perfect Crystal]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M03 Equilibrium Lattice Constant and Bulk Modulus]] &lt;br /&gt;
&amp;lt;LI&amp;gt;[[M04 Energy Minimization of Vacancy]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M05 Finite Temperature Simulation]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M06 Visualization ]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M07 Computing Elastic Constants | M07 Computing Elastic Constants at &#039;&#039;T&#039;&#039; = 0]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M08 MD++ Powered by Tcl Language]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M09 Computing Ideal Strength]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M10 DisregistryAnalysis | M10 Visualize Disregistry vector]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[http://micro.stanford.edu/~caiwei/me346/  Molecular Simulations Lecture Notes]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Comprehensive Nuclear Materials MD Case Studies | Case Studies of Crystals and Dislocations]]&lt;br /&gt;
&amp;lt;/UL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;H4&amp;gt;Technical details&amp;lt;/H4&amp;gt;&lt;br /&gt;
&amp;lt;UL&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;[[ MD++ QnA | MD++ FAQs]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[MD Potential Files]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Making Amimations Using a MD++ Script File | Making Movies in MD++]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Output File Formats in MD++]]&lt;br /&gt;
&amp;lt;/UL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;H4&amp;gt;Advanced topics&amp;lt;/H4&amp;gt;&lt;br /&gt;
&amp;lt;UL&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;[[media:ewald_notes.pdf | Notes on Ewald Summation]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Computing Melting Point by Free Energy Method]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M04A Conjugate Gradient Method in MD++ | Conjugate Gradient Methods in MD++]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Computing Elastic Constants 2 | Computing Elastic Constants at Finite Temperature]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[M10 Angular momentum is conserved or not | Conservation of Angular Momentum]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[Use MEAM in MD++]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[media:Day1_Ising_Demo.pdf | Monte Carlo Simulation of 2D Ising Model]]&lt;br /&gt;
&amp;lt;/UL&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5168</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5168"/>
		<updated>2011-03-23T22:21:04Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Publications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang==&lt;br /&gt;
&lt;br /&gt;
Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, in press (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, &#039;&#039;&#039;64&#039;&#039;&#039;, 1043 (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039;, 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039;, 2169 (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039;, 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
:Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Work: (505)665-2380 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Research_Meeting_Schedule&amp;diff=5164</id>
		<title>Research Meeting Schedule</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Research_Meeting_Schedule&amp;diff=5164"/>
		<updated>2011-03-23T05:01:11Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Spring 2010 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Spring 2010===&lt;br /&gt;
&lt;br /&gt;
Prof. Wei Cai&#039;s weekly schedule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center;&amp;quot;&lt;br /&gt;
!width=&amp;quot;160pt&amp;quot; | Time &lt;br /&gt;
!width=&amp;quot;220pt&amp;quot; | Monday &lt;br /&gt;
!width=&amp;quot;200pt&amp;quot; | Tuesday &lt;br /&gt;
!width=&amp;quot;250pt&amp;quot; | Wednesday &lt;br /&gt;
!width=&amp;quot;250pt&amp;quot; | Thursday &lt;br /&gt;
!width=&amp;quot;250pt&amp;quot; | Friday&lt;br /&gt;
|-&lt;br /&gt;
|9:00-10:00  || bgcolor=&amp;quot;lightgrey&amp;quot; | Hark, Eunseok, Prof Prinz b.w. &lt;br /&gt;
| &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|10:00-10:30|| lecture prep || &#039;&#039;work&#039;&#039; || lecture prep &lt;br /&gt;
| &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
|10:30-11:00|| lecture prep || &#039;&#039;work&#039;&#039;&lt;br /&gt;
| lecture prep || Seunghwa  || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|11:00-11:30|| rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;ME340A&#039;&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;ME340A&#039;&#039;&#039;&lt;br /&gt;
| Seokwoo&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | (ME340A) &lt;br /&gt;
|-&lt;br /&gt;
|11:30-12:00 || &#039;&#039;work&#039;&#039; || Hark b.w.&lt;br /&gt;
|-&lt;br /&gt;
|12:30-1:15 || colspan=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot; | lunch break&lt;br /&gt;
|-&lt;br /&gt;
|1:30-2:05 ||  &#039;&#039;&#039;Group Meeting&#039;&#039;&#039; || Billy (1:20-1:55)&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; |  &#039;&#039;&#039;ME340A office hour&#039;&#039;&#039; (1-2:30)&lt;br /&gt;
|  &#039;&#039;work&#039;&#039; ||  &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|2:10-2:45 || bgcolor=&amp;quot;lightgrey&amp;quot; | Jie (Prof. Barnett b.w.) &lt;br /&gt;
| &#039;&#039;&#039;GCC Committee&#039;&#039;&#039;   (2-3pm) ||                     || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|2:50-3:25 ||         || Haneesh (3:10)  || William K. ||        || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|3:30-4:00 || colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot; | coffee break &lt;br /&gt;
| bgcolor=&amp;quot;lightgrey&amp;quot; | McIntyre b.w.&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightblue&amp;quot; | coffee break &lt;br /&gt;
|-&lt;br /&gt;
|4:00-4:35 || Jie b.w. || ILL RYU || &#039;&#039;work&#039;&#039; || rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;MC seminar&#039;&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|4:40-6:00 || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Meetings to sign-up&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | &lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | &lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | Seminar speaker       &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5163</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5163"/>
		<updated>2011-03-23T04:51:14Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Keonwook Kang */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang==&lt;br /&gt;
&lt;br /&gt;
Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, in press (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, in press (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039;, 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039;, 2169, (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039;, 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
:Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Work: (505)665-2380 &amp;lt;br/&amp;gt;&lt;br /&gt;
:Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5162</id>
		<title>Keonwook Kang</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Keonwook_Kang&amp;diff=5162"/>
		<updated>2011-03-23T04:47:23Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Keonwook Kang */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Keonwook Kang==&lt;br /&gt;
&lt;br /&gt;
Postdoctoral Researcher at Los Alamos National Lab&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Education====&lt;br /&gt;
*07/2004 - 01/2011: Ph.D. Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
:: Dissertation Title: &lt;br /&gt;
:::ATOMISTIC MODELLING OF FRACTURE MECHANISMS IN SEMICONDUCTOR NANOWIRES UNDER TENSION&lt;br /&gt;
*09/2002 - 06/2004: M.S.  Mechanical Engineering,  Stanford University&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Research Interests====&lt;br /&gt;
* To understand material deformation mechanisms at atomic level&lt;br /&gt;
* To simulate material defects and study the effect of defects on the material properties.&lt;br /&gt;
* To predict mechanical/material properties of nano-structures &lt;br /&gt;
&lt;br /&gt;
====Publications====&lt;br /&gt;
*S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Entropic Effect on the Rate of Dislocation Nucleation&amp;quot;, &#039;&#039;Proc. Natl. Acad. Sci.&#039;&#039;, in press (2011)&lt;br /&gt;
*S. Aubry, S. Ryu, &#039;&#039;&#039;K. Kang&#039;&#039;&#039; and Wei Cai, &amp;quot;Energy Barrier for Homogeneous Dislocation Nucleation: Comparing Atomistic and Continuum Models&amp;quot;, &#039;&#039;Scripta Materialia&#039;&#039;, in press (2011)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Size and Temperature Effects on Brittle and Ductile Fracture of Silicon Nanowires&amp;quot;, &#039;&#039;International Journal of Plasticity&#039;&#039;, &#039;&#039;&#039;26&#039;&#039;&#039;, 1387 (2010)&lt;br /&gt;
*&#039;&#039;&#039;K. Kang&#039;&#039;&#039;, Wei Cai, &amp;quot;Brittle and Ductile Fracture of Semiconductor Nanowires – Molecular Dynamics Simulations&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039;, 2169, (2007)&lt;br /&gt;
*V. V. Bulatov, Wei Cai, R. Baran, and &#039;&#039;&#039;K. Kang&#039;&#039;&#039;, &amp;quot;Geometric aspects of the ideal shear resistance in simple crystal lattices&amp;quot;, &#039;&#039;Philosophical Magazine&#039;&#039;, &#039;&#039;&#039;86&#039;&#039;&#039;, 3847 (2006)&lt;br /&gt;
*W. R. Hwang, &#039;&#039;&#039;K. W. Kang&#039;&#039;&#039;, and T. H. Kwon, &amp;quot;Dynamical Systems in Pin Mixers of Single-Screw Extruders&amp;quot;, &#039;&#039;AiChE. J&#039;&#039; &#039;&#039;&#039;50&#039;&#039;&#039; 1372-1385 (2004)&lt;br /&gt;
&lt;br /&gt;
====Contact Information====&lt;br /&gt;
Office: TA03 MSL bldg. Rm. A207, LANL, Los Alamos, NM 87545 &amp;lt;br/&amp;gt;&lt;br /&gt;
Work: (505)665-2380 &amp;lt;br/&amp;gt;&lt;br /&gt;
Email: &amp;lt;math&amp;gt;\mathrm{kwkang\;at\;lanl\;dot\;gov}&amp;lt;/math&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5064</id>
		<title>M05 Finite Temperature Simulation</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5064"/>
		<updated>2011-01-20T17:26:04Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Constant Stress (N\sigmaH) Ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 05 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Molecular Dynamics Simulations&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[First written, [ Jan 19 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[Last Modified, [ Apr 13 ]], [[2008]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The case studies described in Manuals 02-04 only deal with atomic positions as degrees of freedom.  For example, in Manual 02, we learned how to create a perfect crystal by MD++ command &#039;&#039;&#039;makecrystal&#039;&#039;&#039;.  In Manual 03, we varied the size of the perfect crystal to find the equilibrium lattice constants.  In Manual 04, we introduced a vacancy to the perfect crystal and let the atomic positions relax to a local energy minimum.  In this manual, we will learn how to perform finite temperature, Molecular Dynamics (MD) simulations.  For this purpose, we will need to deal with atomic velocities as degrees of freedom, as well as a number of control variables, such as integrator type, time step, and output controls.  We will learn to specify the simulation ensembles from different choices: microcanonical (NVE), canonical (NVT),&lt;br /&gt;
isoenthalpic-isobaric (NPH) and constant pressure/temperature (NPT) ensembles.  Different quantities are conserved or controlled in different ensembles.  For example, the total number of atoms (N), volume (V) and energy (E) are conserved in the (NVE) ensemble.&lt;br /&gt;
&lt;br /&gt;
=== Microcanonical (NVE) Ensemble ===&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
The NVE ensemble is the probably the best starting point to understand what happens in MD simulations.  In Statistical Mechanics, to picture the NVE ensemble, we can imagine a system of N gas molecules inside a rigid container with perfect thermal insulation.  Hence no work or heat can be exchanged between the system and the outside world (its environment).  While the gas molecules move with time, the total number of particles N, the total energy E and the total volume V of the system does not change.  A large number of replicas of the system with the same N, V, E forms the NVE, or microcanonical ensemble in Statistical Mechanics.  In MD simulations within the NVE ensemble, we usually do not simulate the rigid container --- this is because the simulation volume is usually very small and having an explicit container will lead to a large surface-to-volume ratio and large simulation artifacts.  Instead, periodic boundary conditions (PBC) are usually used in MD simulation.  If the repeat vectors of PBC do not change, the simulation volume V is kept constant during the simulation.  Since the particles follows Hamiltonian dynamics in MD simulations, the total energy E is conserved.  The total number of particles N is obviously conserved in the MD simulation.  Therefore, MD simulations under PBC with fixed repeat vectors and no thermostats (to be described later) correspond to the NVE (microcanonical) ensemble.&lt;br /&gt;
&lt;br /&gt;
The following input script &amp;lt;tt&amp;gt;mo_NVE.tcl&amp;lt;/tt&amp;gt; gives an example of running MD simulations in MD++.  You can test is by the following command (if you put this file in your &amp;lt;tt&amp;gt;scripts/&amp;lt;/tt&amp;gt; directory)&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVE.tcl&lt;br /&gt;
&lt;br /&gt;
This example script first creates a perfect BCC crystal of molybdenum (Mo) with a supercell of 5[1 0 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 1 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 0 1].  It then runs MD simulations using the Finnis-Sinclair (FS) potential.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } { MD++ {&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
zipfiles = 1   # zip output files&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Crystal&lt;br /&gt;
element0 = Mo&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472           # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
}}&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
proc readMoPot { } { MD++ {&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
}}&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 2.725&lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
}}&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
# save property every 10 steps&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0   savecnfreq = 100&lt;br /&gt;
writeall = 1 DOUBLE_T = 1 &lt;br /&gt;
randseed = 12345 srand48 #randomize random number generator&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
#format of thermodynamic property file&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this Tcl script, we start with some definition of functions that will be used subsequently.  The main program starts after the comment &amp;lt;tt&amp;gt;Main program starts here&amp;lt;/tt&amp;gt;.  The program first calls the &amp;lt;tt&amp;gt;initmd&amp;lt;/tt&amp;gt; function that was defined at the beginning, which opens the output directory.  After creating the perfect crystal using the &amp;lt;tt&amp;gt;makecrystal&amp;lt;/tt&amp;gt; command, it calls the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function that initializes some important parameters for MD simulation.  (Commands and variables related with visualization as specified in the &amp;lt;tt&amp;gt;openwindow&amp;lt;/tt&amp;gt; function will be covered in a separate manual in detail.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first line in the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function selects the statistica ensemble for the simulation.  The possible choices for the variable &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; are &#039;&#039;&#039;NVE&#039;&#039;&#039;, &#039;&#039;&#039;NVT&#039;&#039;&#039;, &#039;&#039;&#039;NPH&#039;&#039;&#039; and &#039;&#039;&#039;NPT&#039;&#039;&#039;.  The type of the numerical integrator is specified by the &#039;&#039;&#039;integrator_type&#039;&#039;&#039; variable and can be either the Gear 6-th order predictor-corrector algorithm (&#039;&#039;&#039;Gear6&#039;&#039;&#039;) or the velocity Verlet algorithm (&#039;&#039;&#039;VVerlet&#039;&#039;&#039;).  The predictor-corrector integrator has a higher order of accuracy but velocity Verlet is a symplectic integrator and is more stable at larger algorithm.  We recommend the use of velocity Verlet algorithm whenever possible (i.e. if it is implemented for the chosen ensemble type).&lt;br /&gt;
&lt;br /&gt;
The variable &#039;&#039;&#039;atommass&#039;&#039;&#039; specifies the atomic mass in unit of g/mol. &#039;&#039;&#039;timestep&#039;&#039;&#039; specifies the integrator time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; in unit of picosecond. &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is the total number of time steps for the MD simulation.  Hence &#039;&#039;&#039;totalsteps&#039;&#039;&#039; times &#039;&#039;&#039;timestep&#039;&#039;&#039; is the total time duration of the MD simulation.  We usually choose &#039;&#039;&#039;timestep&#039;&#039;&#039; to be as large as possible provided that the total energy of the system is conserved within an acceptable accurady.  &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is usually chosen so that the total simulation time is long enough for the system to reach an equilibrium or steady state (usually on the order of picoseconds). &lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;tt&amp;gt;initvelocity&amp;lt;/tt&amp;gt; assign random numbers to the atomic velocities and then scale them so that the instantaneous temperature matches the target value, as specified by &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; in unit of K.  Strictly speaking, temperature is not well defined in an NVE ensemble (but is well defined in the NVT ensemble).  Here we can regard &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; as a measure of the instantaneous kinetic energy of the system.  MD++ uses the &amp;lt;tt&amp;gt;drand48()&amp;lt;/tt&amp;gt; to generate random numbers for the velocities.  The random number generator can be initialized by calling &amp;lt;tt&amp;gt;srand48&amp;lt;/tt&amp;gt; with a specified &#039;&#039;&#039;randseed&#039;&#039;&#039;.  This approach is more convenient for debugging because the same &#039;&#039;&#039;randseed&#039;&#039;&#039; garauntees exactly the same random number sequence will be generated if you run the simulation again.  On the other hand, you may use the function &amp;lt;tt&amp;gt;srandbytime&amp;lt;/tt&amp;gt; to use the current time as the random seed for initializing the random number generator.  This makes sure that ever time you run the simulation again a completely different set of random numbers will be generated.&lt;br /&gt;
&lt;br /&gt;
If the parameter &#039;&#039;&#039;DOUBLE_T&#039;&#039;&#039; is set to 1, then the velocities are scaled in such a way that the instantaneous temperature is twice of &#039;&#039;&#039;T_OBJ&#039;&#039;&#039;, as illustrated in Fig.1.  The reason we may want to set &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; is the following.  When we assign velocities to the atoms in a perfect crystal, the instantaneous temperature almost always drop to half of its initial value when thermal equilibrium is reached (see Fig.1).  This is due to the energy equipartition theorem.  For solids at temperatures much below the melting temperature, the Hamiltonian is close to that of a set of coupled harmonic oscillators.  The total energy of a harmonic system is equally divided between the average kinetic energy and the average potential energy.  Because the total energy is conserved in an NVE-ensemble simulation, the kinetic energy is bound to decrease by half if the kinetic energy and potential energy (initially zero) are equal (in time average) when equilibrium is reached.  Setting &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; allows the temperature at the equilibrium state to match the desired temperature.&lt;br /&gt;
                                                                        &lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Instantaneous temperature as a function of time during MD simulations with different settings for DOUBLE_T.&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
Image:Temp_double.jpg&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;saveprop&#039;&#039;&#039; and &#039;&#039;&#039;savepropfreq&#039;&#039;&#039; specify whether or not and how often the simulation properties will be saved periodically in a data file. If  &amp;lt;tt&amp;gt;saveprop = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10&amp;lt;/tt&amp;gt;, the properties such as potential energy, kinetic energy and temperature will be save every 10 simulation steps, provided that the MD++ command &#039;&#039;&#039;openpropfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the property file is specified by the &#039;&#039;&#039;outputfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;prop.out&amp;lt;/tt&amp;gt; by default.  The setting &amp;lt;tt&amp;gt;zipfiles = 1&amp;lt;/tt&amp;gt; at the beginning of this script file (line 11) specifies that both property files and atomic configuration files (see below) will be automatically zipped (by gzip) after they are written.&lt;br /&gt;
&lt;br /&gt;
The content of a property ﬁle is defined by variable &#039;&#039;&#039;output_fmt&#039;&#039;&#039;.  In this example, each line of the property file will contain the current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), and temperature (&#039;&#039;&#039;Tinst&#039;&#039;&#039;).  If we do not specify &#039;&#039;&#039;output_fmt&#039;&#039;&#039;, the default content of the property file will be current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), pressure (&#039;&#039;&#039;PRESSURE&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{xy}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_xy&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{yz}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_yz&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{zx}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_zx&#039;&#039;&#039;), &#039;&#039;&#039;HELM&#039;&#039;&#039;, the extended energy(&#039;&#039;&#039;HELMP&#039;&#039;&#039;), thermodynamic friction coeﬃcient (&#039;&#039;&#039;zeta&#039;&#039;&#039;), reversible work increment &#039;&#039;&#039;dEdlambda&#039;&#039;&#039; and volume (&#039;&#039;&#039;OMEGA&#039;&#039;&#039;).  The energies are in unit of eV and stresses in eV/A˚^3. Please note that there is an &amp;lt;font color=&#039;blue&#039;&amp;gt;overall minus sign&amp;lt;/font&amp;gt; between the stress variables in MD++ and that in conventional elasticity theory.  For example, a positive pressure correspond to positive normal stress components in MD++ but negative normal stress components in elasticity theory.  This is because in MD++, we followed the sign convention of Parrinello and Rahman for stress control.&amp;lt;ref&amp;gt;M. Parrinello and A. Rahman, &amp;quot;Polymorphic transitions in single crystals: A new molecular dynamics method&amp;quot;, J. Appl. Phys &#039;&#039;&#039;52&#039;&#039;&#039; 7182-7190 1981&amp;lt;/ref&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;savecn&#039;&#039;&#039; and &#039;&#039;&#039;savecnfreq&#039;&#039;&#039; specify whether or not and how often the atomic coordinates (and velocities if &#039;&#039;&#039;writeall = 1&#039;&#039;&#039;) will be saved as .cn files during the MD simulation. If  &amp;lt;tt&amp;gt;savecn = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10000&amp;lt;/tt&amp;gt;, the intermediate .cn files will be saved every 10000 steps, provided that the MD++ command &#039;&#039;&#039;openintercnfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the intermediate .cn files are specified by the &#039;&#039;&#039;intercnfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;inter####.cn&amp;lt;/tt&amp;gt; by default, where #### are integers (starting with 0000) that will be automatically incremented by one after each file is written.  In this example, &amp;lt;tt&amp;gt;savecn = 0&amp;lt;/tt&amp;gt; so no intermediate .cn files will be saved.  After all the relevant parameters have been set up, the MD++ command &#039;&#039;&#039;run&#039;&#039;&#039; starts the MD simulation. &lt;br /&gt;
&lt;br /&gt;
After the simulation is finished, a property file named &amp;lt;tt&amp;gt;thermo.out&amp;lt;/tt&amp;gt; will be written in the output directory &amp;lt;tt&amp;gt;runs/mo-example&amp;lt;/tt&amp;gt;.  This file can be loaded and plotted by programs such as Matlab, Octave, or Gnuplot.&amp;lt;ref&amp;gt;A simple way to plot the total energy using gnuplot (a free software on Unix/Linux) is to run the command. &lt;br /&gt;
 plot &amp;quot;thermo.out&amp;quot; u ($1):($2+$3) with line&lt;br /&gt;
&amp;lt;/ref&amp;gt; &lt;br /&gt;
Fig.2 plots the total energy per atom and instantanous temperature for two simulations with different sizes. The larger system (10[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[001]) has eight times more atoms than the smaller one (5[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[001]).  As expected, the data for the larger system experience less statistical fluctuation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Energy and Temperature fluctuation of NVE ensemble&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Energy_fluct.jpg|(a) Energy Fluctuation in NVE ensemble. &lt;br /&gt;
Image:Temp_fluct.jpg|(b) Temperature in NVE ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;run&#039;&#039;&#039; command, the script file calls the command &#039;&#039;&#039;writecn&#039;&#039;&#039; to save the final atomic configuration into a .cn file whose name is specified by &#039;&#039;&#039;finalcnfile&#039;&#039;&#039;.  The .cn file has the following format.  The first line contains  the total number of atoms &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt;.  The following &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt; lines then contain the scaled coordinates of all atoms: &amp;lt;math&amp;gt;s_x^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_y^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_z^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;i = 1, 2, \cdots NP&amp;lt;/math&amp;gt;.  The last three lines of the .cn file specify a 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; whose column vectors are the three repeat vectors of the simulation supercell (subjected to periodic boundary conditions). The real coordinates of an atom (x, y, z ) and the scaled coordinates for each atom are related through &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; as follows&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \left( \begin{array}{c} x \\ y \\ z \end{array} \right) =  \left( \begin{array}{ccc} H_{11} &amp;amp; H_{12} &amp;amp; H_{13} \\ H_{21} &amp;amp; H_{22} &amp;amp; H_{23} \\ H_{31} &amp;amp; H_{32} &amp;amp; H_{33} \end{array} \right) \left( \begin{array}{c} s_x \\ s_y \\ s_z \end{array} \right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt; is specified before &#039;&#039;&#039;writecn&#039;&#039;&#039;, additional informations are added to the &#039;&#039;NP&#039;&#039; lines of data.  Following the scaled coordinates, each line will also contain the scaled velocities (&#039;&#039;&#039;_VSR[i].x&#039;&#039;&#039;, &#039;&#039;&#039;_VSR[i].y&#039;&#039;&#039; and &#039;&#039;&#039;_VSR[i].z&#039;&#039;&#039;), local potential energy (&#039;&#039;&#039;_EPOT_IND[i]&#039;&#039;&#039;), flag (&#039;&#039;&#039;fixed[i]&#039;&#039;&#039;), central-symmetry-deviation paramter (&#039;&#039;&#039;_TOPOL[i]&#039;&#039;&#039;), atom species (&#039;&#039;&#039;species[i]&#039;&#039;&#039;), atom groups (&#039;&#039;&#039;group[i]&#039;&#039;&#039;) and image index (&#039;&#039;&#039;image[i]&#039;&#039;&#039;).  You can see this diﬀerence by comparing two conﬁguration ﬁles, &#039;&#039;&#039;perf.cn&#039;&#039;&#039; (written before setting &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;) and &#039;&#039;&#039;init.cn&#039;&#039;&#039; (written after).  If &amp;lt;tt&amp;gt;writevelocity = 1&amp;lt;/tt&amp;gt; is used instead of &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;, then only the scaled velocities are added behind the three columns for scaled coordinates. &lt;br /&gt;
&lt;br /&gt;
At the end of the example script, the command &#039;&#039;&#039;sleep&#039;&#039;&#039; is called so that the graphics window to stay open (i.e. alive) for a while so that we can examine the atomic structure.  You can press ctrl-c in the terminal to exit.  You can also comment out the &#039;&#039;&#039;sleep&#039;&#039;&#039; command in the script file so that MD++ exits immediately after reaching the end of the input file.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In the NVT ensemble of Statistical Mechanics, the system exchanges heat with an external thermostat to maintain its temperature at T but its total energy is no longer conserved.  The following script &amp;lt;tt&amp;gt;mo_NVT.tcl&amp;lt;/tt&amp;gt; provides an example of NVT simulations in MD++.  You can test it by typing&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVT.tcl&lt;br /&gt;
This script first reads in an atomic configuration generated by the previous MD simulation (NVE ensemble) and then performs MD simulation in the NVT ensemble at T = 300 K using the Nose-Hoover thermostat&amp;lt;ref&amp;gt; S. Nose, “A Molecular Dynamics Method for Simulations in the Canonical Ensemble”, Molecular Physics, &#039;&#039;&#039;52&#039;&#039;&#039; 255 (1984)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVT MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVT&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
implementation_type = 0 vt2 = 1e28&lt;br /&gt;
T_OBJ = 300       # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94  # (g/mol)&lt;br /&gt;
timestep = 0.001 # (ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
}}&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = 300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVT.out openpropfile&lt;br /&gt;
MD++ run eval &lt;br /&gt;
#reverse velocity (to test reversibility)&lt;br /&gt;
MD++ input = -1 multiplyvelocity&lt;br /&gt;
#MD simulation (reverse)&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5-NVT.cn writecn&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Instead of creating a perfect crystal as the initial condition, this script uses the command &#039;&#039;&#039;readcn&#039;&#039;&#039; to read the file &amp;lt;tt&amp;gt;300K_5X5X5.cn&amp;lt;/tt&amp;gt; created at the end of the previous simulation (NVE ensemble simulation).  Note that in this case, the new simulation must use the same time step as the previous simulation that created the .cn file.  This is because in MD++ the velocity information are stored as scaled velocity time the time step.  If you really need to change the time step in the new simulation (not recommended), you will need to rescale your velocity using the MD++ command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Setting &#039;&#039;&#039;ensemble_type = &amp;quot;NVT&amp;quot;&#039;&#039;&#039; activates the Nose-Hoover thermostat, which adds a variable (&amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt;) to the equation of motion.  This variable mimicks the heat deposited to the heat reservoir.  The coupled equation of motion is&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} - \zeta \dot\mathbf{r}_i \\ \dot\zeta &amp;amp;=&amp;amp; \frac{3N k_B}{Q} ( T_{\mathrm{inst}} - T_{\mathrm{OBJ}} ) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
for MD simulations of N particles in 3-dimensions.  We can use three different implementations of the Nose-Hoover thermostat in conjunction with the velocity Verlet integrator.  When &amp;lt;tt&amp;gt;implementation_type = 0&amp;lt;/tt&amp;gt;, an implicit integrator is used.  When &amp;lt;tt&amp;gt;implementation_type = 1&amp;lt;/tt&amp;gt;, an explicit integrator based on Stormer-Verlet method is used.  When &amp;lt;tt&amp;gt;implementation_type = 2&amp;lt;/tt&amp;gt;, an explicit integrator baed on Liouville formulation is used.&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;NHMass&#039;&#039;&#039;, in the unit of eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, corresponds to the Nose-Hoover thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; in the above equation of motion. The thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; can also be specified through the MD++ variable &#039;&#039;&#039;vt2&#039;&#039;&#039; , in the unit of (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, by the following relationship&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; Q = \frac{3 N k_B T_{\mathrm{OBJ}}}{\mathrm{vt2}}\times (1e+24)&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;N&#039;&#039; is number of atoms and &#039;&#039;k_B&#039;&#039; is the Boltzmann constant (8.617343e-5 eV/K). &lt;br /&gt;
&amp;lt;!-- For convenience, we also defined thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039;, which is exactly the Nose&#039;-Hoover thermal mass &#039;&#039;Q&#039;&#039;.  --&amp;gt;&lt;br /&gt;
When &#039;&#039;&#039;NHMass&#039;&#039;&#039; is non-zero, &#039;&#039;&#039;vt2&#039;&#039;&#039; will be superceded. When &#039;&#039;N&#039;&#039; = 250 and &#039;&#039;T&#039;&#039; = 300 K (or k_B T ~ 0.026 eV), &#039;&#039;&#039;vt2&#039;&#039;&#039; = 1e28 (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; corresponds to &#039;&#039;&#039;NHMass&#039;&#039;&#039; = 1.95e-03 (eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;). In comparison with other MD programs such as [http://lammps.sandia.gov  LAMMPS], &#039;&#039;&#039;vt2&#039;&#039;&#039; is proportional to the square of the thermal damping frequency &amp;amp;omega;, or &#039;&#039;&#039;vt2&#039;&#039;&#039;~&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. The proportional constant is determined by equating both units. If &amp;amp;omega; is given in the unit of 1/ps, then the equality becomes &#039;&#039;&#039;vt2&#039;&#039;&#039;= 10&amp;lt;sup&amp;gt;24&amp;lt;/sup&amp;gt;&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. In this case, &amp;amp;omega; = 100 (1/ps) for &#039;&#039;&#039;vt2&#039;&#039;&#039;=10&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The bigger &#039;&#039;&#039;vt2&#039;&#039;&#039; is (or the smaller &#039;&#039;&#039;NHMass&#039;&#039;&#039; is), the faster the instantaneous temperature fluctuates around the desired temperature, as shown in Fig. 3.  The MD++ simulation also writes out the value of a variable &#039;&#039;&#039;HELMP&#039;&#039;&#039; in the property file; &#039;&#039;&#039;HELMP&#039;&#039;&#039; is the total energy of the system plus that of the thermal reservior, and should be conserved.  The flucutation of &#039;&#039;&#039;HELMP&#039;&#039;&#039; around its mean value is also plotted in Fig. 3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 The Effect of Nose-Hoover Mass in NVT MD&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Helmp_fluct.jpg|(a) Helmholtz energy fluctuation in NVT ensemble. &lt;br /&gt;
Image:Temp_fluct_NVT.jpg|(b) Temperature in NVT ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In figure 3, you may notice that the energy and the temperature are symmetric before and after the simulation step = 2000. In the above example script, after the first MD simulation (or after the 1st 2000 steps), we use the command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039; to reverse the velocities of all atoms.  This is done by setting &amp;lt;tt&amp;gt;input = -1&amp;lt;/tt&amp;gt;, so that -1 can be multiplied to the velocities of all atoms and also to &amp;amp;zeta;.  We then continue the MD simulation for the same duration of time as the first one, in order to test the reversibility of the numerical (symplectic) integrator.  After the second MD simulation (in the reverse direction), we save the atomic configuration into file &amp;lt;tt&amp;gt;300K-5x5x5-NVT.cn&amp;lt;/tt&amp;gt;.  Comparing this file with the file &amp;lt;tt&amp;gt;300K-5x5x5.cn&amp;lt;/tt&amp;gt;, which contains the atomic configuration at the beginning of the (forward) simulation, reveals that the scaled coordinates of all atoms are identical in the two files within 1e-14 (close to the machine precision).  This demonstrates the reversibility of the chosen integrator.  If on the other hand, &amp;lt;tt&amp;gt;integrator_type = Gear6&amp;lt;/tt&amp;gt; is used, the discrepancy in the atomic coordinates will be on the order of 1e-6, which shows that the Gear6 integrator is not reversible.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble with Nose-Hoover Chain ===&lt;br /&gt;
----&lt;br /&gt;
Martyna &#039;&#039;et al&#039;&#039;&amp;lt;ref&amp;gt;G. J. Martyna, M. L. Klein and M. Tuckerman, &amp;quot;Nose-Hoover chains: The canonical ensemble via continuous dynamics&amp;quot;, J. Chem. Phys. &#039;&#039;&#039;97&#039;&#039;&#039; 2635--2643&amp;lt;/ref&amp;gt; modified the original Nose-Hoover thermostat so that a chain of thermostats are used instead of just one thermostat. The purpose of this chain method is to increase the size of the phase space and help the system to be ergodic when the system is stiff or is not ergodic.  Our implementation of the Nose-Hoover chain method in MD++ follows another paper of Martyna.&amp;lt;ref&amp;gt;G. J. Martyna, &amp;quot;Explicit reversible integrators for extended systems dynamics&amp;quot;, Molecular Physics &#039;&#039;&#039;87&#039;&#039;&#039; 1117-1157 (1996)&amp;lt;/ref&amp;gt;  The following example script, &amp;lt;tt&amp;gt;Mo_NVTC.tcl&amp;lt;/tt&amp;gt;, demonstrates how to use the Nose-Hoover chain method in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVTC&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
NHChainLen = 4                       # MAXNHCLEN = 20 in md.h&lt;br /&gt;
NHMass = [ 1.95e-4 2e-6 2e-6 2e-6 ]&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 5000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = ../mo-example/300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVTC.out openpropfile&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; is set to &amp;lt;tt&amp;gt;NVTC&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;NVT&amp;lt;/tt&amp;gt;.  The number of chains is specified in &#039;&#039;&#039;NHChainLen&#039;&#039;&#039; and the masses for each thermostat on the chain are specified as an array in &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  &#039;&#039;&#039;NHMass&#039;&#039;&#039; need to be chosen with caution, otherwise the system may lose reversibility, even though Martyna &#039;&#039;et al&#039;&#039; stated that the choice of thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039; is not critical.  Martyna &#039;&#039;et all&#039;&#039; suggested the following choice for &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  For a chain of length M that is designed to act as a thermostat for N particles (with &amp;lt;math&amp;gt;N_f = 3 N&amp;lt;/math&amp;gt; degrees of freedom), we can set &lt;br /&gt;
&lt;br /&gt;
 NHMass[0] ~ &amp;lt;math&amp;gt; N_f k_B T / \omega^2&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 NHMass[i] ~ &amp;lt;math&amp;gt; k_B T / \omega^2&amp;lt;/math&amp;gt; (for &#039;&#039;i&#039;&#039; = 1 to &#039;&#039;M-1&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
The thermostats &amp;lt;math&amp;gt; i = 1, \cdots, M-1&amp;lt;/math&amp;gt; fluctuates with a characteristic frequency &amp;lt;math&amp;gt;\omega&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Constant Stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In MD simulations using a constant stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) ensemble, the internal Virial stress is controlled to fluctuate around an externally specified stress (i.e. applied stress).  In MD++ the Parrinello-Rahman method is implemented. The applied stress tensor &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}&amp;lt;/math&amp;gt; can be decomposed into a hydrostatic term and a deviatoric term,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sigma_{\mathrm{EXT}} = \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} + \sigma_{\mathrm{EXT}}^{\mathrm{devi}} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{hydro}} = \frac{1}{3}(\sigma_{\mathrm{EXT}})_{kk}\cdot\mathrm{I}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{devi}} = \sigma_{\mathrm{EXT}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}}&amp;lt;/math&amp;gt;. Here we used the Einstein&#039;s notation, in which repeated indices are summed over from 1 to 3, to express the sum of the diagonal components of the stress tensor. The equations of motion of Parrinello-Rahman&#039;s method can be written as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} &lt;br /&gt;
        \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} &lt;br /&gt;
        - \mathbf{H}^{-T}\dot\mathbf{G}\mathbf{H}^{-1} \dot\mathbf{r}_i \\ &lt;br /&gt;
        \ddot\mathbf{H} &amp;amp;=&amp;amp; -\frac{1}{M} \left[ \left( \sigma_{\mathrm{Virial}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} \right)\Xi &lt;br /&gt;
        - \left( \mathbf{H}\mathbf{H}_0^{-1} \sigma_{\mathrm{EXT}}^{\mathrm{devi}} \right) \Xi_0 \right]        &lt;br /&gt;
 \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is the 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix representing the simulation box at time &#039;&#039;t&#039;&#039; and &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; is the matrix corresponding to the simulation box at &#039;&#039;t&#039;&#039; = 0. &amp;lt;math&amp;gt;\mathbf{G} \equiv \mathbf{H}^T\mathbf{H}&amp;lt;/math&amp;gt; is called the metric tensor. &amp;lt;math&amp;gt;\Xi \equiv \Omega \mathbf{H}^{-T}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Xi_0 \equiv \Omega_0 \mathbf{H}_0^{-T}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Omega \equiv \det \mathbf{H}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Omega_0 \equiv \det \mathbf{H}_0&amp;lt;/math&amp;gt; are the volumes of the simulation box at time &#039;&#039;t&#039;&#039; and at time 0. &#039;&#039;M&#039;&#039; is an artificial parameter, called the &amp;quot;box mass&amp;quot;, that controlls how fast the simulation box changes its shape to reduce the difference between internal (Virial) and applied stress.&lt;br /&gt;
&lt;br /&gt;
If we apply the constant pressure &amp;lt;math&amp;gt;P_{\mathrm{EXT}} = \frac{1}{3}\left(\sigma_{\mathrm{EXT}}\right)_{kk}&amp;lt;/math&amp;gt; (notice that in MD++ a pressure correspond to positive stress, which is usually the opposite of the sign convention in elasticity theory), the deviatoric part of the external stress is zero and the second equation becomes simply&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} = -\frac{1}{M} \left[ &lt;br /&gt;
        \left( \sigma_{\mathrm{Virial}} +  P_{\mathrm{EXT}}\mathbf{I} \right)\Xi \right]        &lt;br /&gt;
&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
In this case the N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H ensemble reduces to the isoenthalpic-isobaric (NPH) ensemble.  The following script, &#039;&#039;&#039;Mo_NPH.tcl&#039;&#039;&#039;, provides an example of how to run NPH MD simulations in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NPH MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NPH&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
wallmass = 1000 boxdamp = 0.1&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
stress = [ 1000    0    0&lt;br /&gt;
              0 1000    0&lt;br /&gt;
              0    0 1000 ] # compression in MPa&lt;br /&gt;
fixboxvec = [ 0 1 1&lt;br /&gt;
              1 0 1&lt;br /&gt;
              1 1 0 ]&lt;br /&gt;
T_OBJ = 300                 # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94            # (in g/mol)&lt;br /&gt;
timestep = 0.001            # (in ps)&lt;br /&gt;
totalsteps = 10000&lt;br /&gt;
saveprop = 1 savepropfreq = 20&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
                    TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
                    TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
                    H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32&amp;quot; }&lt;br /&gt;
MD++ outpropfile = thermo-NPH.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
#MD++ finalcnfile = Mo-5X5X5-NPH.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In function &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt;, &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; to set to &#039;&#039;&#039;NPH&#039;&#039;&#039;.  The variable &#039;&#039;&#039;wallmass&#039;&#039;&#039; is the box mass parameter &#039;&#039;M&#039;&#039; in the Parrinello-Rahman (PR) method.  An artificial paramter, &#039;&#039;&#039;boxdamp&#039;&#039;&#039;, (not in the above equation of motion), is introduced to make the system converge faster to an equilibrium state.  The effect of &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is illustrated in Fig. 4.  When &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is nonzero, an additional term is introduced to the box acceleration, as in,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} := \ddot\mathbf{H}- (\mathrm{boxdamp}) \times \dot\mathbf{H}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the dynamics of the system is no longer symplectic (or reversible).  The variable &#039;&#039;&#039;stress&#039;&#039;&#039; is the external stress in unit of MPa. &amp;lt;font color=&amp;quot;blue&amp;quot;&amp;gt;Note that the sign convention of &#039;&#039;&#039;stress&#039;&#039;&#039; is opposite of that in the elasticity theory. In MD++ a pressure corresponds to positive normal stresses.&amp;lt;/font&amp;gt; &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; specifies which component of the box matrix &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; will be fixed during the MD simulation; the corresponding matrix element in &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; is 1.&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;saveH&#039;&#039;&#039; stores the current box matrix H into &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; in the Parrinello-Rahman method.  This needs to be done before starting the MD simulation.  According to Ray and Rahman&amp;lt;ref&amp;gt;J. R. Ray and A. Rahman, &amp;quot;Statistical ensembles and molecular dynamics studies of anisotropic solids&amp;quot;, J. Chem. Phys, &#039;&#039;&#039;80&#039;&#039;&#039; 4423--4428 &amp;lt;/ref&amp;gt;, &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; should be taken as the average value of &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; when the stress is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 The Effect of BoxDamp paramter in NPH MD simulation.  A finite BoxDamp speeds up the convergence toward an equilibrium state.&amp;quot; widths=&amp;quot;250px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Ext_energy_fluct_NPH.jpg|(a) Fluctuation of the total energy of the extended system (energy of the original system plus that of the box) -- a conserved quantity, as a function of time. &lt;br /&gt;
Image:Stress_fluct_NPH.jpg|(b) Stress fluctuation in NPH ensemble.&lt;br /&gt;
Image:Box_fluct.jpg|(c) Size of the simulation box as a function of time.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Isothermal-isobaric (NPT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5063</id>
		<title>M05 Finite Temperature Simulation</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5063"/>
		<updated>2011-01-20T17:25:40Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Canonical(NVT) Ensemble with Nose-Hoover Chain */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 05 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Molecular Dynamics Simulations&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[First written, [ Jan 19 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[Last Modified, [ Apr 13 ]], [[2008]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The case studies described in Manuals 02-04 only deal with atomic positions as degrees of freedom.  For example, in Manual 02, we learned how to create a perfect crystal by MD++ command &#039;&#039;&#039;makecrystal&#039;&#039;&#039;.  In Manual 03, we varied the size of the perfect crystal to find the equilibrium lattice constants.  In Manual 04, we introduced a vacancy to the perfect crystal and let the atomic positions relax to a local energy minimum.  In this manual, we will learn how to perform finite temperature, Molecular Dynamics (MD) simulations.  For this purpose, we will need to deal with atomic velocities as degrees of freedom, as well as a number of control variables, such as integrator type, time step, and output controls.  We will learn to specify the simulation ensembles from different choices: microcanonical (NVE), canonical (NVT),&lt;br /&gt;
isoenthalpic-isobaric (NPH) and constant pressure/temperature (NPT) ensembles.  Different quantities are conserved or controlled in different ensembles.  For example, the total number of atoms (N), volume (V) and energy (E) are conserved in the (NVE) ensemble.&lt;br /&gt;
&lt;br /&gt;
=== Microcanonical (NVE) Ensemble ===&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
The NVE ensemble is the probably the best starting point to understand what happens in MD simulations.  In Statistical Mechanics, to picture the NVE ensemble, we can imagine a system of N gas molecules inside a rigid container with perfect thermal insulation.  Hence no work or heat can be exchanged between the system and the outside world (its environment).  While the gas molecules move with time, the total number of particles N, the total energy E and the total volume V of the system does not change.  A large number of replicas of the system with the same N, V, E forms the NVE, or microcanonical ensemble in Statistical Mechanics.  In MD simulations within the NVE ensemble, we usually do not simulate the rigid container --- this is because the simulation volume is usually very small and having an explicit container will lead to a large surface-to-volume ratio and large simulation artifacts.  Instead, periodic boundary conditions (PBC) are usually used in MD simulation.  If the repeat vectors of PBC do not change, the simulation volume V is kept constant during the simulation.  Since the particles follows Hamiltonian dynamics in MD simulations, the total energy E is conserved.  The total number of particles N is obviously conserved in the MD simulation.  Therefore, MD simulations under PBC with fixed repeat vectors and no thermostats (to be described later) correspond to the NVE (microcanonical) ensemble.&lt;br /&gt;
&lt;br /&gt;
The following input script &amp;lt;tt&amp;gt;mo_NVE.tcl&amp;lt;/tt&amp;gt; gives an example of running MD simulations in MD++.  You can test is by the following command (if you put this file in your &amp;lt;tt&amp;gt;scripts/&amp;lt;/tt&amp;gt; directory)&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVE.tcl&lt;br /&gt;
&lt;br /&gt;
This example script first creates a perfect BCC crystal of molybdenum (Mo) with a supercell of 5[1 0 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 1 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 0 1].  It then runs MD simulations using the Finnis-Sinclair (FS) potential.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } { MD++ {&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
zipfiles = 1   # zip output files&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Crystal&lt;br /&gt;
element0 = Mo&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472           # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
}}&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
proc readMoPot { } { MD++ {&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
}}&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 2.725&lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
}}&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
# save property every 10 steps&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0   savecnfreq = 100&lt;br /&gt;
writeall = 1 DOUBLE_T = 1 &lt;br /&gt;
randseed = 12345 srand48 #randomize random number generator&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
#format of thermodynamic property file&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this Tcl script, we start with some definition of functions that will be used subsequently.  The main program starts after the comment &amp;lt;tt&amp;gt;Main program starts here&amp;lt;/tt&amp;gt;.  The program first calls the &amp;lt;tt&amp;gt;initmd&amp;lt;/tt&amp;gt; function that was defined at the beginning, which opens the output directory.  After creating the perfect crystal using the &amp;lt;tt&amp;gt;makecrystal&amp;lt;/tt&amp;gt; command, it calls the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function that initializes some important parameters for MD simulation.  (Commands and variables related with visualization as specified in the &amp;lt;tt&amp;gt;openwindow&amp;lt;/tt&amp;gt; function will be covered in a separate manual in detail.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first line in the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function selects the statistica ensemble for the simulation.  The possible choices for the variable &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; are &#039;&#039;&#039;NVE&#039;&#039;&#039;, &#039;&#039;&#039;NVT&#039;&#039;&#039;, &#039;&#039;&#039;NPH&#039;&#039;&#039; and &#039;&#039;&#039;NPT&#039;&#039;&#039;.  The type of the numerical integrator is specified by the &#039;&#039;&#039;integrator_type&#039;&#039;&#039; variable and can be either the Gear 6-th order predictor-corrector algorithm (&#039;&#039;&#039;Gear6&#039;&#039;&#039;) or the velocity Verlet algorithm (&#039;&#039;&#039;VVerlet&#039;&#039;&#039;).  The predictor-corrector integrator has a higher order of accuracy but velocity Verlet is a symplectic integrator and is more stable at larger algorithm.  We recommend the use of velocity Verlet algorithm whenever possible (i.e. if it is implemented for the chosen ensemble type).&lt;br /&gt;
&lt;br /&gt;
The variable &#039;&#039;&#039;atommass&#039;&#039;&#039; specifies the atomic mass in unit of g/mol. &#039;&#039;&#039;timestep&#039;&#039;&#039; specifies the integrator time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; in unit of picosecond. &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is the total number of time steps for the MD simulation.  Hence &#039;&#039;&#039;totalsteps&#039;&#039;&#039; times &#039;&#039;&#039;timestep&#039;&#039;&#039; is the total time duration of the MD simulation.  We usually choose &#039;&#039;&#039;timestep&#039;&#039;&#039; to be as large as possible provided that the total energy of the system is conserved within an acceptable accurady.  &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is usually chosen so that the total simulation time is long enough for the system to reach an equilibrium or steady state (usually on the order of picoseconds). &lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;tt&amp;gt;initvelocity&amp;lt;/tt&amp;gt; assign random numbers to the atomic velocities and then scale them so that the instantaneous temperature matches the target value, as specified by &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; in unit of K.  Strictly speaking, temperature is not well defined in an NVE ensemble (but is well defined in the NVT ensemble).  Here we can regard &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; as a measure of the instantaneous kinetic energy of the system.  MD++ uses the &amp;lt;tt&amp;gt;drand48()&amp;lt;/tt&amp;gt; to generate random numbers for the velocities.  The random number generator can be initialized by calling &amp;lt;tt&amp;gt;srand48&amp;lt;/tt&amp;gt; with a specified &#039;&#039;&#039;randseed&#039;&#039;&#039;.  This approach is more convenient for debugging because the same &#039;&#039;&#039;randseed&#039;&#039;&#039; garauntees exactly the same random number sequence will be generated if you run the simulation again.  On the other hand, you may use the function &amp;lt;tt&amp;gt;srandbytime&amp;lt;/tt&amp;gt; to use the current time as the random seed for initializing the random number generator.  This makes sure that ever time you run the simulation again a completely different set of random numbers will be generated.&lt;br /&gt;
&lt;br /&gt;
If the parameter &#039;&#039;&#039;DOUBLE_T&#039;&#039;&#039; is set to 1, then the velocities are scaled in such a way that the instantaneous temperature is twice of &#039;&#039;&#039;T_OBJ&#039;&#039;&#039;, as illustrated in Fig.1.  The reason we may want to set &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; is the following.  When we assign velocities to the atoms in a perfect crystal, the instantaneous temperature almost always drop to half of its initial value when thermal equilibrium is reached (see Fig.1).  This is due to the energy equipartition theorem.  For solids at temperatures much below the melting temperature, the Hamiltonian is close to that of a set of coupled harmonic oscillators.  The total energy of a harmonic system is equally divided between the average kinetic energy and the average potential energy.  Because the total energy is conserved in an NVE-ensemble simulation, the kinetic energy is bound to decrease by half if the kinetic energy and potential energy (initially zero) are equal (in time average) when equilibrium is reached.  Setting &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; allows the temperature at the equilibrium state to match the desired temperature.&lt;br /&gt;
                                                                        &lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Instantaneous temperature as a function of time during MD simulations with different settings for DOUBLE_T.&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
Image:Temp_double.jpg&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;saveprop&#039;&#039;&#039; and &#039;&#039;&#039;savepropfreq&#039;&#039;&#039; specify whether or not and how often the simulation properties will be saved periodically in a data file. If  &amp;lt;tt&amp;gt;saveprop = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10&amp;lt;/tt&amp;gt;, the properties such as potential energy, kinetic energy and temperature will be save every 10 simulation steps, provided that the MD++ command &#039;&#039;&#039;openpropfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the property file is specified by the &#039;&#039;&#039;outputfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;prop.out&amp;lt;/tt&amp;gt; by default.  The setting &amp;lt;tt&amp;gt;zipfiles = 1&amp;lt;/tt&amp;gt; at the beginning of this script file (line 11) specifies that both property files and atomic configuration files (see below) will be automatically zipped (by gzip) after they are written.&lt;br /&gt;
&lt;br /&gt;
The content of a property ﬁle is defined by variable &#039;&#039;&#039;output_fmt&#039;&#039;&#039;.  In this example, each line of the property file will contain the current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), and temperature (&#039;&#039;&#039;Tinst&#039;&#039;&#039;).  If we do not specify &#039;&#039;&#039;output_fmt&#039;&#039;&#039;, the default content of the property file will be current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), pressure (&#039;&#039;&#039;PRESSURE&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{xy}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_xy&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{yz}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_yz&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{zx}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_zx&#039;&#039;&#039;), &#039;&#039;&#039;HELM&#039;&#039;&#039;, the extended energy(&#039;&#039;&#039;HELMP&#039;&#039;&#039;), thermodynamic friction coeﬃcient (&#039;&#039;&#039;zeta&#039;&#039;&#039;), reversible work increment &#039;&#039;&#039;dEdlambda&#039;&#039;&#039; and volume (&#039;&#039;&#039;OMEGA&#039;&#039;&#039;).  The energies are in unit of eV and stresses in eV/A˚^3. Please note that there is an &amp;lt;font color=&#039;blue&#039;&amp;gt;overall minus sign&amp;lt;/font&amp;gt; between the stress variables in MD++ and that in conventional elasticity theory.  For example, a positive pressure correspond to positive normal stress components in MD++ but negative normal stress components in elasticity theory.  This is because in MD++, we followed the sign convention of Parrinello and Rahman for stress control.&amp;lt;ref&amp;gt;M. Parrinello and A. Rahman, &amp;quot;Polymorphic transitions in single crystals: A new molecular dynamics method&amp;quot;, J. Appl. Phys &#039;&#039;&#039;52&#039;&#039;&#039; 7182-7190 1981&amp;lt;/ref&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;savecn&#039;&#039;&#039; and &#039;&#039;&#039;savecnfreq&#039;&#039;&#039; specify whether or not and how often the atomic coordinates (and velocities if &#039;&#039;&#039;writeall = 1&#039;&#039;&#039;) will be saved as .cn files during the MD simulation. If  &amp;lt;tt&amp;gt;savecn = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10000&amp;lt;/tt&amp;gt;, the intermediate .cn files will be saved every 10000 steps, provided that the MD++ command &#039;&#039;&#039;openintercnfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the intermediate .cn files are specified by the &#039;&#039;&#039;intercnfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;inter####.cn&amp;lt;/tt&amp;gt; by default, where #### are integers (starting with 0000) that will be automatically incremented by one after each file is written.  In this example, &amp;lt;tt&amp;gt;savecn = 0&amp;lt;/tt&amp;gt; so no intermediate .cn files will be saved.  After all the relevant parameters have been set up, the MD++ command &#039;&#039;&#039;run&#039;&#039;&#039; starts the MD simulation. &lt;br /&gt;
&lt;br /&gt;
After the simulation is finished, a property file named &amp;lt;tt&amp;gt;thermo.out&amp;lt;/tt&amp;gt; will be written in the output directory &amp;lt;tt&amp;gt;runs/mo-example&amp;lt;/tt&amp;gt;.  This file can be loaded and plotted by programs such as Matlab, Octave, or Gnuplot.&amp;lt;ref&amp;gt;A simple way to plot the total energy using gnuplot (a free software on Unix/Linux) is to run the command. &lt;br /&gt;
 plot &amp;quot;thermo.out&amp;quot; u ($1):($2+$3) with line&lt;br /&gt;
&amp;lt;/ref&amp;gt; &lt;br /&gt;
Fig.2 plots the total energy per atom and instantanous temperature for two simulations with different sizes. The larger system (10[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[001]) has eight times more atoms than the smaller one (5[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[001]).  As expected, the data for the larger system experience less statistical fluctuation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Energy and Temperature fluctuation of NVE ensemble&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Energy_fluct.jpg|(a) Energy Fluctuation in NVE ensemble. &lt;br /&gt;
Image:Temp_fluct.jpg|(b) Temperature in NVE ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;run&#039;&#039;&#039; command, the script file calls the command &#039;&#039;&#039;writecn&#039;&#039;&#039; to save the final atomic configuration into a .cn file whose name is specified by &#039;&#039;&#039;finalcnfile&#039;&#039;&#039;.  The .cn file has the following format.  The first line contains  the total number of atoms &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt;.  The following &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt; lines then contain the scaled coordinates of all atoms: &amp;lt;math&amp;gt;s_x^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_y^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_z^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;i = 1, 2, \cdots NP&amp;lt;/math&amp;gt;.  The last three lines of the .cn file specify a 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; whose column vectors are the three repeat vectors of the simulation supercell (subjected to periodic boundary conditions). The real coordinates of an atom (x, y, z ) and the scaled coordinates for each atom are related through &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; as follows&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \left( \begin{array}{c} x \\ y \\ z \end{array} \right) =  \left( \begin{array}{ccc} H_{11} &amp;amp; H_{12} &amp;amp; H_{13} \\ H_{21} &amp;amp; H_{22} &amp;amp; H_{23} \\ H_{31} &amp;amp; H_{32} &amp;amp; H_{33} \end{array} \right) \left( \begin{array}{c} s_x \\ s_y \\ s_z \end{array} \right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt; is specified before &#039;&#039;&#039;writecn&#039;&#039;&#039;, additional informations are added to the &#039;&#039;NP&#039;&#039; lines of data.  Following the scaled coordinates, each line will also contain the scaled velocities (&#039;&#039;&#039;_VSR[i].x&#039;&#039;&#039;, &#039;&#039;&#039;_VSR[i].y&#039;&#039;&#039; and &#039;&#039;&#039;_VSR[i].z&#039;&#039;&#039;), local potential energy (&#039;&#039;&#039;_EPOT_IND[i]&#039;&#039;&#039;), flag (&#039;&#039;&#039;fixed[i]&#039;&#039;&#039;), central-symmetry-deviation paramter (&#039;&#039;&#039;_TOPOL[i]&#039;&#039;&#039;), atom species (&#039;&#039;&#039;species[i]&#039;&#039;&#039;), atom groups (&#039;&#039;&#039;group[i]&#039;&#039;&#039;) and image index (&#039;&#039;&#039;image[i]&#039;&#039;&#039;).  You can see this diﬀerence by comparing two conﬁguration ﬁles, &#039;&#039;&#039;perf.cn&#039;&#039;&#039; (written before setting &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;) and &#039;&#039;&#039;init.cn&#039;&#039;&#039; (written after).  If &amp;lt;tt&amp;gt;writevelocity = 1&amp;lt;/tt&amp;gt; is used instead of &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;, then only the scaled velocities are added behind the three columns for scaled coordinates. &lt;br /&gt;
&lt;br /&gt;
At the end of the example script, the command &#039;&#039;&#039;sleep&#039;&#039;&#039; is called so that the graphics window to stay open (i.e. alive) for a while so that we can examine the atomic structure.  You can press ctrl-c in the terminal to exit.  You can also comment out the &#039;&#039;&#039;sleep&#039;&#039;&#039; command in the script file so that MD++ exits immediately after reaching the end of the input file.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In the NVT ensemble of Statistical Mechanics, the system exchanges heat with an external thermostat to maintain its temperature at T but its total energy is no longer conserved.  The following script &amp;lt;tt&amp;gt;mo_NVT.tcl&amp;lt;/tt&amp;gt; provides an example of NVT simulations in MD++.  You can test it by typing&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVT.tcl&lt;br /&gt;
This script first reads in an atomic configuration generated by the previous MD simulation (NVE ensemble) and then performs MD simulation in the NVT ensemble at T = 300 K using the Nose-Hoover thermostat&amp;lt;ref&amp;gt; S. Nose, “A Molecular Dynamics Method for Simulations in the Canonical Ensemble”, Molecular Physics, &#039;&#039;&#039;52&#039;&#039;&#039; 255 (1984)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVT MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVT&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
implementation_type = 0 vt2 = 1e28&lt;br /&gt;
T_OBJ = 300       # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94  # (g/mol)&lt;br /&gt;
timestep = 0.001 # (ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
}}&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = 300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVT.out openpropfile&lt;br /&gt;
MD++ run eval &lt;br /&gt;
#reverse velocity (to test reversibility)&lt;br /&gt;
MD++ input = -1 multiplyvelocity&lt;br /&gt;
#MD simulation (reverse)&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5-NVT.cn writecn&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Instead of creating a perfect crystal as the initial condition, this script uses the command &#039;&#039;&#039;readcn&#039;&#039;&#039; to read the file &amp;lt;tt&amp;gt;300K_5X5X5.cn&amp;lt;/tt&amp;gt; created at the end of the previous simulation (NVE ensemble simulation).  Note that in this case, the new simulation must use the same time step as the previous simulation that created the .cn file.  This is because in MD++ the velocity information are stored as scaled velocity time the time step.  If you really need to change the time step in the new simulation (not recommended), you will need to rescale your velocity using the MD++ command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Setting &#039;&#039;&#039;ensemble_type = &amp;quot;NVT&amp;quot;&#039;&#039;&#039; activates the Nose-Hoover thermostat, which adds a variable (&amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt;) to the equation of motion.  This variable mimicks the heat deposited to the heat reservoir.  The coupled equation of motion is&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} - \zeta \dot\mathbf{r}_i \\ \dot\zeta &amp;amp;=&amp;amp; \frac{3N k_B}{Q} ( T_{\mathrm{inst}} - T_{\mathrm{OBJ}} ) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
for MD simulations of N particles in 3-dimensions.  We can use three different implementations of the Nose-Hoover thermostat in conjunction with the velocity Verlet integrator.  When &amp;lt;tt&amp;gt;implementation_type = 0&amp;lt;/tt&amp;gt;, an implicit integrator is used.  When &amp;lt;tt&amp;gt;implementation_type = 1&amp;lt;/tt&amp;gt;, an explicit integrator based on Stormer-Verlet method is used.  When &amp;lt;tt&amp;gt;implementation_type = 2&amp;lt;/tt&amp;gt;, an explicit integrator baed on Liouville formulation is used.&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;NHMass&#039;&#039;&#039;, in the unit of eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, corresponds to the Nose-Hoover thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; in the above equation of motion. The thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; can also be specified through the MD++ variable &#039;&#039;&#039;vt2&#039;&#039;&#039; , in the unit of (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, by the following relationship&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; Q = \frac{3 N k_B T_{\mathrm{OBJ}}}{\mathrm{vt2}}\times (1e+24)&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;N&#039;&#039; is number of atoms and &#039;&#039;k_B&#039;&#039; is the Boltzmann constant (8.617343e-5 eV/K). &lt;br /&gt;
&amp;lt;!-- For convenience, we also defined thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039;, which is exactly the Nose&#039;-Hoover thermal mass &#039;&#039;Q&#039;&#039;.  --&amp;gt;&lt;br /&gt;
When &#039;&#039;&#039;NHMass&#039;&#039;&#039; is non-zero, &#039;&#039;&#039;vt2&#039;&#039;&#039; will be superceded. When &#039;&#039;N&#039;&#039; = 250 and &#039;&#039;T&#039;&#039; = 300 K (or k_B T ~ 0.026 eV), &#039;&#039;&#039;vt2&#039;&#039;&#039; = 1e28 (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; corresponds to &#039;&#039;&#039;NHMass&#039;&#039;&#039; = 1.95e-03 (eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;). In comparison with other MD programs such as [http://lammps.sandia.gov  LAMMPS], &#039;&#039;&#039;vt2&#039;&#039;&#039; is proportional to the square of the thermal damping frequency &amp;amp;omega;, or &#039;&#039;&#039;vt2&#039;&#039;&#039;~&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. The proportional constant is determined by equating both units. If &amp;amp;omega; is given in the unit of 1/ps, then the equality becomes &#039;&#039;&#039;vt2&#039;&#039;&#039;= 10&amp;lt;sup&amp;gt;24&amp;lt;/sup&amp;gt;&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. In this case, &amp;amp;omega; = 100 (1/ps) for &#039;&#039;&#039;vt2&#039;&#039;&#039;=10&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The bigger &#039;&#039;&#039;vt2&#039;&#039;&#039; is (or the smaller &#039;&#039;&#039;NHMass&#039;&#039;&#039; is), the faster the instantaneous temperature fluctuates around the desired temperature, as shown in Fig. 3.  The MD++ simulation also writes out the value of a variable &#039;&#039;&#039;HELMP&#039;&#039;&#039; in the property file; &#039;&#039;&#039;HELMP&#039;&#039;&#039; is the total energy of the system plus that of the thermal reservior, and should be conserved.  The flucutation of &#039;&#039;&#039;HELMP&#039;&#039;&#039; around its mean value is also plotted in Fig. 3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 The Effect of Nose-Hoover Mass in NVT MD&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Helmp_fluct.jpg|(a) Helmholtz energy fluctuation in NVT ensemble. &lt;br /&gt;
Image:Temp_fluct_NVT.jpg|(b) Temperature in NVT ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In figure 3, you may notice that the energy and the temperature are symmetric before and after the simulation step = 2000. In the above example script, after the first MD simulation (or after the 1st 2000 steps), we use the command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039; to reverse the velocities of all atoms.  This is done by setting &amp;lt;tt&amp;gt;input = -1&amp;lt;/tt&amp;gt;, so that -1 can be multiplied to the velocities of all atoms and also to &amp;amp;zeta;.  We then continue the MD simulation for the same duration of time as the first one, in order to test the reversibility of the numerical (symplectic) integrator.  After the second MD simulation (in the reverse direction), we save the atomic configuration into file &amp;lt;tt&amp;gt;300K-5x5x5-NVT.cn&amp;lt;/tt&amp;gt;.  Comparing this file with the file &amp;lt;tt&amp;gt;300K-5x5x5.cn&amp;lt;/tt&amp;gt;, which contains the atomic configuration at the beginning of the (forward) simulation, reveals that the scaled coordinates of all atoms are identical in the two files within 1e-14 (close to the machine precision).  This demonstrates the reversibility of the chosen integrator.  If on the other hand, &amp;lt;tt&amp;gt;integrator_type = Gear6&amp;lt;/tt&amp;gt; is used, the discrepancy in the atomic coordinates will be on the order of 1e-6, which shows that the Gear6 integrator is not reversible.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble with Nose-Hoover Chain ===&lt;br /&gt;
----&lt;br /&gt;
Martyna &#039;&#039;et al&#039;&#039;&amp;lt;ref&amp;gt;G. J. Martyna, M. L. Klein and M. Tuckerman, &amp;quot;Nose-Hoover chains: The canonical ensemble via continuous dynamics&amp;quot;, J. Chem. Phys. &#039;&#039;&#039;97&#039;&#039;&#039; 2635--2643&amp;lt;/ref&amp;gt; modified the original Nose-Hoover thermostat so that a chain of thermostats are used instead of just one thermostat. The purpose of this chain method is to increase the size of the phase space and help the system to be ergodic when the system is stiff or is not ergodic.  Our implementation of the Nose-Hoover chain method in MD++ follows another paper of Martyna.&amp;lt;ref&amp;gt;G. J. Martyna, &amp;quot;Explicit reversible integrators for extended systems dynamics&amp;quot;, Molecular Physics &#039;&#039;&#039;87&#039;&#039;&#039; 1117-1157 (1996)&amp;lt;/ref&amp;gt;  The following example script, &amp;lt;tt&amp;gt;Mo_NVTC.tcl&amp;lt;/tt&amp;gt;, demonstrates how to use the Nose-Hoover chain method in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVTC&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
NHChainLen = 4                       # MAXNHCLEN = 20 in md.h&lt;br /&gt;
NHMass = [ 1.95e-4 2e-6 2e-6 2e-6 ]&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 5000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = ../mo-example/300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVTC.out openpropfile&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; is set to &amp;lt;tt&amp;gt;NVTC&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;NVT&amp;lt;/tt&amp;gt;.  The number of chains is specified in &#039;&#039;&#039;NHChainLen&#039;&#039;&#039; and the masses for each thermostat on the chain are specified as an array in &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  &#039;&#039;&#039;NHMass&#039;&#039;&#039; need to be chosen with caution, otherwise the system may lose reversibility, even though Martyna &#039;&#039;et al&#039;&#039; stated that the choice of thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039; is not critical.  Martyna &#039;&#039;et all&#039;&#039; suggested the following choice for &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  For a chain of length M that is designed to act as a thermostat for N particles (with &amp;lt;math&amp;gt;N_f = 3 N&amp;lt;/math&amp;gt; degrees of freedom), we can set &lt;br /&gt;
&lt;br /&gt;
 NHMass[0] ~ &amp;lt;math&amp;gt; N_f k_B T / \omega^2&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 NHMass[i] ~ &amp;lt;math&amp;gt; k_B T / \omega^2&amp;lt;/math&amp;gt; (for &#039;&#039;i&#039;&#039; = 1 to &#039;&#039;M-1&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
The thermostats &amp;lt;math&amp;gt; i = 1, \cdots, M-1&amp;lt;/math&amp;gt; fluctuates with a characteristic frequency &amp;lt;math&amp;gt;\omega&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Constant Stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In MD simulations using a constant stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) ensemble, the internal Virial stress is controlled to fluctuate around an externally specified stress (i.e. applied stress).  In MD++ the Parrinello-Rahman method is implemented. The applied stress tensor &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}&amp;lt;/math&amp;gt; can be decomposed into a hydrostatic term and a deviatoric term,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sigma_{\mathrm{EXT}} = \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} + \sigma_{\mathrm{EXT}}^{\mathrm{devi}} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{hydro}} = \frac{1}{3}(\sigma_{\mathrm{EXT}})_{kk}\cdot\mathrm{I}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{devi}} = \sigma_{\mathrm{EXT}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}}&amp;lt;/math&amp;gt;. Here we used the Einstein&#039;s notation, in which repeated indices are summed over from 1 to 3, to express the sum of the diagonal components of the stress tensor. The equations of motion of Parrinello-Rahman&#039;s method can be written as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} &lt;br /&gt;
        \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} &lt;br /&gt;
        - \mathbf{H}^{-T}\dot\mathbf{G}\mathbf{H}^{-1} \dot\mathbf{r}_i \\ &lt;br /&gt;
        \ddot\mathbf{H} &amp;amp;=&amp;amp; -\frac{1}{M} \left[ \left( \sigma_{\mathrm{Virial}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} \right)\Xi &lt;br /&gt;
        - \left( \mathbf{H}\mathbf{H}_0^{-1} \sigma_{\mathrm{EXT}}^{\mathrm{devi}} \right) \Xi_0 \right]        &lt;br /&gt;
 \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is the 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix representing the simulation box at time &#039;&#039;t&#039;&#039; and &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; is the matrix corresponding to the simulation box at &#039;&#039;t&#039;&#039; = 0. &amp;lt;math&amp;gt;\mathbf{G} \equiv \mathbf{H}^T\mathbf{H}&amp;lt;/math&amp;gt; is called the metric tensor. &amp;lt;math&amp;gt;\Xi \equiv \Omega \mathbf{H}^{-T}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Xi_0 \equiv \Omega_0 \mathbf{H}_0^{-T}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Omega \equiv \det \mathbf{H}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Omega_0 \equiv \det \mathbf{H}_0&amp;lt;/math&amp;gt; are the volumes of the simulation box at time &#039;&#039;t&#039;&#039; and at time 0. &#039;&#039;M&#039;&#039; is an artificial parameter, called the &amp;quot;box mass&amp;quot;, that controlls how fast the simulation box changes its shape to reduce the difference between internal (Virial) and applied stress.&lt;br /&gt;
&lt;br /&gt;
If we apply the constant pressure &amp;lt;math&amp;gt;P_{\mathrm{EXT}} = \frac{1}{3}\left(\sigma_{\mathrm{EXT}}\right)_{kk}&amp;lt;/math&amp;gt; (notice that in MD++ a pressure correspond to positive stress, which is usually the opposite of the sign convention in elasticity theory), the deviatoric part of the external stress is zero and the second equation becomes simply&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} = -\frac{1}{M} \left[ &lt;br /&gt;
        \left( \sigma_{\mathrm{Virial}} +  P_{\mathrm{EXT}}\mathbf{I} \right)\Xi \right]        &lt;br /&gt;
&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
In this case the N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H ensemble reduces to the isoenthalpic-isobaric (NPH) ensemble.  The following script, &#039;&#039;&#039;Mo_NPH.tcl&#039;&#039;&#039;, provides an example of how to run NPH MD simulations in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NPH MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NPH&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
wallmass = 1000 boxdamp = 0.1&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
stress = [ 1000    0    0&lt;br /&gt;
              0 1000    0&lt;br /&gt;
              0    0 1000 ] # compression in MPa&lt;br /&gt;
fixboxvec = [ 0 1 1&lt;br /&gt;
              1 0 1&lt;br /&gt;
              1 1 0 ]&lt;br /&gt;
T_OBJ = 300                 # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94            # (in g/mol)&lt;br /&gt;
timestep = 0.001            # (in ps)&lt;br /&gt;
totalsteps = 10000&lt;br /&gt;
saveprop = 1 savepropfreq = 20&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
                    TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
                    TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
                    H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32&amp;quot; }&lt;br /&gt;
MD++ outpropfile = thermo-NPH.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
#MD++ finalcnfile = Mo-5X5X5-NPH.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In function &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt;, &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; to set to &#039;&#039;&#039;NPH&#039;&#039;&#039;.  The variable &#039;&#039;&#039;wallmass&#039;&#039;&#039; is the box mass parameter &#039;&#039;M&#039;&#039; in the Parrinello-Rahman (PR) method.  An artificial paramter, &#039;&#039;&#039;boxdamp&#039;&#039;&#039;, (not in the above equation of motion), is introduced to make the system converge faster to an equilibrium state.  The effect of &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is illustrated in Fig. 4.  When &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is nonzero, an additional term is introduced to the box acceleration, as in,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} := \ddot\mathbf{H}- (\mathrm{boxdamp}) \times \dot\mathbf{H}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the dynamics of the system is no longer symplectic (or reversible).  The variable &#039;&#039;&#039;stress&#039;&#039;&#039; is the external stress in unit of MPa. &amp;lt;font color=&amp;quot;blue&amp;quot;&amp;gt;Note that the sign convention of &#039;&#039;&#039;stress&#039;&#039;&#039; is opposite of that in the elasticity theory. In MD++ a pressure corresponds to positive normal stresses.&amp;lt;/font&amp;gt; &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; specifies which component of the box matrix &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; will be fixed during the MD simulation; the corresponding matrix element in &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; is 1.&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;saveH&#039;&#039;&#039; stores the current box matrix H into &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; in the Parrinello-Rahman method.  This needs to be done before starting the MD simulation.  According to Ray and Rahman&amp;lt;ref&amp;gt;J. R. Ray and A. Rahman, &amp;quot;Statistical ensembles and molecular dynamics studies of anisotropic solids&amp;quot;, J. Chem. Phys, &#039;&#039;&#039;80&#039;&#039;&#039; 4423--4428 &amp;lt;/ref&amp;gt;, &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; should be taken as the average value of &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; when the stress is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 The Effect of BoxDamp paramter in NPH MD simulation.  A finite BoxDamp speeds up the convergence toward an equilibrium state.&amp;quot; widths=&amp;quot;250px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Ext_energy_fluct_NPH.jpg|(a) Fluctuation of the total energy of the extended system (energy of the original system plus that of the box) -- a conserved quantity, as a function of time. &lt;br /&gt;
Image:Stress_fluct_NPH.jpg|(b) Stress fluctuation in NPH ensemble.&lt;br /&gt;
Image:Box_fluct.jpg|(c) Size of the simulation box as a function of time.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Isothermal-isobaric (NPT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5062</id>
		<title>M05 Finite Temperature Simulation</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M05_Finite_Temperature_Simulation&amp;diff=5062"/>
		<updated>2011-01-20T17:24:44Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Microcanonical (NVE) Ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 05 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Molecular Dynamics Simulations&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[First written, [ Jan 19 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[Last Modified, [ Apr 13 ]], [[2008]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The case studies described in Manuals 02-04 only deal with atomic positions as degrees of freedom.  For example, in Manual 02, we learned how to create a perfect crystal by MD++ command &#039;&#039;&#039;makecrystal&#039;&#039;&#039;.  In Manual 03, we varied the size of the perfect crystal to find the equilibrium lattice constants.  In Manual 04, we introduced a vacancy to the perfect crystal and let the atomic positions relax to a local energy minimum.  In this manual, we will learn how to perform finite temperature, Molecular Dynamics (MD) simulations.  For this purpose, we will need to deal with atomic velocities as degrees of freedom, as well as a number of control variables, such as integrator type, time step, and output controls.  We will learn to specify the simulation ensembles from different choices: microcanonical (NVE), canonical (NVT),&lt;br /&gt;
isoenthalpic-isobaric (NPH) and constant pressure/temperature (NPT) ensembles.  Different quantities are conserved or controlled in different ensembles.  For example, the total number of atoms (N), volume (V) and energy (E) are conserved in the (NVE) ensemble.&lt;br /&gt;
&lt;br /&gt;
=== Microcanonical (NVE) Ensemble ===&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
The NVE ensemble is the probably the best starting point to understand what happens in MD simulations.  In Statistical Mechanics, to picture the NVE ensemble, we can imagine a system of N gas molecules inside a rigid container with perfect thermal insulation.  Hence no work or heat can be exchanged between the system and the outside world (its environment).  While the gas molecules move with time, the total number of particles N, the total energy E and the total volume V of the system does not change.  A large number of replicas of the system with the same N, V, E forms the NVE, or microcanonical ensemble in Statistical Mechanics.  In MD simulations within the NVE ensemble, we usually do not simulate the rigid container --- this is because the simulation volume is usually very small and having an explicit container will lead to a large surface-to-volume ratio and large simulation artifacts.  Instead, periodic boundary conditions (PBC) are usually used in MD simulation.  If the repeat vectors of PBC do not change, the simulation volume V is kept constant during the simulation.  Since the particles follows Hamiltonian dynamics in MD simulations, the total energy E is conserved.  The total number of particles N is obviously conserved in the MD simulation.  Therefore, MD simulations under PBC with fixed repeat vectors and no thermostats (to be described later) correspond to the NVE (microcanonical) ensemble.&lt;br /&gt;
&lt;br /&gt;
The following input script &amp;lt;tt&amp;gt;mo_NVE.tcl&amp;lt;/tt&amp;gt; gives an example of running MD simulations in MD++.  You can test is by the following command (if you put this file in your &amp;lt;tt&amp;gt;scripts/&amp;lt;/tt&amp;gt; directory)&lt;br /&gt;
&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVE.tcl&lt;br /&gt;
&lt;br /&gt;
This example script first creates a perfect BCC crystal of molybdenum (Mo) with a supercell of 5[1 0 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 1 0] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[0 0 1].  It then runs MD simulations using the Finnis-Sinclair (FS) potential.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } { MD++ {&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/mo-example&lt;br /&gt;
zipfiles = 1   # zip output files&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Crystal&lt;br /&gt;
element0 = Mo&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.1472           # in Angstrom for Mo&lt;br /&gt;
latticesize = [ 1 0 0 5&lt;br /&gt;
                0 1 0 5&lt;br /&gt;
                0 0 1 5]&lt;br /&gt;
}}&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
proc readMoPot { } { MD++ {&lt;br /&gt;
# Read the potential file&lt;br /&gt;
potfile = ~/Codes/MD++/potentials/mo_pot readpot&lt;br /&gt;
}}&lt;br /&gt;
#-------------------------------------------------------------&lt;br /&gt;
proc openwindow { } { MD++ {&lt;br /&gt;
# Plot Configuration&lt;br /&gt;
atomradius = 1.0 bondradius = 0.3 bondlength = 2.725&lt;br /&gt;
atomcolor = orange highlightcolor = purple&lt;br /&gt;
bondcolor = red backgroundcolor = gray70&lt;br /&gt;
plotfreq = 10 rotateangles = [ 0 0 0 1.25 ]&lt;br /&gt;
openwin alloccolors rotate saverot eval plot&lt;br /&gt;
}}&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
# save property every 10 steps&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0   savecnfreq = 100&lt;br /&gt;
writeall = 1 DOUBLE_T = 1 &lt;br /&gt;
randseed = 12345 srand48 #randomize random number generator&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
#format of thermodynamic property file&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this Tcl script, we start with some definition of functions that will be used subsequently.  The main program starts after the comment &amp;lt;tt&amp;gt;Main program starts here&amp;lt;/tt&amp;gt;.  The program first calls the &amp;lt;tt&amp;gt;initmd&amp;lt;/tt&amp;gt; function that was defined at the beginning, which opens the output directory.  After creating the perfect crystal using the &amp;lt;tt&amp;gt;makecrystal&amp;lt;/tt&amp;gt; command, it calls the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function that initializes some important parameters for MD simulation.  (Commands and variables related with visualization as specified in the &amp;lt;tt&amp;gt;openwindow&amp;lt;/tt&amp;gt; function will be covered in a separate manual in detail.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first line in the &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt; function selects the statistica ensemble for the simulation.  The possible choices for the variable &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; are &#039;&#039;&#039;NVE&#039;&#039;&#039;, &#039;&#039;&#039;NVT&#039;&#039;&#039;, &#039;&#039;&#039;NPH&#039;&#039;&#039; and &#039;&#039;&#039;NPT&#039;&#039;&#039;.  The type of the numerical integrator is specified by the &#039;&#039;&#039;integrator_type&#039;&#039;&#039; variable and can be either the Gear 6-th order predictor-corrector algorithm (&#039;&#039;&#039;Gear6&#039;&#039;&#039;) or the velocity Verlet algorithm (&#039;&#039;&#039;VVerlet&#039;&#039;&#039;).  The predictor-corrector integrator has a higher order of accuracy but velocity Verlet is a symplectic integrator and is more stable at larger algorithm.  We recommend the use of velocity Verlet algorithm whenever possible (i.e. if it is implemented for the chosen ensemble type).&lt;br /&gt;
&lt;br /&gt;
The variable &#039;&#039;&#039;atommass&#039;&#039;&#039; specifies the atomic mass in unit of g/mol. &#039;&#039;&#039;timestep&#039;&#039;&#039; specifies the integrator time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; in unit of picosecond. &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is the total number of time steps for the MD simulation.  Hence &#039;&#039;&#039;totalsteps&#039;&#039;&#039; times &#039;&#039;&#039;timestep&#039;&#039;&#039; is the total time duration of the MD simulation.  We usually choose &#039;&#039;&#039;timestep&#039;&#039;&#039; to be as large as possible provided that the total energy of the system is conserved within an acceptable accurady.  &#039;&#039;&#039;totalsteps&#039;&#039;&#039; is usually chosen so that the total simulation time is long enough for the system to reach an equilibrium or steady state (usually on the order of picoseconds). &lt;br /&gt;
&lt;br /&gt;
The command &amp;lt;tt&amp;gt;initvelocity&amp;lt;/tt&amp;gt; assign random numbers to the atomic velocities and then scale them so that the instantaneous temperature matches the target value, as specified by &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; in unit of K.  Strictly speaking, temperature is not well defined in an NVE ensemble (but is well defined in the NVT ensemble).  Here we can regard &#039;&#039;&#039;T_OBJ&#039;&#039;&#039; as a measure of the instantaneous kinetic energy of the system.  MD++ uses the &amp;lt;tt&amp;gt;drand48()&amp;lt;/tt&amp;gt; to generate random numbers for the velocities.  The random number generator can be initialized by calling &amp;lt;tt&amp;gt;srand48&amp;lt;/tt&amp;gt; with a specified &#039;&#039;&#039;randseed&#039;&#039;&#039;.  This approach is more convenient for debugging because the same &#039;&#039;&#039;randseed&#039;&#039;&#039; garauntees exactly the same random number sequence will be generated if you run the simulation again.  On the other hand, you may use the function &amp;lt;tt&amp;gt;srandbytime&amp;lt;/tt&amp;gt; to use the current time as the random seed for initializing the random number generator.  This makes sure that ever time you run the simulation again a completely different set of random numbers will be generated.&lt;br /&gt;
&lt;br /&gt;
If the parameter &#039;&#039;&#039;DOUBLE_T&#039;&#039;&#039; is set to 1, then the velocities are scaled in such a way that the instantaneous temperature is twice of &#039;&#039;&#039;T_OBJ&#039;&#039;&#039;, as illustrated in Fig.1.  The reason we may want to set &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; is the following.  When we assign velocities to the atoms in a perfect crystal, the instantaneous temperature almost always drop to half of its initial value when thermal equilibrium is reached (see Fig.1).  This is due to the energy equipartition theorem.  For solids at temperatures much below the melting temperature, the Hamiltonian is close to that of a set of coupled harmonic oscillators.  The total energy of a harmonic system is equally divided between the average kinetic energy and the average potential energy.  Because the total energy is conserved in an NVE-ensemble simulation, the kinetic energy is bound to decrease by half if the kinetic energy and potential energy (initially zero) are equal (in time average) when equilibrium is reached.  Setting &amp;lt;tt&amp;gt;DOUBLE_T = 1&amp;lt;/tt&amp;gt; allows the temperature at the equilibrium state to match the desired temperature.&lt;br /&gt;
                                                                        &lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.1 Instantaneous temperature as a function of time during MD simulations with different settings for DOUBLE_T.&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
Image:Temp_double.jpg&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;saveprop&#039;&#039;&#039; and &#039;&#039;&#039;savepropfreq&#039;&#039;&#039; specify whether or not and how often the simulation properties will be saved periodically in a data file. If  &amp;lt;tt&amp;gt;saveprop = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10&amp;lt;/tt&amp;gt;, the properties such as potential energy, kinetic energy and temperature will be save every 10 simulation steps, provided that the MD++ command &#039;&#039;&#039;openpropfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the property file is specified by the &#039;&#039;&#039;outputfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;prop.out&amp;lt;/tt&amp;gt; by default.  The setting &amp;lt;tt&amp;gt;zipfiles = 1&amp;lt;/tt&amp;gt; at the beginning of this script file (line 11) specifies that both property files and atomic configuration files (see below) will be automatically zipped (by gzip) after they are written.&lt;br /&gt;
&lt;br /&gt;
The content of a property ﬁle is defined by variable &#039;&#039;&#039;output_fmt&#039;&#039;&#039;.  In this example, each line of the property file will contain the current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), and temperature (&#039;&#039;&#039;Tinst&#039;&#039;&#039;).  If we do not specify &#039;&#039;&#039;output_fmt&#039;&#039;&#039;, the default content of the property file will be current step (&#039;&#039;&#039;curstep&#039;&#039;&#039;), kinetic energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), pressure (&#039;&#039;&#039;PRESSURE&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{xy}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_xy&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{yz}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_yz&#039;&#039;&#039;), &amp;lt;math&amp;gt;\sigma_{zx}&amp;lt;/math&amp;gt; (&#039;&#039;&#039;TSTRESS_zx&#039;&#039;&#039;), &#039;&#039;&#039;HELM&#039;&#039;&#039;, the extended energy(&#039;&#039;&#039;HELMP&#039;&#039;&#039;), thermodynamic friction coeﬃcient (&#039;&#039;&#039;zeta&#039;&#039;&#039;), reversible work increment &#039;&#039;&#039;dEdlambda&#039;&#039;&#039; and volume (&#039;&#039;&#039;OMEGA&#039;&#039;&#039;).  The energies are in unit of eV and stresses in eV/A˚^3. Please note that there is an &amp;lt;font color=&#039;blue&#039;&amp;gt;overall minus sign&amp;lt;/font&amp;gt; between the stress variables in MD++ and that in conventional elasticity theory.  For example, a positive pressure correspond to positive normal stress components in MD++ but negative normal stress components in elasticity theory.  This is because in MD++, we followed the sign convention of Parrinello and Rahman for stress control.&amp;lt;ref&amp;gt;M. Parrinello and A. Rahman, &amp;quot;Polymorphic transitions in single crystals: A new molecular dynamics method&amp;quot;, J. Appl. Phys &#039;&#039;&#039;52&#039;&#039;&#039; 7182-7190 1981&amp;lt;/ref&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
The parameters &#039;&#039;&#039;savecn&#039;&#039;&#039; and &#039;&#039;&#039;savecnfreq&#039;&#039;&#039; specify whether or not and how often the atomic coordinates (and velocities if &#039;&#039;&#039;writeall = 1&#039;&#039;&#039;) will be saved as .cn files during the MD simulation. If  &amp;lt;tt&amp;gt;savecn = 1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;savepropfreq = 10000&amp;lt;/tt&amp;gt;, the intermediate .cn files will be saved every 10000 steps, provided that the MD++ command &#039;&#039;&#039;openintercnfile&#039;&#039;&#039; is called before the command &#039;&#039;&#039;run&#039;&#039;&#039;.  The name of the intermediate .cn files are specified by the &#039;&#039;&#039;intercnfile&#039;&#039;&#039; variable and is &amp;lt;tt&amp;gt;inter####.cn&amp;lt;/tt&amp;gt; by default, where #### are integers (starting with 0000) that will be automatically incremented by one after each file is written.  In this example, &amp;lt;tt&amp;gt;savecn = 0&amp;lt;/tt&amp;gt; so no intermediate .cn files will be saved.  After all the relevant parameters have been set up, the MD++ command &#039;&#039;&#039;run&#039;&#039;&#039; starts the MD simulation. &lt;br /&gt;
&lt;br /&gt;
After the simulation is finished, a property file named &amp;lt;tt&amp;gt;thermo.out&amp;lt;/tt&amp;gt; will be written in the output directory &amp;lt;tt&amp;gt;runs/mo-example&amp;lt;/tt&amp;gt;.  This file can be loaded and plotted by programs such as Matlab, Octave, or Gnuplot.&amp;lt;ref&amp;gt;A simple way to plot the total energy using gnuplot (a free software on Unix/Linux) is to run the command. &lt;br /&gt;
 plot &amp;quot;thermo.out&amp;quot; u ($1):($2+$3) with line&lt;br /&gt;
&amp;lt;/ref&amp;gt; &lt;br /&gt;
Fig.2 plots the total energy per atom and instantanous temperature for two simulations with different sizes. The larger system (10[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 10[001]) has eight times more atoms than the smaller one (5[100] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[010] &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 5[001]).  As expected, the data for the larger system experience less statistical fluctuation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.2 Energy and Temperature fluctuation of NVE ensemble&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Energy_fluct.jpg|(a) Energy Fluctuation in NVE ensemble. &lt;br /&gt;
Image:Temp_fluct.jpg|(b) Temperature in NVE ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the &#039;&#039;&#039;run&#039;&#039;&#039; command, the script file calls the command &#039;&#039;&#039;writecn&#039;&#039;&#039; to save the final atomic configuration into a .cn file whose name is specified by &#039;&#039;&#039;finalcnfile&#039;&#039;&#039;.  The .cn file has the following format.  The first line contains  the total number of atoms &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt;.  The following &amp;lt;tt&amp;gt;NP&amp;lt;/tt&amp;gt; lines then contain the scaled coordinates of all atoms: &amp;lt;math&amp;gt;s_x^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_y^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;s_z^{(i)}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;i = 1, 2, \cdots NP&amp;lt;/math&amp;gt;.  The last three lines of the .cn file specify a 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; whose column vectors are the three repeat vectors of the simulation supercell (subjected to periodic boundary conditions). The real coordinates of an atom (x, y, z ) and the scaled coordinates for each atom are related through &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; as follows&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \left( \begin{array}{c} x \\ y \\ z \end{array} \right) =  \left( \begin{array}{ccc} H_{11} &amp;amp; H_{12} &amp;amp; H_{13} \\ H_{21} &amp;amp; H_{22} &amp;amp; H_{23} \\ H_{31} &amp;amp; H_{32} &amp;amp; H_{33} \end{array} \right) \left( \begin{array}{c} s_x \\ s_y \\ s_z \end{array} \right)&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt; is specified before &#039;&#039;&#039;writecn&#039;&#039;&#039;, additional informations are added to the &#039;&#039;NP&#039;&#039; lines of data.  Following the scaled coordinates, each line will also contain the scaled velocities (&#039;&#039;&#039;_VSR[i].x&#039;&#039;&#039;, &#039;&#039;&#039;_VSR[i].y&#039;&#039;&#039; and &#039;&#039;&#039;_VSR[i].z&#039;&#039;&#039;), local potential energy (&#039;&#039;&#039;_EPOT_IND[i]&#039;&#039;&#039;), flag (&#039;&#039;&#039;fixed[i]&#039;&#039;&#039;), central-symmetry-deviation paramter (&#039;&#039;&#039;_TOPOL[i]&#039;&#039;&#039;), atom species (&#039;&#039;&#039;species[i]&#039;&#039;&#039;), atom groups (&#039;&#039;&#039;group[i]&#039;&#039;&#039;) and image index (&#039;&#039;&#039;image[i]&#039;&#039;&#039;).  You can see this diﬀerence by comparing two conﬁguration ﬁles, &#039;&#039;&#039;perf.cn&#039;&#039;&#039; (written before setting &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;) and &#039;&#039;&#039;init.cn&#039;&#039;&#039; (written after).  If &amp;lt;tt&amp;gt;writevelocity = 1&amp;lt;/tt&amp;gt; is used instead of &amp;lt;tt&amp;gt;writeall = 1&amp;lt;/tt&amp;gt;, then only the scaled velocities are added behind the three columns for scaled coordinates. &lt;br /&gt;
&lt;br /&gt;
At the end of the example script, the command &#039;&#039;&#039;sleep&#039;&#039;&#039; is called so that the graphics window to stay open (i.e. alive) for a while so that we can examine the atomic structure.  You can press ctrl-c in the terminal to exit.  You can also comment out the &#039;&#039;&#039;sleep&#039;&#039;&#039; command in the script file so that MD++ exits immediately after reaching the end of the input file.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In the NVT ensemble of Statistical Mechanics, the system exchanges heat with an external thermostat to maintain its temperature at T but its total energy is no longer conserved.  The following script &amp;lt;tt&amp;gt;mo_NVT.tcl&amp;lt;/tt&amp;gt; provides an example of NVT simulations in MD++.  You can test it by typing&lt;br /&gt;
 $ bin/fs_gpp scripts/mo_NVT.tcl&lt;br /&gt;
This script first reads in an atomic configuration generated by the previous MD simulation (NVE ensemble) and then performs MD simulation in the NVT ensemble at T = 300 K using the Nose-Hoover thermostat&amp;lt;ref&amp;gt; S. Nose, “A Molecular Dynamics Method for Simulations in the Canonical Ensemble”, Molecular Physics, &#039;&#039;&#039;52&#039;&#039;&#039; 255 (1984)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVT MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVT&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
implementation_type = 0 vt2 = 1e28&lt;br /&gt;
T_OBJ = 300       # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94  # (g/mol)&lt;br /&gt;
timestep = 0.001 # (ps)&lt;br /&gt;
totalsteps = 2000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
}}&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = 300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVT.out openpropfile&lt;br /&gt;
MD++ run eval &lt;br /&gt;
#reverse velocity (to test reversibility)&lt;br /&gt;
MD++ input = -1 multiplyvelocity&lt;br /&gt;
#MD simulation (reverse)&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ finalcnfile = 300K-5X5X5-NVT.cn writecn&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Instead of creating a perfect crystal as the initial condition, this script uses the command &#039;&#039;&#039;readcn&#039;&#039;&#039; to read the file &amp;lt;tt&amp;gt;300K_5X5X5.cn&amp;lt;/tt&amp;gt; created at the end of the previous simulation (NVE ensemble simulation).  Note that in this case, the new simulation must use the same time step as the previous simulation that created the .cn file.  This is because in MD++ the velocity information are stored as scaled velocity time the time step.  If you really need to change the time step in the new simulation (not recommended), you will need to rescale your velocity using the MD++ command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Setting &#039;&#039;&#039;ensemble_type = &amp;quot;NVT&amp;quot;&#039;&#039;&#039; activates the Nose-Hoover thermostat, which adds a variable (&amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt;) to the equation of motion.  This variable mimicks the heat deposited to the heat reservoir.  The coupled equation of motion is&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} - \zeta \dot\mathbf{r}_i \\ \dot\zeta &amp;amp;=&amp;amp; \frac{3N k_B}{Q} ( T_{\mathrm{inst}} - T_{\mathrm{OBJ}} ) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
for MD simulations of N particles in 3-dimensions.  We can use three different implementations of the Nose-Hoover thermostat in conjunction with the velocity Verlet integrator.  When &amp;lt;tt&amp;gt;implementation_type = 0&amp;lt;/tt&amp;gt;, an implicit integrator is used.  When &amp;lt;tt&amp;gt;implementation_type = 1&amp;lt;/tt&amp;gt;, an explicit integrator based on Stormer-Verlet method is used.  When &amp;lt;tt&amp;gt;implementation_type = 2&amp;lt;/tt&amp;gt;, an explicit integrator baed on Liouville formulation is used.&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;NHMass&#039;&#039;&#039;, in the unit of eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, corresponds to the Nose-Hoover thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; in the above equation of motion. The thermal mass &amp;lt;math&amp;gt;Q&amp;lt;/math&amp;gt; can also be specified through the MD++ variable &#039;&#039;&#039;vt2&#039;&#039;&#039; , in the unit of (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;, by the following relationship&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; Q = \frac{3 N k_B T_{\mathrm{OBJ}}}{\mathrm{vt2}}\times (1e+24)&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;N&#039;&#039; is number of atoms and &#039;&#039;k_B&#039;&#039; is the Boltzmann constant (8.617343e-5 eV/K). &lt;br /&gt;
&amp;lt;!-- For convenience, we also defined thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039;, which is exactly the Nose&#039;-Hoover thermal mass &#039;&#039;Q&#039;&#039;.  --&amp;gt;&lt;br /&gt;
When &#039;&#039;&#039;NHMass&#039;&#039;&#039; is non-zero, &#039;&#039;&#039;vt2&#039;&#039;&#039; will be superceded. When &#039;&#039;N&#039;&#039; = 250 and &#039;&#039;T&#039;&#039; = 300 K (or k_B T ~ 0.026 eV), &#039;&#039;&#039;vt2&#039;&#039;&#039; = 1e28 (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; corresponds to &#039;&#039;&#039;NHMass&#039;&#039;&#039; = 1.95e-03 (eV&amp;amp;middot;ps&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;). In comparison with other MD programs such as [http://lammps.sandia.gov  LAMMPS], &#039;&#039;&#039;vt2&#039;&#039;&#039; is proportional to the square of the thermal damping frequency &amp;amp;omega;, or &#039;&#039;&#039;vt2&#039;&#039;&#039;~&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. The proportional constant is determined by equating both units. If &amp;amp;omega; is given in the unit of 1/ps, then the equality becomes &#039;&#039;&#039;vt2&#039;&#039;&#039;= 10&amp;lt;sup&amp;gt;24&amp;lt;/sup&amp;gt;&amp;amp;omega;&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;. In this case, &amp;amp;omega; = 100 (1/ps) for &#039;&#039;&#039;vt2&#039;&#039;&#039;=10&amp;lt;sup&amp;gt;28&amp;lt;/sup&amp;gt; (1/sec)&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The bigger &#039;&#039;&#039;vt2&#039;&#039;&#039; is (or the smaller &#039;&#039;&#039;NHMass&#039;&#039;&#039; is), the faster the instantaneous temperature fluctuates around the desired temperature, as shown in Fig. 3.  The MD++ simulation also writes out the value of a variable &#039;&#039;&#039;HELMP&#039;&#039;&#039; in the property file; &#039;&#039;&#039;HELMP&#039;&#039;&#039; is the total energy of the system plus that of the thermal reservior, and should be conserved.  The flucutation of &#039;&#039;&#039;HELMP&#039;&#039;&#039; around its mean value is also plotted in Fig. 3.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.3 The Effect of Nose-Hoover Mass in NVT MD&amp;quot; widths=&amp;quot;300px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;2&amp;quot;&amp;gt;&lt;br /&gt;
Image:Helmp_fluct.jpg|(a) Helmholtz energy fluctuation in NVT ensemble. &lt;br /&gt;
Image:Temp_fluct_NVT.jpg|(b) Temperature in NVT ensemble&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In figure 3, you may notice that the energy and the temperature are symmetric before and after the simulation step = 2000. In the above example script, after the first MD simulation (or after the 1st 2000 steps), we use the command &#039;&#039;&#039;multiplyvelocity&#039;&#039;&#039; to reverse the velocities of all atoms.  This is done by setting &amp;lt;tt&amp;gt;input = -1&amp;lt;/tt&amp;gt;, so that -1 can be multiplied to the velocities of all atoms and also to &amp;amp;zeta;.  We then continue the MD simulation for the same duration of time as the first one, in order to test the reversibility of the numerical (symplectic) integrator.  After the second MD simulation (in the reverse direction), we save the atomic configuration into file &amp;lt;tt&amp;gt;300K-5x5x5-NVT.cn&amp;lt;/tt&amp;gt;.  Comparing this file with the file &amp;lt;tt&amp;gt;300K-5x5x5.cn&amp;lt;/tt&amp;gt;, which contains the atomic configuration at the beginning of the (forward) simulation, reveals that the scaled coordinates of all atoms are identical in the two files within 1e-14 (close to the machine precision).  This demonstrates the reversibility of the chosen integrator.  If on the other hand, &amp;lt;tt&amp;gt;integrator_type = Gear6&amp;lt;/tt&amp;gt; is used, the discrepancy in the atomic coordinates will be on the order of 1e-6, which shows that the Gear6 integrator is not reversible.&lt;br /&gt;
&lt;br /&gt;
=== Canonical(NVT) Ensemble with Nose-Hoover Chain ===&lt;br /&gt;
----&lt;br /&gt;
Martyna &#039;&#039;et al&#039;&#039;&amp;lt;ref&amp;gt;G. J. Martyna, M. L. Klein and M. Tuckerman, &amp;quot;Nose-Hoover chains: The canonical ensemble via continuous dynamics&amp;quot;, J. Chem. Phys. &#039;&#039;&#039;97&#039;&#039;&#039; 2635--2643&amp;lt;/ref&amp;gt; modified the original Nose-Hoover thermostat so that a chain of thermostats are used instead of just one thermostat. The purpose of this chain method is to increase the size of the phase space and help the system to be ergodic when the system is stiff or is not ergodic.  Our implementation of the Nose-Hoover chain method in MD++ follows another paper of Martyna.&amp;lt;ref&amp;gt;G. J. Martyna, &amp;quot;Explicit reversible integrators for extended systems dynamics&amp;quot;, Molecular Physics &#039;&#039;&#039;87&#039;&#039;&#039; 1117-1157 (1996)&amp;lt;/ref&amp;gt;  The following example script, &amp;lt;tt&amp;gt;Mo_NVTC.tcl&amp;lt;/tt&amp;gt;, demonstrates how to use the Nose-Hoover chain method in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NVE MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# ... omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NVTC&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
NHChainLen = 4                       # MAXNHCLEN = 20 in md.h&lt;br /&gt;
NHMass = [ 1.95e-4 2e-6 2e-6 2e-6 ]&lt;br /&gt;
T_OBJ = 300        # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94   # (in g/mol)&lt;br /&gt;
timestep = 0.001   # (in ps)&lt;br /&gt;
totalsteps = 5000&lt;br /&gt;
saveprop = 1 savepropfreq = 10&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ {&lt;br /&gt;
  incnfile = ../mo-example/300K-5X5X5.cn&lt;br /&gt;
  atommass = 95.94 timestep = 0.001&lt;br /&gt;
  readcn eval&lt;br /&gt;
}&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP&amp;quot;}&lt;br /&gt;
MD++ outpropfile = thermo-NVTC.out openpropfile&lt;br /&gt;
MD++ run eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; is set to &amp;lt;tt&amp;gt;NVTC&amp;lt;/tt&amp;gt; instead of &amp;lt;tt&amp;gt;NVT&amp;lt;/tt&amp;gt;.  The number of chains is specified in &#039;&#039;&#039;NHChainLen&#039;&#039;&#039; and the masses for each thermostat on the chain are specified as an array in &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  &#039;&#039;&#039;NHMass&#039;&#039;&#039; need to be chosen with caution, otherwise the system may lose reversibility, even though Martyna &#039;&#039;et al&#039;&#039; stated that the choice of thermal mass &#039;&#039;&#039;NHMass&#039;&#039;&#039; is not critical.  Martyna &#039;&#039;et all&#039;&#039; suggested the following choice for &#039;&#039;&#039;NHMass&#039;&#039;&#039;.  For a chain of length M that is designed to act as a thermostat for N particles (with &amp;lt;math&amp;gt;N_f = 3 N&amp;lt;/math&amp;gt; degrees of freedom), we can set &lt;br /&gt;
&lt;br /&gt;
 NHMass[0] ~ &amp;lt;math&amp;gt; N_f k_B T / \omega^2&amp;lt;/math&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 NHMass[i] ~ &amp;lt;math&amp;gt; k_B T / \omega^2&amp;lt;/math&amp;gt; (for &#039;&#039;i&#039;&#039; = 1 to &#039;&#039;M-1&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
The thermostats &amp;lt;math&amp;gt; i = 1, \cdots, M-1&amp;lt;/math&amp;gt; fluctuates with a characteristic frequency &amp;lt;math&amp;gt;\omega&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Constant Stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
In MD simulations using a constant stress (N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H) ensemble, the internal Virial stress is controlled to fluctuate around an externally specified stress (i.e. applied stress).  In MD++ the Parrinello-Rahman method is implemented. The applied stress tensor &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}&amp;lt;/math&amp;gt; can be decomposed into a hydrostatic term and a deviatoric term,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sigma_{\mathrm{EXT}} = \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} + \sigma_{\mathrm{EXT}}^{\mathrm{devi}} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{hydro}} = \frac{1}{3}(\sigma_{\mathrm{EXT}})_{kk}\cdot\mathrm{I}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\sigma_{\mathrm{EXT}}^{\mathrm{devi}} = \sigma_{\mathrm{EXT}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}}&amp;lt;/math&amp;gt;. Here we used the Einstein&#039;s notation, in which repeated indices are summed over from 1 to 3, to express the sum of the diagonal components of the stress tensor. The equations of motion of Parrinello-Rahman&#039;s method can be written as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} &lt;br /&gt;
        \ddot\mathbf{r}_i &amp;amp;=&amp;amp; -\frac{1}{m_i}\frac{\partial U(\{\mathbf{r}_i\})}{\partial \mathbf{r}_i} &lt;br /&gt;
        - \mathbf{H}^{-T}\dot\mathbf{G}\mathbf{H}^{-1} \dot\mathbf{r}_i \\ &lt;br /&gt;
        \ddot\mathbf{H} &amp;amp;=&amp;amp; -\frac{1}{M} \left[ \left( \sigma_{\mathrm{Virial}} - \sigma_{\mathrm{EXT}}^{\mathrm{hydro}} \right)\Xi &lt;br /&gt;
        - \left( \mathbf{H}\mathbf{H}_0^{-1} \sigma_{\mathrm{EXT}}^{\mathrm{devi}} \right) \Xi_0 \right]        &lt;br /&gt;
 \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is the 3 &amp;lt;math&amp;gt;\times&amp;lt;/math&amp;gt; 3 matrix representing the simulation box at time &#039;&#039;t&#039;&#039; and &amp;lt;math&amp;gt;\mathbf{H}_0&amp;lt;/math&amp;gt; is the matrix corresponding to the simulation box at &#039;&#039;t&#039;&#039; = 0. &amp;lt;math&amp;gt;\mathbf{G} \equiv \mathbf{H}^T\mathbf{H}&amp;lt;/math&amp;gt; is called the metric tensor. &amp;lt;math&amp;gt;\Xi \equiv \Omega \mathbf{H}^{-T}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Xi_0 \equiv \Omega_0 \mathbf{H}_0^{-T}&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\Omega \equiv \det \mathbf{H}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\Omega_0 \equiv \det \mathbf{H}_0&amp;lt;/math&amp;gt; are the volumes of the simulation box at time &#039;&#039;t&#039;&#039; and at time 0. &#039;&#039;M&#039;&#039; is an artificial parameter, called the &amp;quot;box mass&amp;quot;, that controlls how fast the simulation box changes its shape to reduce the difference between internal (Virial) and applied stress.&lt;br /&gt;
&lt;br /&gt;
If we apply the constant pressure &amp;lt;math&amp;gt;P_{\mathrm{EXT}} = \frac{1}{3}\left(\sigma_{\mathrm{EXT}}\right)_{kk}&amp;lt;/math&amp;gt; (notice that in MD++ a pressure correspond to positive stress, which is usually the opposite of the sign convention in elasticity theory), the deviatoric part of the external stress is zero and the second equation becomes simply&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} = -\frac{1}{M} \left[ &lt;br /&gt;
        \left( \sigma_{\mathrm{Virial}} +  P_{\mathrm{EXT}}\mathbf{I} \right)\Xi \right]        &lt;br /&gt;
&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
In this case the N&amp;lt;math&amp;gt;\sigma&amp;lt;/math&amp;gt;H ensemble reduces to the isoenthalpic-isobaric (NPH) ensemble.  The following script, &#039;&#039;&#039;Mo_NPH.tcl&#039;&#039;&#039;, provides an example of how to run NPH MD simulations in MD++.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script -*-&lt;br /&gt;
# run NPH MD simulation of perfect crystal of Mo.&lt;br /&gt;
#&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
#&lt;br /&gt;
# omitted here to save space ...&lt;br /&gt;
#&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
#MD settings&lt;br /&gt;
ensemble_type = &amp;quot;NPH&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
wallmass = 1000 boxdamp = 0.1&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
stress = [ 1000    0    0&lt;br /&gt;
              0 1000    0&lt;br /&gt;
              0    0 1000 ] # compression in MPa&lt;br /&gt;
fixboxvec = [ 0 1 1&lt;br /&gt;
              1 0 1&lt;br /&gt;
              1 1 0 ]&lt;br /&gt;
T_OBJ = 300                 # (in Kelvin) Desired Temperature&lt;br /&gt;
atommass = 95.94            # (in g/mol)&lt;br /&gt;
timestep = 0.001            # (in ps)&lt;br /&gt;
totalsteps = 10000&lt;br /&gt;
saveprop = 1 savepropfreq = 20&lt;br /&gt;
savecn = 0 savecnfreq = 100&lt;br /&gt;
writeall = 1&lt;br /&gt;
DOUBLE_T = 0 randseed = 12345 srand48&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
readMoPot&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
openwindow&lt;br /&gt;
#---------------------------------------------&lt;br /&gt;
# run MD&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ initvelocity finalcnfile = init.cn writecn&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
                    TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
                    TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
                    H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32&amp;quot; }&lt;br /&gt;
MD++ outpropfile = thermo-NPH.out openpropfile&lt;br /&gt;
MD++ run closepropfile&lt;br /&gt;
#MD++ finalcnfile = Mo-5X5X5-NPH.cn writecn eval&lt;br /&gt;
MD++ sleep quit&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In function &amp;lt;tt&amp;gt;setup_md&amp;lt;/tt&amp;gt;, &#039;&#039;&#039;ensemble_type&#039;&#039;&#039; to set to &#039;&#039;&#039;NPH&#039;&#039;&#039;.  The variable &#039;&#039;&#039;wallmass&#039;&#039;&#039; is the box mass parameter &#039;&#039;M&#039;&#039; in the Parrinello-Rahman (PR) method.  An artificial paramter, &#039;&#039;&#039;boxdamp&#039;&#039;&#039;, (not in the above equation of motion), is introduced to make the system converge faster to an equilibrium state.  The effect of &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is illustrated in Fig. 4.  When &#039;&#039;&#039;boxdamp&#039;&#039;&#039; is nonzero, an additional term is introduced to the box acceleration, as in,&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \ddot\mathbf{H} := \ddot\mathbf{H}- (\mathrm{boxdamp}) \times \dot\mathbf{H}&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the dynamics of the system is no longer symplectic (or reversible).  The variable &#039;&#039;&#039;stress&#039;&#039;&#039; is the external stress in unit of MPa. &amp;lt;font color=&amp;quot;blue&amp;quot;&amp;gt;Note that the sign convention of &#039;&#039;&#039;stress&#039;&#039;&#039; is opposite of that in the elasticity theory. In MD++ a pressure corresponds to positive normal stresses.&amp;lt;/font&amp;gt; &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; specifies which component of the box matrix &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; will be fixed during the MD simulation; the corresponding matrix element in &#039;&#039;&#039;fixboxvec&#039;&#039;&#039; is 1.&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;saveH&#039;&#039;&#039; stores the current box matrix H into &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; in the Parrinello-Rahman method.  This needs to be done before starting the MD simulation.  According to Ray and Rahman&amp;lt;ref&amp;gt;J. R. Ray and A. Rahman, &amp;quot;Statistical ensembles and molecular dynamics studies of anisotropic solids&amp;quot;, J. Chem. Phys, &#039;&#039;&#039;80&#039;&#039;&#039; 4423--4428 &amp;lt;/ref&amp;gt;, &amp;lt;math&amp;gt;\mathrm{H}_0&amp;lt;/math&amp;gt; should be taken as the average value of &amp;lt;math&amp;gt;\mathrm{H}&amp;lt;/math&amp;gt; when the stress is zero.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery caption=&amp;quot;Fig.4 The Effect of BoxDamp paramter in NPH MD simulation.  A finite BoxDamp speeds up the convergence toward an equilibrium state.&amp;quot; widths=&amp;quot;250px&amp;quot; heights=&amp;quot;200px&amp;quot; perrow=&amp;quot;3&amp;quot;&amp;gt;&lt;br /&gt;
Image:Ext_energy_fluct_NPH.jpg|(a) Fluctuation of the total energy of the extended system (energy of the original system plus that of the box) -- a conserved quantity, as a function of time. &lt;br /&gt;
Image:Stress_fluct_NPH.jpg|(b) Stress fluctuation in NPH ensemble.&lt;br /&gt;
Image:Box_fluct.jpg|(c) Size of the simulation box as a function of time.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Isothermal-isobaric (NPT) Ensemble ===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=VASP_Computing_Bulk_Modulus_of_Au&amp;diff=5061</id>
		<title>VASP Computing Bulk Modulus of Au</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=VASP_Computing_Bulk_Modulus_of_Au&amp;diff=5061"/>
		<updated>2011-01-19T08:32:53Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Input files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;FONT SIZE=&amp;quot;+3&amp;quot; color=&amp;quot;darkred&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;&lt;br /&gt;
VASP: Computing Bulk Modulus of Au&amp;lt;/STRONG&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt; &amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Input files===&lt;br /&gt;
&lt;br /&gt;
Here we give an example of how to use VASP to compute the bulk modulus of LDA-Au.  We performed this calculation on &amp;lt;tt&amp;gt;MC-CC&amp;lt;/tt&amp;gt; in serial model in the &amp;lt;tt&amp;gt;~/Codes/VASP/runs/Au/LDA/perfect.21x21x21&amp;lt;/tt&amp;gt; directory.  This directory contains the following files.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;INCAR&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENCUT  =  400&lt;br /&gt;
ISMEAR  = 1&lt;br /&gt;
SIGMA = 0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;KPOINTS&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
21x21x21&lt;br /&gt;
0        0 = automatic generation of k-points&lt;br /&gt;
Monkhorst&lt;br /&gt;
21 21 21&lt;br /&gt;
0 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;POSCAR&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POSCAR for FCC Au (created manually)&lt;br /&gt;
   4.068 &lt;br /&gt;
   0    0.5  0.5&lt;br /&gt;
   0.5  0    0.5&lt;br /&gt;
   0.5  0.5  0&lt;br /&gt;
   1 &lt;br /&gt;
Cartesian  (real coordinates r)&lt;br /&gt;
   0    0    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To do this calculation, you also need to put the LDA pseudopotential file as &amp;lt;tt&amp;gt;POTCAR&amp;lt;/tt&amp;gt; in this directory.&lt;br /&gt;
&lt;br /&gt;
===Run VASP===&lt;br /&gt;
&lt;br /&gt;
Now we are ready to run&lt;br /&gt;
&lt;br /&gt;
 vasp&lt;br /&gt;
&lt;br /&gt;
To compute the equilibrium lattice constant, cohesive energy and bulk modulus, we use the following script &amp;lt;tt&amp;gt;auto.B.serial&amp;lt;/tt&amp;gt; to run &amp;lt;tt&amp;gt;vasp&amp;lt;/tt&amp;gt; repeated with different lattice constants.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
rm WAVECAR &lt;br /&gt;
for a in 4.056 4.058 4.060 4.062 4.064 4.066 4.068&lt;br /&gt;
do&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
POSCAR for FCC Au (created manually)&lt;br /&gt;
   $a &lt;br /&gt;
   0    0.5  0.5&lt;br /&gt;
   0.5  0    0.5&lt;br /&gt;
   0.5  0.5  0&lt;br /&gt;
   1 &lt;br /&gt;
Cartesian  (real coordinates r)&lt;br /&gt;
   0    0    0&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;a=$a&amp;quot;&lt;br /&gt;
./vasp&lt;br /&gt;
&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E | sed -s &#039;s/F=//; s/E0=//; s/d E =//;&#039; &amp;gt;&amp;gt; Elatt.B.dat&lt;br /&gt;
&lt;br /&gt;
p=`grep pressure OUTCAR | cut -b 25-34`&lt;br /&gt;
echo $a $p &amp;gt;&amp;gt; platt.B.dat&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyze data===&lt;br /&gt;
&lt;br /&gt;
After running it as &amp;lt;tt&amp;gt;./auto.B.serial&amp;lt;/tt&amp;gt;, it will create data files &amp;lt;tt&amp;gt;Elatt.B.dat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;platt.B.dat&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Launch &amp;lt;tt&amp;gt;octave&amp;lt;/tt&amp;gt; and run the following functions [[media:fit_a0EB.m.txt | fit_a0EB.m]] and [[media:fit_a0B.m.txt | fit_a0B.m]],&lt;br /&gt;
&lt;br /&gt;
 fit_a0EB(&#039;Elatt.B.dat&#039;);&lt;br /&gt;
 fit_a0B (&#039;platt.B.dat&#039;);&lt;br /&gt;
&lt;br /&gt;
The first line fits the energy data to a quadratic curve and computes the equilibrium lattice constant, cohesive energy and bulk modulus.  The second line fits the pressure data to a linear curve and computes the equilibrium lattice constant and bulk modulus.  In this example, the result is a0 = 4.06 angstrom, Ecoh = -4.39 eV, B = 190 GPa.&lt;br /&gt;
&lt;br /&gt;
===Parallel computation===&lt;br /&gt;
&lt;br /&gt;
To run &amp;lt;tt&amp;gt;vasp&amp;lt;/tt&amp;gt; in parallel, you need to submit [[media:vasp.pbs.txt | vasp.pbs]] as&lt;br /&gt;
&lt;br /&gt;
 qsub vasp.pbs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need the following two files to do this calculation in parallel on SU-AHPCRC: &lt;br /&gt;
[[media:auto.B.par.Au.txt | auto.B.par]] and&lt;br /&gt;
[[media:B.pbs.Au.txt | B.pbs]].&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=VASP_Computing_Bulk_Modulus_of_Au&amp;diff=5060</id>
		<title>VASP Computing Bulk Modulus of Au</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=VASP_Computing_Bulk_Modulus_of_Au&amp;diff=5060"/>
		<updated>2011-01-19T08:27:34Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Analyze data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;FONT SIZE=&amp;quot;+3&amp;quot; color=&amp;quot;darkred&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;&lt;br /&gt;
VASP: Computing Bulk Modulus of Au&amp;lt;/STRONG&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt; &amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Input files===&lt;br /&gt;
&lt;br /&gt;
Here we give an example of how to use VASP to compute the bulk modulus of LDA-Au.  We performed this calculation on &amp;lt;tt&amp;gt;MC-CC&amp;lt;/tt&amp;gt; in serial model in the &amp;lt;tt&amp;gt;~/Codes/VASP/runs/Au/LDA/perfect.21x21x21&amp;lt;/tt&amp;gt; directory.  This directory contains the following files.&lt;br /&gt;
&lt;br /&gt;
 INCAR&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ENCUT  =  400&lt;br /&gt;
ISMEAR  = 1&lt;br /&gt;
SIGMA = 0.1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 KPOINTS&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
21x21x21&lt;br /&gt;
0        0 = automatic generation of k-points&lt;br /&gt;
Monkhorst&lt;br /&gt;
21 21 21&lt;br /&gt;
0 0 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 POSCAR&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
POSCAR for FCC Au (created manually)&lt;br /&gt;
   4.068 &lt;br /&gt;
   0    0.5  0.5&lt;br /&gt;
   0.5  0    0.5&lt;br /&gt;
   0.5  0.5  0&lt;br /&gt;
   1 &lt;br /&gt;
Cartesian  (real coordinates r)&lt;br /&gt;
   0    0    0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To do this calculation, you also need to put the LDA pseudopotential file as &amp;lt;tt&amp;gt;POTCAR&amp;lt;/tt&amp;gt; in this directory. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Run VASP===&lt;br /&gt;
&lt;br /&gt;
Now we are ready to run&lt;br /&gt;
&lt;br /&gt;
 vasp&lt;br /&gt;
&lt;br /&gt;
To compute the equilibrium lattice constant, cohesive energy and bulk modulus, we use the following script &amp;lt;tt&amp;gt;auto.B.serial&amp;lt;/tt&amp;gt; to run &amp;lt;tt&amp;gt;vasp&amp;lt;/tt&amp;gt; repeated with different lattice constants.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
rm WAVECAR &lt;br /&gt;
for a in 4.056 4.058 4.060 4.062 4.064 4.066 4.068&lt;br /&gt;
do&lt;br /&gt;
cat &amp;gt; POSCAR &amp;lt;&amp;lt; FIN&lt;br /&gt;
POSCAR for FCC Au (created manually)&lt;br /&gt;
   $a &lt;br /&gt;
   0    0.5  0.5&lt;br /&gt;
   0.5  0    0.5&lt;br /&gt;
   0.5  0.5  0&lt;br /&gt;
   1 &lt;br /&gt;
Cartesian  (real coordinates r)&lt;br /&gt;
   0    0    0&lt;br /&gt;
FIN&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;a=$a&amp;quot;&lt;br /&gt;
./vasp&lt;br /&gt;
&lt;br /&gt;
E=`tail -1 OSZICAR`&lt;br /&gt;
echo $a $E | sed -s &#039;s/F=//; s/E0=//; s/d E =//;&#039; &amp;gt;&amp;gt; Elatt.B.dat&lt;br /&gt;
&lt;br /&gt;
p=`grep pressure OUTCAR | cut -b 25-34`&lt;br /&gt;
echo $a $p &amp;gt;&amp;gt; platt.B.dat&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Analyze data===&lt;br /&gt;
&lt;br /&gt;
After running it as &amp;lt;tt&amp;gt;./auto.B.serial&amp;lt;/tt&amp;gt;, it will create data files &amp;lt;tt&amp;gt;Elatt.B.dat&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;platt.B.dat&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Launch &amp;lt;tt&amp;gt;octave&amp;lt;/tt&amp;gt; and run the following functions [[media:fit_a0EB.m.txt | fit_a0EB.m]] and [[media:fit_a0B.m.txt | fit_a0B.m]],&lt;br /&gt;
&lt;br /&gt;
 fit_a0EB(&#039;Elatt.B.dat&#039;);&lt;br /&gt;
 fit_a0B (&#039;platt.B.dat&#039;);&lt;br /&gt;
&lt;br /&gt;
The first line fits the energy data to a quadratic curve and computes the equilibrium lattice constant, cohesive energy and bulk modulus.  The second line fits the pressure data to a linear curve and computes the equilibrium lattice constant and bulk modulus.  In this example, the result is a0 = 4.06 angstrom, Ecoh = -4.39 eV, B = 190 GPa.&lt;br /&gt;
&lt;br /&gt;
===Parallel computation===&lt;br /&gt;
&lt;br /&gt;
To run &amp;lt;tt&amp;gt;vasp&amp;lt;/tt&amp;gt; in parallel, you need to submit [[media:vasp.pbs.txt | vasp.pbs]] as&lt;br /&gt;
&lt;br /&gt;
 qsub vasp.pbs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need the following two files to do this calculation in parallel on SU-AHPCRC: &lt;br /&gt;
[[media:auto.B.par.Au.txt | auto.B.par]] and&lt;br /&gt;
[[media:B.pbs.Au.txt | B.pbs]].&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Computing_Clusters&amp;diff=4978</id>
		<title>Computing Clusters</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Computing_Clusters&amp;diff=4978"/>
		<updated>2011-01-05T05:05:28Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Semaphores */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Computing Clusters==&lt;br /&gt;
The Micro and Nano Mechanics Group primarily uses two clusters here at Stanford.  They are [http://hpcc.stanford.edu/clusters/mc-cc.html MC-CC] and WCR (or Glacial).  MC-CC is a cluster supported by the Mechanics and Computation Group in the Mechanical Engineering Department and whose name means &amp;quot;Mechanics and Computation Computing Cluster&amp;quot;.  WCR, or alternatively Glacial, is a computer cluster hosted the the Mechanical Engineering Department and is the initials of the late William Reynolds (Not the Reynolds number Reynolds, but a Professor at Stanford who did research in thermodynamics).  To use either cluster, you must be working with a faculty affiliated with the cluster.  MC-CC has 45 nodes, each with 2 processors and WCR has 221 nodes with 8 processors per node.&lt;br /&gt;
&lt;br /&gt;
==Hints For working with the clusters==&lt;br /&gt;
Below you will find information regarding nuances of working with these computing clusters.  This is not meant to be a exhaustive list nor a tutorial, but a collection of advice and tools.  They may not follow and order and we will update them as we remember.&lt;br /&gt;
&lt;br /&gt;
===Semaphores===&lt;br /&gt;
A [http://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci212959,00.html semaphore] is a type of shared resource on the clusters, that can lead to communication problems in parallel runs if left on the nodes since there is a limit of number of semaphores.  If any job you run terminates abnormally, you may leave Semaphore Arrays on the computer.  If you run the job on the head node, then the Semaphore Array is left with the head node, otherwise it will be associated with the compute node you were working  on.  This can lead to problems with future parallel jobs run by you or other users.  Therefore, it is good manners to frequently clean up your Semaphores.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How do I clean up Semahpores, you ask?&#039;&#039;&#039;  Easy!  You need to run the cleanipcs script to clean semaphores from your the computer.  To do this, first you must find cleanipcs in the cluster using the locate command.  Then, copy it over to you home directory and chmod it so that you have execute privileges.  Now, you can run the program by typing&lt;br /&gt;
  $ ./cleanipcs&lt;br /&gt;
This will clean all of your Semaphores from the computer.  However, if you are on a cluster, then this will only clean the Semaphores from the head node.  Generally, the problem usually lies with Semapahores on the compute nodes, which can be cleaned using the &#039;&#039;&#039;cluster-fork&#039;&#039;&#039; command. The command &#039;&#039;&#039;cluster-fork&#039;&#039;&#039; runs a following command(&#039;&#039;e.g.&#039;&#039; ./cleanipcs) on all nodes or a subset of nodes. To clean the compute nodes, use &lt;br /&gt;
  $ cluster-fork ./cleanipcs&lt;br /&gt;
&lt;br /&gt;
In some of clusters, the command &#039;&#039;&#039;cluster-fork&#039;&#039;&#039; has been replaced with &#039;&#039;&#039;rocks run host&#039;&#039;&#039;. In this case, use&lt;br /&gt;
  $ rocks run host &amp;quot;./cleanipcs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;How do I know if I have a Semaphore problem?&#039;&#039;&#039;  Ok, thats easy too.  Just run the command &lt;br /&gt;
  $/usr/bin/ipcs -s&lt;br /&gt;
This will list all of the Semaphore Arrays used on the head node. Basically, the command &#039;&#039;&#039;ipcs&#039;&#039;&#039; lists all the active [http://en.wikipedia.org/wiki/Inter-process_communication interprocess communication] objects (shared memory, message queues and semaphores). With option &#039;&#039;&#039;-s&#039;&#039;&#039;, it will show only semaphore sets. For the compute nodes, just use the cluster-fork prefix. The aforementioned script &#039;&#039;&#039;cleanipcs&#039;&#039;&#039; internally uses the command &#039;&#039;&#039;ipcrm&#039;&#039;&#039; to remove interprocess communication objects.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Finally, how do I know if this is crashing my parallel job?&#039;&#039;&#039;  Well, likely your job will crash with the following error:&lt;br /&gt;
  $ p4_error: semget failed for setnum:0&lt;br /&gt;
If you see this error in your parallel job, you may have a problem with Semaphore Arrays.  Run the ipcs command to see which nodes have Semaphore Arrays and clean up yours.  You cannot clean up Semapahores owned by other users, so you may have to contact them to free all Semaphores.&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=ParaDiS_Cylinder_Code_Manuals&amp;diff=4583</id>
		<title>ParaDiS Cylinder Code Manuals</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=ParaDiS_Cylinder_Code_Manuals&amp;diff=4583"/>
		<updated>2010-04-30T20:59:58Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;UL&amp;gt;&lt;br /&gt;
&amp;lt;LI&amp;gt;[[PARADISCYL:How-To-Install | M01 How to install]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[PARADISCYL:Test-Run | M02 Test Run]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[PARADISCYL:Scale-Rule | M03 How units are scaled]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[PARADISCYL:How-To-Get-Nodal-Force | M04 How to get nodal force data]]&lt;br /&gt;
&amp;lt;LI&amp;gt;[[PARADISCYL:Cylinder-Benchmark | M05 ]]&lt;br /&gt;
&amp;lt;/UL&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M03_Equilibrium_Lattice_Constant_and_Bulk_Modulus&amp;diff=374</id>
		<title>M03 Equilibrium Lattice Constant and Bulk Modulus</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M03_Equilibrium_Lattice_Constant_and_Bulk_Modulus&amp;diff=374"/>
		<updated>2009-10-14T22:49:38Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Bulk Modulus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Manual 03 for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Equilibrium Lattice Constant and Bulk Modulus&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Nov 26 ]], [[2007]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&amp;lt;!--Table of Child-Links--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading a Log File ==&lt;br /&gt;
In the example scripts of Manual 02, the command &#039;&#039;&#039;setnolog&#039;&#039;&#039; was activated and&lt;br /&gt;
the simulation results were printed out to the standard output, which is usually&lt;br /&gt;
your terminal screen. If you want to keep the record of this information, you&lt;br /&gt;
comment out the &#039;&#039;&#039;setnolog&#039;&#039;&#039; command by adding # before it. This&lt;br /&gt;
will create a log ﬁle &#039;&#039;&#039;A.log&#039;&#039;&#039; in the directory speciﬁed by &#039;&#039;&#039;dirname&#039;&#039;&#039;. For example,&lt;br /&gt;
if you run &#039;&#039;&#039;mo.script&#039;&#039;&#039; in Manual 02 with &#039;&#039;&#039;setnolog&#039;&#039;&#039; commented out,&lt;br /&gt;
then you will ﬁnd a &#039;&#039;&#039;A.log&#039;&#039;&#039; ﬁle in the &#039;&#039;&#039;runs/mo-example&#039;&#039;&#039; directory. To read&lt;br /&gt;
this ﬁle, type&lt;br /&gt;
&lt;br /&gt;
 $ more runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
In the log ﬁle, the line starting with &#039;&#039;&#039;ASSIGN&#039;&#039;&#039; shows that a variable &lt;br /&gt;
is assigned to the values as speciﬁed in the script ﬁle. The line with &#039;&#039;&#039;EXEC&#039;&#039;&#039;&lt;br /&gt;
shows the execution of certain command. After the &#039;&#039;&#039;eval&#039;&#039;&#039; command is executed,&lt;br /&gt;
properties such as number of atoms (&#039;&#039;&#039;NP&#039;&#039;&#039;), potential energy (&#039;&#039;&#039;EPOT&#039;&#039;&#039;), kinetic&lt;br /&gt;
energy (&#039;&#039;&#039;KATOM&#039;&#039;&#039;), pressure (&#039;&#039;&#039;PRESSURE&#039;&#039;&#039;) and stress (&#039;&#039;&#039;Stress&#039;&#039;&#039;) are also printed.&lt;br /&gt;
Sometimes, the log ﬁle may be zipped as &#039;&#039;&#039;A.log.gz&#039;&#039;&#039;, in which case you can use&lt;br /&gt;
&lt;br /&gt;
 $ gzip -cd runs/mo-example/A.log.gz | more&lt;br /&gt;
&lt;br /&gt;
to see the content. To search for a speciﬁc property (&#039;&#039;e.g.&#039;&#039; &#039;&#039;&#039;EPOT&#039;&#039;&#039;) in the log&lt;br /&gt;
ﬁle, you may use&lt;br /&gt;
&lt;br /&gt;
 $ grep EPOT runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ gzip -cd runs/mo-example/A.log.gz | grep EPOT&lt;br /&gt;
&lt;br /&gt;
depending on whether the log ﬁle is zipped or not. In case you want to “grep” several&lt;br /&gt;
lines before and after your keyword (&#039;&#039;e.g.&#039;&#039; &#039;&#039;&#039;Stress&#039;&#039;&#039;), you can use&lt;br /&gt;
&lt;br /&gt;
 $ grep -3 Stress runs/mo-example/A.log&lt;br /&gt;
&lt;br /&gt;
This will show three lines above and below any line containing the keyword&lt;br /&gt;
“Stress”.&lt;br /&gt;
&lt;br /&gt;
Obviously, this way of extracting the values of MD++ variables is very tedious.  There is a better way to do this, which is to use the Tcl scripting language, as described in [[M08_MD++_Powered_by_Tcl_Language |Manual 08 (will be available soon)]].  The Tcl script for MD++ calculations described in this section is attaced at the end of this manual.&lt;br /&gt;
&lt;br /&gt;
== Equilibrium Lattice Constant and Cohesive Energy ==&lt;br /&gt;
Under ambient condition silicon takes the diamond-cubic (DC) structure.&lt;br /&gt;
But in a computer simulation, we can create Si crystals with diﬀerent hypothet-&lt;br /&gt;
ical structures, such as face-centered-cubic (FCC), body-centered-cubic (BCC),&lt;br /&gt;
or simple-cubic (SC). A good potential model should be able to tell us that the&lt;br /&gt;
DC structure is the one with the lowest energy, hence it is the most favorable&lt;br /&gt;
structure for silicon. In this section, we will perform such calculations using&lt;br /&gt;
MD++.&lt;br /&gt;
&lt;br /&gt;
Let us deﬁne the lattice energy &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; and the number density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Phi = \frac{E_{pot}}{N} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt; \rho = \frac{N}{V} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;E_{pot}&amp;lt;/math&amp;gt; is the potential energy of the crystal, &amp;lt;math&amp;gt;N&amp;lt;/math&amp;gt; is total number of atoms&lt;br /&gt;
in the simulation cell (corresponding to variable &#039;&#039;&#039;NP&#039;&#039;&#039; in MD++) and &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; is the&lt;br /&gt;
volume of the simulation cell. Run MD++ with following command line to use&lt;br /&gt;
the Stillinger-Weber (SW) potential model&amp;lt;ref name=&amp;quot;SW&amp;quot;&amp;gt;F. H. Stillinger and T. A. Weber, Phys. Rev. B &#039;&#039;&#039;31&#039;&#039;&#039;, 5262 (1985).&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;BH&amp;quot;&amp;gt;H. Balamane, T. Halicioglu, and W. A. Tiler, Phys. Rev. B &#039;&#039;&#039;46&#039;&#039;&#039;, 2250 (1992)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 $ bin/sw_gpp scripts/ME346/si_polytype.script&lt;br /&gt;
&lt;br /&gt;
Here is the content of the &#039;&#039;&#039;si_polytype.script&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si_polytype&lt;br /&gt;
#------------------------------------------------------------&lt;br /&gt;
#Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
crystalstructure = diamond-cubic&lt;br /&gt;
latticeconst = 5.4309529817532409 #(A) for Si&lt;br /&gt;
latticesize = [ 1 0 0 3&lt;br /&gt;
                0 1 0 3&lt;br /&gt;
                0 0 1 3]&lt;br /&gt;
makecrystal eval&lt;br /&gt;
latticeconst = 4.850 makecrystal eval&lt;br /&gt;
latticeconst = 4.950 makecrystal eval&lt;br /&gt;
latticeconst = 5.050 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
(many lines omitted here for brevity)&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 5.900 makecrystal eval&lt;br /&gt;
latticeconst = 6.000 makecrystal eval&lt;br /&gt;
latticeconst = 6.100 makecrystal eval&lt;br /&gt;
crystalstructure = face-centered-cubic&lt;br /&gt;
latticeconst = 4.105 makecrystal eval&lt;br /&gt;
latticeconst = 4.110 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 4.205 makecrystal eval&lt;br /&gt;
latticeconst = 4.215 makecrystal eval&lt;br /&gt;
crystalstructure = body-centered-cubic&lt;br /&gt;
latticeconst = 3.210 makecrystal eval&lt;br /&gt;
latticeconst = 3.220 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 3.320 makecrystal eval&lt;br /&gt;
latticeconst = 3.340 makecrystal eval&lt;br /&gt;
crystalstructure = simple-cubic&lt;br /&gt;
latticeconst = 2.550 makecrystal eval&lt;br /&gt;
latticeconst = 2.600 makecrystal eval&lt;br /&gt;
                :&lt;br /&gt;
                :&lt;br /&gt;
latticeconst = 2.640 makecrystal eval&lt;br /&gt;
latticeconst = 2.650 makecrystal eval&lt;br /&gt;
quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the log ﬁle, you can ﬁnd number of atoms &#039;&#039;&#039;NP&#039;&#039;&#039; for the 3 X 3 X 3 DC cell&lt;br /&gt;
to be 216. This number can also be obtained by calculating &amp;lt;math&amp;gt;8 \times 3^3 = 216&amp;lt;/math&amp;gt;, since&lt;br /&gt;
there are eight atoms in the DC unit cell. For other crystal structures, the&lt;br /&gt;
number of atoms in the 3X3X3 cell is given in the following table.&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|+ Table 1. Number of atoms in different crystal structures&lt;br /&gt;
| Crystal Structure || No. of atoms in the unit cell || Total No. of atoms&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| SC ||align=&amp;quot;center&amp;quot;|       1       ||align=&amp;quot;center&amp;quot;|       27&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| BCC ||align=&amp;quot;center&amp;quot;|      2       ||align=&amp;quot;center&amp;quot;|       54&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| FCC ||align=&amp;quot;center&amp;quot;|      4       ||align=&amp;quot;center&amp;quot;|      108&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;| DC ||align=&amp;quot;center&amp;quot;|       8       ||align=&amp;quot;center&amp;quot;|      216&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The potential energy at each diﬀerent lattice constant can also be read from the&lt;br /&gt;
log ﬁle by typing&lt;br /&gt;
&lt;br /&gt;
 $ grep EPOT runs/si_polytype/A.log&lt;br /&gt;
&lt;br /&gt;
The volume of a simulation cell &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; can be obtained from the determinant of&lt;br /&gt;
the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt;.&amp;lt;ref&amp;gt;The matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; deﬁnes size and shape of the simulation cell. &amp;lt;math&amp;gt;\mathbf{H} = [\mathbf{c}_1 \; \mathbf{c}_2 \; \mathbf{c}_3]&amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;\mathbf{c}_i&amp;lt;/math&amp;gt;&#039;s&lt;br /&gt;
are three periodicity vectors. In MD++, the matrix &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; becomes a diagonal matrix when the&lt;br /&gt;
supercell is a rectangular box (after reorienting the coordinate system).&lt;br /&gt;
&amp;lt;/ref&amp;gt; When &amp;lt;math&amp;gt;\mathbf{H}&amp;lt;/math&amp;gt; is a diagonal matrix (the same is true for an upper&lt;br /&gt;
triangular matrix),&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; V = \det(\mathbf{H}) = \mathbf{H}(1,1) \mathbf{H}(2,2) \mathbf{H}(3,3) &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
                      &lt;br /&gt;
the volume is the product of the entries in the main diagonal of \mathbf{H}. The unit&lt;br /&gt;
of length in MD++ is &amp;amp;Aring; and the unit of volume is &amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt; . From these, we can&lt;br /&gt;
calculate the lattice energy &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; (in eV) of silicon as a function of the number&lt;br /&gt;
density &amp;lt;math&amp;gt;\rho&amp;lt;/math&amp;gt; (in 1/&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;), for diﬀerent crystal structures, as shown in Fig.1. &lt;br /&gt;
The structure with the lowest energy is DC. The equilibrium lattice&lt;br /&gt;
constant &amp;lt;math&amp;gt;a_0&amp;lt;/math&amp;gt; corresponds to the number density that gives the minimum of the&lt;br /&gt;
&amp;lt;math&amp;gt;\Phi(\rho)&amp;lt;/math&amp;gt; curve. The minimum of &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; is also called the &#039;&#039;&#039;cohesive energy&#039;&#039;&#039; &amp;lt;math&amp;gt;E_{coh}&amp;lt;/math&amp;gt; . &lt;br /&gt;
For DC silicon, &amp;lt;math&amp;gt;a_0=&amp;lt;/math&amp;gt; 5.431 &amp;amp;Aring; and &amp;lt;math&amp;gt;E_{coh}&amp;lt;/math&amp;gt; = −4.63 eV.&lt;br /&gt;
&lt;br /&gt;
[[Image:E_Si.jpg | frame | center | Fig.1 Lattice energy of Si in different structures. DC Si has the lowest energy well. The inset figure is the zoom-in image of the energy curve of DC Si.]]&lt;br /&gt;
[[Image:E_latt_Si.jpg | frame | center | Fig.2 Lattice energy vs lattice constant of DC Si. The curve is fitted to the quadratic polynomials. The equilibrium lattice constant is estimated to be 5.43095(&amp;amp;Aring;).]]&lt;br /&gt;
&lt;br /&gt;
== Bulk Modulus ==&lt;br /&gt;
The curvature of the &amp;lt;math&amp;gt;\Phi(\rho)&amp;lt;/math&amp;gt; curve near the minimum also tells us the bulk modulus&lt;br /&gt;
of the crystal. The bulk modulus &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is deﬁned as&amp;lt;ref&amp;gt;This is because &amp;lt;math&amp;gt;B =  -V \partial P / \partial V &amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;P = - \partial \Phi / \partial V&amp;lt;/math&amp;gt;.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; B = V \frac{\partial^2 \Phi}{\partial V^2}_{V=V_0} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;V_0&amp;lt;/math&amp;gt; is the equilibrium atomic volume (corresponding to the energy minimum). &lt;br /&gt;
To compute the second derivative, plot &amp;lt;math&amp;gt;\Phi&amp;lt;/math&amp;gt; as a function of &amp;lt;math&amp;gt;V = 1/\rho&amp;lt;/math&amp;gt; and&lt;br /&gt;
ﬁt the &amp;lt;math&amp;gt;\Phi(V)&amp;lt;/math&amp;gt; curve by a quadratic function,&lt;br /&gt;
&#039;&#039;i.e.&#039;&#039; &amp;lt;math&amp;gt;\Phi = c_0 + c_1 V + c_2 V^2&amp;lt;/math&amp;gt;, as shown in Fig.3. This can be done by the Matlab&lt;br /&gt;
command &#039;&#039;&#039;polyfit&#039;&#039;&#039; and the result is c&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; = 0.016879 (in unit of eV/&amp;amp;Aring;&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt; ). &lt;br /&gt;
Then, with &amp;lt;math&amp;gt;V_0=&amp;lt;/math&amp;gt;20.023 (&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;), the bulk modulus becomes &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; B =  2\times 20.023 \mathrm{(\AA^3)}\times 0.016879 \mathrm{(eV/\AA^6)}\times 160.2 \mathrm{(GPa/(eV/\AA^3))}= 108.3 \mathrm{(GPa)}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This result matches with an earlier report in the literature&amp;lt;ref name=&amp;quot;BH&amp;quot;/&amp;gt;. In the elasticity&lt;br /&gt;
theory&amp;lt;ref&amp;gt;J. P. Hirth and J. Lothe, &#039;&#039;Theory of Dislocations&#039;&#039;, (Wiley, New York, 1982)&amp;lt;/ref&amp;gt;, the bulk modulus &amp;lt;math&amp;gt;B&amp;lt;/math&amp;gt; is related to the other elastic constants through&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;B = \lambda + \frac{2}{3}\mu &amp;lt;/math&amp;gt; || for isotropic material&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;math&amp;gt;B = \frac{1}{3}(C_{11} + 2C_{12})&amp;lt;/math&amp;gt; || for cubic material&lt;br /&gt;
|}&lt;br /&gt;
where &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt; are Lam&amp;amp;eacute;&#039;s constants and &amp;lt;math&amp;gt;C_{11}&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;C_{12}&amp;lt;/math&amp;gt; are cubic elastic constants.&lt;br /&gt;
From this relation, the bulk modulus would be 98.4 GPa if we calculate it from the experimental value of &amp;lt;math&amp;gt;C_{11}=&amp;lt;/math&amp;gt; 165.7(GPa) and &amp;lt;math&amp;gt;C_{12}=&amp;lt;/math&amp;gt; 63.9(GPa) for silicon. &lt;br /&gt;
The discrepancy between the simulation and experimental results in the bulk modulus is partly&lt;br /&gt;
because the simulation results corresponds to the ideal case of T = 0 K,&lt;br /&gt;
while the experimental result is obtained at room temperature T = 300 K. The&lt;br /&gt;
elastic constants generally decreases with increasing temperature. The discrepancy &lt;br /&gt;
may also come from the fact that the potential model has empirical nature. Diﬀerent&lt;br /&gt;
parameterization of the potential model generally leads to diﬀerent predictions&lt;br /&gt;
of the elastic constants.&lt;br /&gt;
[[Image:E_vol_Si.jpg | frame | center | Fig.3 Lattice energy vs atomic volume of DC Si. The equilibrium atomic volume is estimated to be 20.023(&amp;amp;Aring;&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;).]]&lt;br /&gt;
&lt;br /&gt;
== Tcl version of MD++ script == &lt;br /&gt;
For anyone that wants to reproduce my data, I uploaded the Tcl version of MD++ script &#039;&#039;&#039;si_polytype.tcl&#039;&#039;&#039; and the matlab script for the post-process of the simulation data.&lt;br /&gt;
&lt;br /&gt;
si_polytype.tcl&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { } { MD++ {&lt;br /&gt;
#setnolog&lt;br /&gt;
setoverwrite&lt;br /&gt;
dirname = runs/si_polytype&lt;br /&gt;
zipfiles = 1   # zip output files&lt;br /&gt;
NIC = 200 NNM = 200&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
proc makecrystal { } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
  MD++ element0 = Si&lt;br /&gt;
  MD++ latticesize = \[ 1 0 0 4 0 1 0 4 0 0 1 4 \]&lt;br /&gt;
  MD++ makecrystal&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
proc readnwrite { a fileID } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# read and write properties&lt;br /&gt;
for {set i -50} {$i &amp;lt;= 50} {incr i} {&lt;br /&gt;
  set latt [expr $a + $i/10000.0 ]&lt;br /&gt;
  MD++ latticeconst = $latt&lt;br /&gt;
  makecrystal&lt;br /&gt;
&lt;br /&gt;
  MD++ eval    &lt;br /&gt;
  set EPOT     [MD++_Get EPOT]&lt;br /&gt;
  set N        [MD++_Get NP]&lt;br /&gt;
  set VOL      [MD++_Get OMEGA]&lt;br /&gt;
  set ELAT     [expr $EPOT / $N]&lt;br /&gt;
  set rho      [expr $N / double($VOL)]&lt;br /&gt;
  set AtomVol  [expr double($VOL) / $N]&lt;br /&gt;
&lt;br /&gt;
  puts $fileID &amp;quot;[format %18.12e $latt]\t \&lt;br /&gt;
                [format %18.12e $rho] \t \&lt;br /&gt;
                [format %18.12e $AtomVol]\t \&lt;br /&gt;
                [format %18.12e $EPOT]\t \&lt;br /&gt;
                [format %18.12e $ELAT]&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
initmd&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = diamond-cubic&lt;br /&gt;
set a 5.4309 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_DC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = face-centered-cubic&lt;br /&gt;
set a 4.1465 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_FCC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = body-centered-cubic&lt;br /&gt;
set a 3.245 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_BCC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ crystalstructure = simple-cubic&lt;br /&gt;
set a 2.6120 &lt;br /&gt;
set fileID [open &amp;quot;EvsVol_SC.dat&amp;quot; w]&lt;br /&gt;
readnwrite $a $fileID&lt;br /&gt;
close $fileID&lt;br /&gt;
&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% Matlab script to plot the lattice energy of Si&lt;br /&gt;
% in different structures (DC, FCC, BCC and SC)&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
clf&lt;br /&gt;
&lt;br /&gt;
DC.data = load(&#039;EvsVol_DC.dat&#039;);&lt;br /&gt;
DC.latt = DC.data(:,1);&lt;br /&gt;
DC.rho  = DC.data(:,2);&lt;br /&gt;
DC.atomvol = DC.data(:,3);&lt;br /&gt;
DC.EPOT = DC.data(:,4);&lt;br /&gt;
DC.ELAT = DC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
FCC.data = load(&#039;EvsVol_FCC.dat&#039;);&lt;br /&gt;
FCC.latt = FCC.data(:,1);&lt;br /&gt;
FCC.rho  = FCC.data(:,2);&lt;br /&gt;
FCC.atomvol = FCC.data(:,3);&lt;br /&gt;
FCC.EPOT = FCC.data(:,4);&lt;br /&gt;
FCC.ELAT = FCC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
BCC.data = load(&#039;EvsVol_BCC.dat&#039;);&lt;br /&gt;
BCC.latt = BCC.data(:,1);&lt;br /&gt;
BCC.rho  = BCC.data(:,2);&lt;br /&gt;
BCC.atomvol = BCC.data(:,3);&lt;br /&gt;
BCC.EPOT = BCC.data(:,4);&lt;br /&gt;
BCC.ELAT = BCC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
SC.data = load(&#039;EvsVol_SC.dat&#039;);&lt;br /&gt;
SC.latt = SC.data(:,1);&lt;br /&gt;
SC.rho  = SC.data(:,2);&lt;br /&gt;
SC.atomvol = SC.data(:,3);&lt;br /&gt;
SC.EPOT = SC.data(:,4);&lt;br /&gt;
SC.ELAT = SC.data(:,5);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs number density&lt;br /&gt;
% with inset figure&lt;br /&gt;
h1 = figure(1);&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.rho, DC.ELAT, &#039;.-&#039;,FCC.rho, FCC.ELAT, &#039;.-&#039;, ...&lt;br /&gt;
     BCC.rho, BCC.ELAT, &#039;.-&#039;,SC.rho, SC.ELAT, &#039;.-&#039;)&lt;br /&gt;
xlabel(&#039;Number Density, \rho=N/V (1/Angstrom^3)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
legend(&#039;DC&#039;,&#039;FCC&#039;,&#039;BCC&#039;,&#039;SC&#039;,2)&lt;br /&gt;
h2 = get(h1,&#039;CurrentAxes&#039;)&lt;br /&gt;
h3 = axes(&#039;pos&#039;,[.5 .2 .35 .35]);&lt;br /&gt;
&lt;br /&gt;
hold on; plot(DC.rho, DC.ELAT, &#039;.-&#039;)&lt;br /&gt;
yticklong = get(h3,&#039;YTick&#039;);&lt;br /&gt;
set(h3,&#039;xlim&#039;,[0.0498 0.0501],&#039;YTickLabel&#039;,yticklong,&#039;box&#039;,&#039;on&#039;);&lt;br /&gt;
hold off&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs lattice constant&lt;br /&gt;
% and find the equilibrium lattice constant, a_0&lt;br /&gt;
[P, S] = polyfit(DC.latt,DC.ELAT,2);&lt;br /&gt;
latt_X = linspace(5.4305,5.4315);&lt;br /&gt;
ELAT_Y = polyval(P,latt_X);&lt;br /&gt;
&lt;br /&gt;
figure(2)&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.latt, DC.ELAT, &#039;.-&#039;,latt_X,ELAT_Y,&#039;.-r&#039;)&lt;br /&gt;
xlabel(&#039;Lattice Constant, \it a \rm (Angstrom)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
yticklong = get(gca,&#039;YTick&#039;);&lt;br /&gt;
set(gca,&#039;YTickLabel&#039;,yticklong,&#039;Xlim&#039;,[5.426 5.436]);&lt;br /&gt;
legend(&#039;data&#039;,&#039;fitting curve&#039;)&lt;br /&gt;
&lt;br /&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br /&gt;
% plot the lattice energy vs atomic volume&lt;br /&gt;
% and find the bulk modulus, B&lt;br /&gt;
[P2, S2] = polyfit(DC.atomvol,DC.ELAT,2);&lt;br /&gt;
vol_X = linspace(20.01,20.04);&lt;br /&gt;
ELAT_Y2 = polyval(P2,vol_X);&lt;br /&gt;
&lt;br /&gt;
figure(3)&lt;br /&gt;
set(gca,&#039;fontsize&#039;,14)&lt;br /&gt;
plot(DC.atomvol, DC.ELAT, &#039;.-&#039;,vol_X,ELAT_Y2,&#039;.-r&#039;)&lt;br /&gt;
xlabel(&#039;Atomic Volume, \it V \rm (Angstrom^3)&#039;,&#039;fontsize&#039;,16), &lt;br /&gt;
ylabel(&#039;Binding Energy per atom (eV)&#039;,&#039;fontsize&#039;,16)&lt;br /&gt;
yticklong = get(gca,&#039;YTick&#039;);&lt;br /&gt;
set(gca,&#039;YTickLabel&#039;,yticklong);&lt;br /&gt;
legend(&#039;data&#039;,&#039;fitting curve&#039;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=A_Polygonal_Dislocation_Loop_in_MD%2B%2B&amp;diff=2949</id>
		<title>A Polygonal Dislocation Loop in MD++</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=A_Polygonal_Dislocation_Loop_in_MD%2B%2B&amp;diff=2949"/>
		<updated>2009-09-30T21:17:42Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;FONT SIZE=&amp;quot;-1&amp;quot;&amp;gt;Additional Manual for MD++ &amp;lt;/FONT&amp;gt; &lt;br /&gt;
&amp;lt;BR&amp;gt;&lt;br /&gt;
Creating a Polygonal Dislocation Loop&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jan 19 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This short summary explains how we create a polygonal dislocation loop in the atomistic simulation, using the displacement field of a triagonal dislocation loop.&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Displacement Field of a Triangular Dislocation Loop ==&lt;br /&gt;
[[Image:Triangular_disl_loop.jpg|frame|Fig.1. ]]&lt;br /&gt;
While studying a dislocation nucleation problem by atomistic simulations, the authors needed to create a polygonal dislocation loop, which requires the knowledge of the displacement field of a polygonal dislocation loop in the infinite isotropic medium.&lt;br /&gt;
&lt;br /&gt;
In elasticity, the displacement field of a polygonal dislocation loop is merely the sum of fields of triangular loops that constitute the polygon loop.&amp;lt;ref name=&amp;quot;Barnett1985&amp;quot;&amp;gt;D. M. Barnett. The displacement field of a triangular dislocation loop. &#039;&#039;Philosophical Magazine A&#039;&#039;, &#039;&#039;&#039;51&#039;&#039;&#039;(3):383--387, 1985&amp;lt;/ref&amp;gt;  The coordinate-free form of analytic expression for the elastic displacement field &#039;&#039;&#039;u&#039;&#039;&#039; of a triangular loop ABC is given as&amp;lt;ref name=&amp;quot;Barnett1985&amp;quot;/&amp;gt;&amp;lt;ref&amp;gt;D. M. Barnett and R. W. Balluffi. The displacement field of a triangular dislocation loop -- a correction with commentary. &#039;&#039;Philosophical Magazine Letters&#039;&#039;, &#039;&#039;&#039;87&#039;&#039;&#039;(12):943--944, 2007&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{u(x)} = -\frac{\Omega}{4\pi}\mathbf{b} &lt;br /&gt;
-\frac{1-2\nu}{8\pi(1-\nu)} \left[ \mathbf{f}_{AB} + \mathbf{f}_{BC} + \mathbf{f}_{CA} \right]&lt;br /&gt;
+ \frac{1}{8\pi(1-\nu)} \left[ \mathbf{g}_{AB} + \mathbf{g}_{BC} + \mathbf{g}_{CA} \right]  &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
| width=&amp;quot;100&amp;quot; align=&amp;quot;right&amp;quot; |(1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{f}_{AB} = \left( \mathbf{b}\times\mathbf{t}_{AB} \right) \ln \left( \frac{R_B}{R_A}\cdot \frac{1 + \boldsymbol{\lambda}_B\cdot\mathbf{t}_{AB}}{1 + \boldsymbol{\lambda}_A\cdot\mathbf{t}_{AB}} \right) &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
| width=&amp;quot;200&amp;quot; align=&amp;quot;right&amp;quot; | (2)&lt;br /&gt;
|}&lt;br /&gt;
and&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;&lt;br /&gt;
\mathbf{g}_{AB} = &lt;br /&gt;
(\boldsymbol{\lambda}_A + \boldsymbol{\lambda}_B ) \frac{ \mathbf{b} \cdot (\boldsymbol{\lambda}_A \times \boldsymbol{\lambda}_B) }  &lt;br /&gt;
{1 + \boldsymbol{\lambda}_A \cdot \boldsymbol{\lambda}_B}. &lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
| width=&amp;quot;200&amp;quot; align=&amp;quot;right&amp;quot; | (3)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;f&#039;&#039;&#039;&amp;lt;sub&amp;gt;BC&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;f&#039;&#039;&#039;&amp;lt;sub&amp;gt;CA&amp;lt;/sub&amp;gt; have the same expression as Eqn.(2) except cyclic permutation of A, B and C, and so do &#039;&#039;&#039;g&#039;&#039;&#039;&amp;lt;sub&amp;gt;BC&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;g&#039;&#039;&#039;&amp;lt;sub&amp;gt;CA&amp;lt;/sub&amp;gt; with Eqn.(3). &lt;br /&gt;
&#039;&#039;R&#039;&#039;&amp;lt;sub&amp;gt;A&amp;lt;/sub&amp;gt;, &#039;&#039;R&#039;&#039;&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt; and &#039;&#039;R&#039;&#039;&amp;lt;sub&amp;gt;C&amp;lt;/sub&amp;gt; are the magnitudes of &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;A&amp;lt;/sub&amp;gt;, &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;C&amp;lt;/sub&amp;gt;, respectively. (See Fig.1.) &amp;lt;math&amp;gt;\boldsymbol{\lambda}_A&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\boldsymbol{\lambda}_B&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\boldsymbol{\lambda}_C&amp;lt;/math&amp;gt; are the unit vectors of &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;A&amp;lt;/sub&amp;gt;, &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;R&#039;&#039;&#039;&amp;lt;sub&amp;gt;C&amp;lt;/sub&amp;gt;, respectively, &#039;&#039;e.g.&#039;&#039; &amp;lt;math&amp;gt;\boldsymbol{\lambda}_A = \mathbf{R}_A / R_A&amp;lt;/math&amp;gt;.&lt;br /&gt;
And &#039;&#039;&#039;t&#039;&#039;&#039;&amp;lt;sub&amp;gt;AB&amp;lt;/sub&amp;gt;, &#039;&#039;&#039;t&#039;&#039;&#039;&amp;lt;sub&amp;gt;BC&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;t&#039;&#039;&#039;&amp;lt;sub&amp;gt;CA&amp;lt;/sub&amp;gt; are the unit tangent vectors of the segments AB, BC and CA, respectively. &#039;&#039;&#039;b&#039;&#039;&#039; is the loop Burgers vector.&lt;br /&gt;
&lt;br /&gt;
The solid angle &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; in Eqn.(1) is expressed as&amp;lt;ref&amp;gt;A. Van Oosterom and J. Strackee. The solid angle of a plane triangle. &#039;&#039;IEEE Transactions on Biomedical Engineering&#039;&#039;, &#039;&#039;&#039;BME-30&#039;&#039;&#039;(2):125--126, 1983&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;&lt;br /&gt;
 \Omega = -2\tan^{-1}&lt;br /&gt;
\frac{ \mathbf{R}_\textrm{A} \cdot (\mathbf{R}_\textrm{B} \times \mathbf{R}_\textrm{C}) }&lt;br /&gt;
{R_\textrm{A}R_\textrm{B}R_\textrm{C} &lt;br /&gt;
 + (\mathbf{R}_\textrm{A} \cdot \mathbf{R}_\textrm{B}) R_\textrm{C} &lt;br /&gt;
 + (\mathbf{R}_\textrm{A} \cdot \mathbf{R}_\textrm{C}) R_\textrm{B}&lt;br /&gt;
 + (\mathbf{R}_\textrm{B} \cdot \mathbf{R}_\textrm{C}) R_\textrm{A}}.&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
| width=&amp;quot;100&amp;quot; align=&amp;quot;right&amp;quot; | (4)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The sign of &amp;lt;math&amp;gt;\Omega&amp;lt;/math&amp;gt; is reversed from the original expression to be in accordance with the convention of Barnett (1985).&lt;br /&gt;
&lt;br /&gt;
By displacing all the atoms according to Eqn.(1), we can create a triangular dislocation loop in the atomistic simulation as shown in Fig.2(a).&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|[[Image:tri_disl_loop_md.jpg|frameless|300px|caption]]&lt;br /&gt;
|[[Image:tetra_disl_loop_md.jpg|frameless|300px|caption]]&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|(a)&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|(b)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; | Fig.2 (a) A triangular and (b) a tetragonal dislocation loop in DC Si. &amp;lt;math&amp;gt;\mathbf{C}_1 = 8a[1\, 1\, \bar{2}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{C}_2 = 20a[1\, 1\, 1]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{C}_3 = 12a[1\, \bar{1}\, 0]&amp;lt;/math&amp;gt;, where &#039;&#039;a&#039;&#039; is the lattice constant and &amp;lt;math&amp;gt;a = 5.431 \AA&amp;lt;/math&amp;gt; in Si. The loop Bergurs vector &amp;lt;math&amp;gt;\mathbf{b} = a/2[1\, \bar{1}\, 0]&amp;lt;/math&amp;gt; in both (a) and (b).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Construction of a Polygonal Dislocation Loop ==&lt;br /&gt;
For the displacement field of a polygonal dislocation loop, we first decompose the polygonal loop into a sum of triangular loops, calculate the fields of each loops according to Eqn.(1)-(4) and finally sum them up. For example, Fig.3 shows how a tetragonal dislocation loop can be decomposed of multiple triangular loops.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|[[Image:Tetra_disl_loop_schem1.jpg|frameless|300px|caption]]&lt;br /&gt;
|[[Image:Tetra_disl_loop_schem2.jpg|frameless|300px|caption]]&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|(a)&lt;br /&gt;
|align=&amp;quot;center&amp;quot;|(b)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot; | Fig.3 A tetragonal dislocation loop P&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;P&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;P&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt;P&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; can be decomposed into two different sets of triangular loops. In either case, the net displacement field is identical, or &amp;lt;math&amp;gt;\mathbf{u}_{\Box 1243} = \mathbf{u}_{\triangle 124}+ \mathbf{u}_{\triangle 143} = \mathbf{u}_{\triangle 123}+ \mathbf{u}_{\triangle 243}&amp;lt;/math&amp;gt;. The inside arrows designate the order of vertex indices, which are cyclically permutatable.&lt;br /&gt;
|}&lt;br /&gt;
Note that the displacement given in Eqn.(1) changes its sign depending on the circular direction of the loop, or &amp;lt;math&amp;gt;\mathbf{u}_{\triangle 123} = -\mathbf{u}_{\triangle 321}&amp;lt;/math&amp;gt;. Hence, when we sum fields of two or more triangular loops, we need to carefully decide the circular direction of each loop such that the displacement fields due to the shared segment of neighboring triangular loops can be canceled each other. (See the direction of circular arrows in Fig.3.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do we maintain the periodic boundary condition? ==&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
== Can we create a nonplanar polygonal dislocation loop? ==&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
== Is &#039;&#039;&#039;b&#039;&#039;&#039; given in lab coordinate or crytal coordinate? ==&lt;br /&gt;
&lt;br /&gt;
The Burgers vector &#039;&#039;&#039;b&#039;&#039;&#039; is conventionally given in crystal coordinate such as &amp;lt;math&amp;gt;\mathbf{b} = a/2[1\, \bar{1}\, 0]&amp;lt;/math&amp;gt;. However, to use Eqn.(1), &#039;&#039;&#039;b&#039;&#039;&#039; should be given in lab coordinate. In the example of Fig.(2), the three main axes are chosen as &amp;lt;math&amp;gt;\mathbf{C}_1 = 8a[1\, 1\, \bar{2}]&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{C}_2 = 20a[1\, 1\, 1]&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;\mathbf{C}_3 = 12a[1\, \bar{1}\, 0]&amp;lt;/math&amp;gt;, where &#039;&#039;a&#039;&#039; is the lattice constant. Then the Burgers vector &#039;&#039;&#039;b&#039;&#039;&#039; in lab coordinate is&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt;&lt;br /&gt;
a\left[\mathbf{b}\cdot\frac{\mathbf{C}_1}{|\mathbf{C}_1|} \quad&lt;br /&gt;
\mathbf{b}\cdot\frac{\mathbf{C}_2}{|\mathbf{C}_2|} \quad&lt;br /&gt;
\mathbf{b}\cdot\frac{\mathbf{C}_3}{|\mathbf{C}_3|} \right] &lt;br /&gt;
= a[0\quad 0\quad \frac{1}{\surd{2}}].&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
| width=&amp;quot;100&amp;quot; align=&amp;quot;right&amp;quot; | &lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=Research_Meeting_Schedule&amp;diff=2260</id>
		<title>Research Meeting Schedule</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=Research_Meeting_Schedule&amp;diff=2260"/>
		<updated>2009-09-24T06:47:25Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Autumn 2009===&lt;br /&gt;
&lt;br /&gt;
Prof. Wei Cai&#039;s weekly schedule.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center;&amp;quot;&lt;br /&gt;
!width=&amp;quot;150pt&amp;quot; | Time &lt;br /&gt;
!width=&amp;quot;200pt&amp;quot; | Monday &lt;br /&gt;
!width=&amp;quot;200pt&amp;quot; | Tuesday &lt;br /&gt;
!width=&amp;quot;200pt&amp;quot; | Wednesday &lt;br /&gt;
!width=&amp;quot;200pt&amp;quot; | Thursday &lt;br /&gt;
!width=&amp;quot;220pt&amp;quot; | Friday&lt;br /&gt;
|-&lt;br /&gt;
|9:00-10:00  || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|10:00-10:30|| lecture prep || (meeting) || lecture prep || (meeting) &lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;ME80 office hour&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|10:30-11:00|| lecture prep || rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;Group Meeting&#039;&#039;&#039; || lecture prep || Ill &lt;br /&gt;
|-&lt;br /&gt;
|11:00-12:00|| bi-weekly Eunseok,&amp;lt;br&amp;gt; Hark, Prof. Prinz|| &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|12:30-1:15 || colspan=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightgrey&amp;quot; | lunch break&lt;br /&gt;
|-&lt;br /&gt;
|1:30-2:05 ||  rowspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;ME80&#039;&#039;&#039; || rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;ME80 office hour&#039;&#039;&#039; &lt;br /&gt;
|  rowspan=&amp;quot;3&amp;quot; | &#039;&#039;&#039;ME80&#039;&#039;&#039;   || Keonwook  ||  &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|2:10-2:45 || (meeting) || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|2:50-3:25 || Seok-Woo || (meeting) || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|3:30-4:00 || colspan=&amp;quot;5&amp;quot; align=&amp;quot;center&amp;quot; bgcolor=&amp;quot;lightgrey&amp;quot; | coffee break &lt;br /&gt;
|-&lt;br /&gt;
|4:00-4:35 || Seunghwa Ryu || Haneesh || (meeting) || rowspan=&amp;quot;2&amp;quot; | &#039;&#039;&#039;MC seminar&#039;&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|4:40-6:00 || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039; || &#039;&#039;work&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Meetings to sign-up&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Eunseok&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | ILL Ryu&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Seokwoo&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Haneesh&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Jie&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Sylvie&lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | &lt;br /&gt;
| width=&amp;quot;120pt&amp;quot; | Billy&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | Hark  (bi-weekly)&lt;br /&gt;
| colspan=&amp;quot;3&amp;quot; | Jie, Prof. Barnett (bi-weekly)&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | Ibrahim  (bi-weekly)&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot; | Seminar speaker       &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3432</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3432"/>
		<updated>2009-08-15T00:28:54Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD simulations of NVT ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. This question is not trivial because a system of NVT ensemble is not an isolated system in a sense that it is connected to the heat bath to control temperature. &lt;br /&gt;
&lt;br /&gt;
In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 5(c), it is interesting to observe that angular momentum exponentially decays in the early time and eventually fluctuates around some constant value later. This behavior can be understood if we take a closer look on Nos&amp;amp;eacute;-Hoover dynamics. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\frac{d\zeta}{dt&#039;} &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior of the angular momentum, though &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; is a function of time. Linear momentum will show similar behavior when its initial value is not zero, because&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{P}&#039; = - \zeta \mathbf{P}&#039;&amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
from the 1st equation of NH equations of motion. It would be an interesting question how changes in &#039;&#039;Q&#039;&#039; will affect the behavior of momenta.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3431</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3431"/>
		<updated>2009-08-14T23:54:50Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD simulations of NVT ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. This question is not trivial because a system of NVT ensemble is not an isolated system in a sense that it is connected to the heat bath to control temperature. &lt;br /&gt;
&lt;br /&gt;
In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 5(c), it is interesting to observe that angular momentum exponentially decays in the early time and eventually fluctuates around some constant value later. This behavior can be understood if we take a closer look on Nos&amp;amp;eacute;-Hoover dynamics. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\frac{d\zeta}{dt&#039;} &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3430</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3430"/>
		<updated>2009-08-14T23:41:38Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD simulations of NVT ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. This question is not trivial because a system of NVT ensemble is not an isolated system in a sense that it is connected to the heat bath to control temperature. &lt;br /&gt;
&lt;br /&gt;
In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 5(c), it is interesting to observe that angular momentum exponentially decays in the early time and eventually fluctuates around some constant value later. This behavior can be understood if we take a closer look on Nos&amp;amp;eacute;-Hoover dynamics. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3429</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3429"/>
		<updated>2009-07-20T17:51:20Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD simulations of NVT ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. This question is important because a system of NVT ensemble is not isolated system because it has heat bath. In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According to figure 5(c), angular momentum exponentially decays in the early time and fluctuates around some constant value later. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3428</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3428"/>
		<updated>2009-07-20T07:05:45Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* MD simulations of NVT ensemble */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. This question is important because a system of NVT ensemble is not isolated system because of its heat bath. In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According to figure 5(c), angular momentum exponentially decays in the early time and fluctuates around some constant value later. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3427</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3427"/>
		<updated>2009-07-20T07:00:43Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Si NW */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selectively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According to figure 5(c), angular momentum exponentially decays in the early time and fluctuates around some constant value later. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3426</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3426"/>
		<updated>2009-07-20T06:57:40Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Si cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selletively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According to figure 5(c), angular momentum exponentially decays in the early time and fluctuates around some constant value later. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
	<entry>
		<id>http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3425</id>
		<title>M10 Angular momentum is conserved or not</title>
		<link rel="alternate" type="text/html" href="http://micro.stanford.edu/mediawiki/index.php?title=M10_Angular_momentum_is_conserved_or_not&amp;diff=3425"/>
		<updated>2009-07-20T06:56:19Z</updated>

		<summary type="html">&lt;p&gt;Kwkang: /* Bulk Si */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;H1 ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&lt;br /&gt;
Conservation of Angular Momentum&amp;lt;/H1&amp;gt;&lt;br /&gt;
&amp;lt;DIV&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;&amp;lt;STRONG&amp;gt;Keonwook Kang, Seunghwa Ryu and Wei Cai&amp;lt;/STRONG&amp;gt;&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;/DIV&amp;gt;&lt;br /&gt;
&amp;lt;P ALIGN=&amp;quot;CENTER&amp;quot;&amp;gt;[[ Jul 06 ]], [[2009]]&amp;lt;/P&amp;gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&amp;lt;BR&amp;gt;&amp;lt;HR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Linear and angular momentum conservations ==&lt;br /&gt;
&lt;br /&gt;
From classical dynamics, if a system is isolated such that there are no external force (&#039;&#039;&#039;F&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) and torque (&#039;&#039;&#039;T&#039;&#039;&#039;&amp;lt;sub&amp;gt;ext&amp;lt;/sub&amp;gt;) acting on it, its linear and angular momenta are conserved since &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \dot\mathbf{P} &amp;amp; = &amp;amp; \mathbf{F}_{\mathrm{ext}} = 0 \\  \dot\mathbf{L} &amp;amp; = &amp;amp;  \mathbf{T}_{\mathrm{ext}} = 0, \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where linear momentum &#039;&#039;&#039;P&#039;&#039;&#039; and angular momentum &#039;&#039;&#039;L&#039;&#039;&#039; are obtained as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{P} &amp;amp; \equiv &amp;amp; \sum_i m_i\mathbf{v}_ i \\  \mathbf{L} &amp;amp; \equiv &amp;amp; \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i \end{array} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
in multi-body system. &lt;br /&gt;
&lt;br /&gt;
Since molecular dynamics simulations follows classical dynamics theory, we would naturally expect that linear and angular momenta of a system of NVE ensemble will be constant during the time integration. Or&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i m_i\mathbf{v}_ i = \mathrm{Const.} \\  \sum_i \mathbf{r}_i \times m_i\mathbf{v}_i = \mathrm{Const.} \end{array}. &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this manual, we will check whether linear and angular momenta are indeed conserved in MD simulations with or without periodic boundary conditions.&lt;br /&gt;
&lt;br /&gt;
== Zeroing out linear/angular momentum ==&lt;br /&gt;
&lt;br /&gt;
In molecular dynamics simulations, we usually prevent our system of interest from drifting. For this purpose, we subtract ceter-of-mass velocity from the velocity of each atom.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_ i - \mathbf{v}_{\mathrm{CM}}, &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;v&#039;&#039;&#039;&amp;lt;sub&amp;gt;CM&amp;lt;/sub&amp;gt; is defined as &lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_{\mathrm{CM}} \equiv \frac{\sum_i m_i \mathbf{v}_i}{\sum_i m_i} &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In this case, the linear momentum becomes zero.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{P} = \sum_i m_i\mathbf{v}_i - \mathbf{v}_{\mathrm{CM}}\sum_i m_i= 0 &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is a special case of linear momentum conservation. And it accords well with periodic boundary conditions (PBC). You can think of a simulation system that loses some amount of linear momentum that leaves through a boundary gains exactly the same amount of linear momentum from the opposite boundary due to PBCs.&lt;br /&gt;
&lt;br /&gt;
Similarly, we can additionally subtract velocity components, &amp;lt;math&amp;gt;\Omega\times\mathbf{r}_i&amp;lt;/math&amp;gt; shown below, contributing rotation motion so that the whole system can not rotate.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{v}_i := \mathbf{v}_i - \mathbf{\Omega}\times\mathbf{r}_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
The angular velocity &#039;&#039;&#039;&amp;amp;Omega;&#039;&#039;&#039; is obtained from&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{\Omega} \equiv \mathbf{I}^{-1} \mathbf{L} &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
and moment-of-inertia matrix &#039;&#039;&#039;I&#039;&#039;&#039; is expressed as&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{I} \equiv \sum_i m_i(\mathbf{E}_3|\mathbf{r}_i|^2 - \mathbf{r}_i\otimes\mathbf{r}_i)&amp;lt;/math&amp;gt;, &lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;E&#039;&#039;&#039;&amp;lt;sub&amp;gt;3&amp;lt;/sub&amp;gt; is a 3 by 3 identity matrix.&lt;br /&gt;
&lt;br /&gt;
However, it is questionable that a system under periodic boundary conditions can indeed maintain constant angular momentum. Let&#039;s check the conservations of both linear and angular momentum in test MD simulations below.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVE ensemble == &lt;br /&gt;
&lt;br /&gt;
=== Bulk Si ===&lt;br /&gt;
For the 1st test simulation, a diamond cubic structure of 216 silicon atoms are equilbriated under periodic boundary conditions for 10,000 steps using NVE ensemble. Linear and angular momenta are initially zeroed out as explained above.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 1&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_N216_PBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
During 10,000 steps, the linear momentum is conserved within the machine precision in figure 1(b). On the other hand, figure 1(c) shows that the angular momentum is not conserved within the machine precision. What is interesting is that the angular momentum is fluctuating around zero. Even if the angular momentum is not initially zeroed out, its behavior is very much similar in terms of fluctuation maginutude and frequency, though it is not shown here. What does this mean?&lt;br /&gt;
&lt;br /&gt;
Allen and Tildesley&amp;lt;ref&amp;gt;M. P. Allen and D. J. Tildesley, &#039;&#039;Computer Simulations of Liquids&#039;&#039;, Oxford Science Publications (2004) pp.72-73&amp;lt;/ref&amp;gt; clearly stated that the angular momentum is not conserved in MD simulations with periodic boundary conditions as quoted below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;If the system is invariant to rotation about an axis, then the corresponding angular momentum component is conserved. ... In the case of the periodic boundary conditions, ... none of them were spherically symmetrical; in fact it is impossible (in Euclidean space) to construct a spherically symmetric periodic system. Hence, ... &#039;&#039;&#039;total angular momentum is not conserved in most molecular dynamics simulations&#039;&#039;&#039;.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Though the angular momentum is not conserved, its average value is close to zero and we do not observe the simulation system rotating during the simulation. The only possible explanation is that there exists time-varying external torque that makes the angular momentum be zero in average sense. Periodic boundary conditions are interesting constraints because they break the angular momentum conservation but they enforce the system not to rotate in a such way that the image cells apply external torques to the primary cell to compensate the rotation of the primary cell.&lt;br /&gt;
&lt;br /&gt;
=== Si cluster ===&lt;br /&gt;
Let&#039;s check the above statement via another test simulation, where a Si cluster of 216 atoms are equilbrated with the same initial velocity. In this simulation, the simulation box has margin surrounding the Si cluster such that the cluster no longer sees its periodic images. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 2&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_noPBC.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_noPBC.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 2(b) and 2(c), we can see that linear and angular momenta are conserved within the machine precision in this test simulation.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Si NW ===&lt;br /&gt;
Since the angular momentum is not conserved in MD simulations under periodic boundary conditions, it is usually unnecessary to make angular momentum be zero when the velocities of atoms are initialized. However, when we perform simulations of nanowires or rods, it is desirable to prevent the rotation around wire axis. For example,  if a nanowire is aligned along the &#039;&#039;z&#039;&#039;-direction, we want to let the &#039;&#039;z&#039;&#039;-component of angular momentum be zero, or &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
&lt;br /&gt;
In MD++ there is a variable &#039;&#039;&#039;zerorot&#039;&#039;&#039;, depending on whose value components of the angular momentum can be selletively zero. If &#039;&#039;&#039;zerorot = &amp;quot;x&amp;quot;&#039;&#039;&#039;, &#039;&#039;x&#039;&#039;-component of angular momentum will be zero. If &#039;&#039;&#039;zerorot = &amp;quot;all&amp;quot;&#039;&#039;&#039;, all three components of the angular momentum will be zero. The default value of &#039;&#039;&#039;zerorot&#039;&#039;&#039; is &amp;quot;none&amp;quot;. The other possible values are &amp;quot;y&amp;quot; and &amp;quot;z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
In the next test simulation, a Si NW is aligned along the &#039;&#039;z&#039;&#039;-direction and we expect &#039;&#039;&#039;L&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;z&#039;&#039;&amp;lt;/sub&amp;gt; = 0.&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 3&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_nw.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_nw.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_nw.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In figure 3(b) and 3(c), we can see that all three components of linear momentum and &#039;&#039;z&#039;&#039;-component of angular momentum are conserved during equilibriation.&lt;br /&gt;
&lt;br /&gt;
MD++ script for this simulation is given below.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# -*-shell-script-*-&lt;br /&gt;
# Check linear momentum and angular momentum conservation &lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Definition of procedures&lt;br /&gt;
#*******************************************&lt;br /&gt;
proc initmd { n } {&lt;br /&gt;
#MD++ setnolog&lt;br /&gt;
MD++ setoverwrite&lt;br /&gt;
MD++ dirname = &amp;quot;runs/si-test-$n&amp;quot;&lt;br /&gt;
MD++ NNM = 300&lt;br /&gt;
}&lt;br /&gt;
#end of proc initmd&lt;br /&gt;
&lt;br /&gt;
proc create_crystal { N } {&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
# Create Perfect Lattice Configuration&lt;br /&gt;
#&lt;br /&gt;
MD++ latticestructure = diamond-cubic&lt;br /&gt;
MD++ latticeconst = 5.431 #(A) for Si&lt;br /&gt;
MD++ latticesize  = \[ 1 0 0  $N \&lt;br /&gt;
                       0 1 0  $N \&lt;br /&gt;
                       0 0 1  $N \]&lt;br /&gt;
MD++ makecrystal finalcnfile = perf.cn writecn&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#--------------------------------------------&lt;br /&gt;
proc setup_md { } { MD++ {&lt;br /&gt;
equilsteps = 0  timestep = 0.001 # (ps)&lt;br /&gt;
atommass = 28.0855 # (g/mol) Si&lt;br /&gt;
DOUBLE_T = 0  equilsteps = 0&lt;br /&gt;
saveprop = 1 savepropfreq = 10 openpropfile #run&lt;br /&gt;
savecn = 0 savecnfreq = 10000&lt;br /&gt;
plotfreq = 20&lt;br /&gt;
vt2 = 2e28  #1e28 2e28 5e28&lt;br /&gt;
wallmass = 2e3     # atommass * NP = 14380&lt;br /&gt;
boxdamp = 1e-3     # optimal damping for 216 atoms and wallmass 1e-3&lt;br /&gt;
randseed = 12345 srand48&lt;br /&gt;
#MD++  srand48bytime&lt;br /&gt;
saveH # Use current H as reference (H0), needed for specifying stress&lt;br /&gt;
fixboxvec  = [ 0 1 1&lt;br /&gt;
               1 0 1&lt;br /&gt;
               1 1 0 ]&lt;br /&gt;
stress = [ 0 0 0&lt;br /&gt;
           0 0 0&lt;br /&gt;
           0 0 0 ]&lt;br /&gt;
output_fmt = &amp;quot;curstep EPOT Tinst VIRIAL(0) VIRIAL(4) DVIRIALDexx(0) DVIRIALDexx(4)&amp;quot;&lt;br /&gt;
writeall = 1&lt;br /&gt;
} }&lt;br /&gt;
&lt;br /&gt;
#*******************************************&lt;br /&gt;
# Main program starts here&lt;br /&gt;
#*******************************************&lt;br /&gt;
set T 300&lt;br /&gt;
initmd NW&lt;br /&gt;
create_crystal 5&lt;br /&gt;
MD++ input = \[ 3 2 0 0 5 0 \] makecylinder&lt;br /&gt;
&lt;br /&gt;
MD++ input = \[1 1 1\] changeH_keepR&lt;br /&gt;
MD++ input = \[2 2 1\] changeH_keepR&lt;br /&gt;
&lt;br /&gt;
setup_md&lt;br /&gt;
MD++ totalsteps = 10000&lt;br /&gt;
MD++ T_OBJ = $T DOUBLE_T = 1 timestep = 0.001&lt;br /&gt;
&lt;br /&gt;
MD++ initvelocity_type = &amp;quot;Gaussian&amp;quot; zerorot = &amp;quot;z&amp;quot; initvelocity&lt;br /&gt;
MD++ finalcnfile = init.cn writecn&lt;br /&gt;
MD++ finalcnfile = init.cfg writeatomeyecfg&lt;br /&gt;
  &lt;br /&gt;
MD++ ensemble_type = &amp;quot;NVE&amp;quot; integrator_type = &amp;quot;VVerlet&amp;quot;&lt;br /&gt;
MD++ {output_fmt = &amp;quot;curstep EPOT KATOM Tinst HELMP \&lt;br /&gt;
              TSTRESSinMPa_xx TSTRESSinMPa_yy TSTRESSinMPa_zz \&lt;br /&gt;
              TSTRESSinMPa_xy TSTRESSinMPa_xz TSTRESSinMPa_yz \&lt;br /&gt;
              H_11 H_22 H_33 H_12 H_13 H_21 H_23 H_31 H_32 \&lt;br /&gt;
              [MD++_Get P_com(0)] [MD++_Get P_com(1)] [MD++_Get P_com(2)] \&lt;br /&gt;
              [MD++_Get L_com(0)] [MD++_Get L_com(1)] [MD++_Get L_com(2)]&amp;quot; }&lt;br /&gt;
MD++ run&lt;br /&gt;
&lt;br /&gt;
MD++ finalcnfile = equil.cn writecn&lt;br /&gt;
MD++ finalcnfile = equil.cfg writeatomeyecfg&lt;br /&gt;
MD++ quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MD++ variable &#039;&#039;&#039;zerorot&#039;&#039;&#039; can be used with the MD++ command &#039;&#039;&#039;initvelocity&#039;&#039;&#039; as shown above. Or it can be used with another command &#039;&#039;&#039;zerorotation&#039;&#039;&#039;. Internally, &#039;&#039;&#039;initvelocity&#039;&#039;&#039; calls the function &#039;&#039;&#039;zero_rotation()&#039;&#039;&#039; depending on the value of &#039;&#039;&#039;zerorot&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;HR&amp;gt;&amp;lt;BR&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== MD simulations of NVT ensemble == &lt;br /&gt;
&lt;br /&gt;
Upto here we have considered MD simulations of NVE ensemble. People might wonder whether the linear and the angular momenta will be conserved in case of canonical or NVT ensemble. In MD++, Nos&amp;amp;eacute;-Hoover thermostat is used for NVT ensemble. Nos&amp;amp;eacute;&#039;s Hamiltonian is expressed in time scaling variable &#039;&#039;s&#039;&#039; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathcal{H} = \frac{1}{2} \sum_i \frac{|\mathbf{p}_i|^2}{m_i s^2} + U(\{\mathbf{r}_i\})&lt;br /&gt;
              + \frac{p_s^2}{2Q} + \frac{g\ln s}{\beta}&amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
where &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; and &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt; are scaled coordinate and momentum of atoms. And they are related with real coordinate &#039;&#039;&#039;r&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; and momenutm &#039;&#039;&#039;p&#039;&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;i&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;math&amp;gt;&#039;&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \mathbf{r}_i &amp;amp; = &amp;amp; \mathbf{r}&#039;_ i \\  &lt;br /&gt;
\mathbf{p}_i &amp;amp; = &amp;amp; s\mathbf{p}&#039;_i  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The real time step &amp;lt;math&amp;gt;\Delta t&#039;&amp;lt;/math&amp;gt; are related with the scaled time step &amp;lt;math&amp;gt;\Delta t&amp;lt;/math&amp;gt; as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \Delta t &#039; = \Delta t / s &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Q&#039;&#039; is thermal mass, &#039;&#039;g&#039;&#039; is number of degree of freedom, and &#039;&#039;p&#039;&#039;&amp;lt;sub&amp;gt;&#039;&#039;s&#039;&#039;&amp;lt;/sub&amp;gt; is the conjugate momentum of &#039;&#039;s&#039;&#039;. &lt;br /&gt;
Then, the time derivative of the linear and the angular momenta in real coordinate and momentum can be expressed as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d}{dt&#039;}\sum_i\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{p}_i \\  &lt;br /&gt;
\frac{d}{dt&#039;}\sum_i\mathbf{r}&#039;_i\times\mathbf{p}&#039;_i &amp;amp; = &amp;amp; \frac{1}{s}\frac{d}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s^2}\frac{ds}{dt&#039;}\sum_i\mathbf{r}_i \times \mathbf{p}_i = \frac{d}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i - \frac{1}{s}\frac{ds}{dt}\sum_i\mathbf{r}_i \times \mathbf{p}_i \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The 1st terms on the right hand side are zeros, since the linear and the angular momentum are conserved in scaled formulation. However, &#039;&#039;s&#039;&#039; is varing as a function of time and &amp;lt;math&amp;gt;ds/dt \neq 0&amp;lt;/math&amp;gt;. Thus the linear and angular momenta in real varaiable formulation would not be constant in time, unless the following is satisfied.&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \sum_i\mathbf{p}_i &amp;amp; = &amp;amp; 0 \\  &lt;br /&gt;
\sum_i \mathbf{r}_i \times \mathbf{p}_i &amp;amp; = &amp;amp; 0  \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In other words, only if the linear and angular momenta are intially zeros, those quantites are conserved in NVT ensemble.&lt;br /&gt;
Besides, it is known that Nos&amp;amp;eacute; thermostat will generate the trajectory of canonical ensemble if the total momentum is zero.&amp;lt;ref&amp;gt;T. &amp;amp;Ccedil;agin and J. R. Ray, &#039;&#039;Isothermal molecular-dynamics ensembles&#039;&#039;, Phys. Rev. A. (1988) &#039;&#039;&#039;37&#039;&#039;&#039; pp. 4510--4513&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Figure 4 shows the linear and the angular momenta as functions of integration step in MD simulation of NVT ensemble when both linear and angular momenta are initially set to be zeros. You can see that both momenta are conserved.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 4&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On the other hand, figure 5(c) shows how the angular momentum behaves in NVT ensemble simulation when it is not zero initially.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;0&amp;quot;&lt;br /&gt;
!  !! colspan=&amp;quot;3&amp;quot; align=&amp;quot;center&amp;quot; | &#039;&#039;&#039;Figure 5&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;150px&amp;quot; | [[Image:Init_noPBC.jpg|150px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Linearmom_NVT2.jpg|320px]]&lt;br /&gt;
| align=&amp;quot;center&amp;quot; width=&amp;quot;320px&amp;quot; | [[Image:Angmom_NVT2.jpg|320px]]&lt;br /&gt;
|-&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(a)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(b)&lt;br /&gt;
| align=&amp;quot;center&amp;quot; |(c)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
According to figure 5(c), angular momentum exponentially decays in the early time and fluctuates around some constant value later. The equations of motion of Nos&amp;amp;eacute;-Hoover thermostat are given as&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \begin{array}{rcl} \frac{d \mathbf{p}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; - \frac{\partial U(\left\{ \mathbf{r}&#039;_i \right\})}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{p}&#039;_i  \\&lt;br /&gt;
\frac{d \mathbf{r}&#039;_i}{dt&#039;} &amp;amp;=&amp;amp; \frac{\mathbf{p}&#039;_i}{m_i} \\  &lt;br /&gt;
\dot{\zeta}&#039; &amp;amp;=&amp;amp; \frac{gk_B}{Q} \left( T - T_\mathsf{obj} \right) \end{array}&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
From the 1st equation, we can get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \mathbf{r}&#039;_i \times \frac{d \mathbf{p}&#039;_i}{dt&#039;} = - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rearranging time derivative term gives&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{d\mathbf{r}&#039;_i} {dt&#039;} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
By substituting the 2nd equation for the 2nd term in the left hand side, the above equation becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right) - \frac{\mathbf{p}&#039;_i} {m_i} \times \mathbf{p}&#039;_i= - \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;,&lt;br /&gt;
|}&lt;br /&gt;
 &lt;br /&gt;
and the 2nd term in the left hand side becomes zero. If we take summation over &#039;&#039;i&#039;&#039; of remaining terms, we get&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \sum_i \frac{d}{dt&#039;} \left(\mathbf{r}&#039;_i \times \mathbf{p}&#039;_i\right)  = - \sum_i \mathbf{r}&#039;_i \times \frac{\partial U}{\partial \mathbf{r}&#039;_i} - \zeta \sum_i \mathbf{r}&#039;_i \times \mathbf{p}&#039;_i &amp;lt;/math&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Since the 1st term in the right-hand side is the summation of the internal torque, it is zero. Finally, the equation for the angular momentum becomes&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;0&amp;quot; align=&amp;quot;center&amp;quot;&lt;br /&gt;
|&amp;lt;math&amp;gt; \frac{d}{dt&#039;} \mathbf{L}&#039; = - \zeta \mathbf{L}&#039;&amp;lt;/math&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This relation explains the exponential behavior at the early time. Later, when the system reaches equilibrium state, temperature will fluctuate around the objective temperature and &amp;lt;math&amp;gt;d\zeta/dt&#039;&amp;lt;/math&amp;gt; keeps changing its sign to compensate the difference, &#039;&#039;T&#039;&#039;-&#039;&#039;T&#039;&#039;&amp;lt;sub&amp;gt;OBJ&amp;lt;/sub&amp;gt;. Thus, &amp;lt;math&amp;gt;\zeta&amp;lt;/math&amp;gt; will fluctuate around zero in the long run and that explains the flat region of angular momentum curve. Linear momentum would show similiar behavior if its initial value is not zero.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kwkang</name></author>
	</entry>
</feed>