Skip to content

Commit aa4209e

Browse files
committed
more layout improvements small tweaks to text
1 parent 281dff8 commit aa4209e

File tree

1 file changed

+116
-111
lines changed

1 file changed

+116
-111
lines changed

lammps-tutorials.tex

Lines changed: 116 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -711,17 +711,17 @@ \subsubsection{My first input}
711711
\label{fig:chart-log}
712712
\end{figure}
713713

714-
The potential energy decreases from a positive value to a
715-
negative value (Figs.~\ref{fig:chart-log} and~\ref{fig:evolution-energy}\,a).
716-
The initially positive potential energy is
717-
expected, as the atoms are created at random positions within
718-
the simulation box, with some in very close proximity to each other.
719-
This proximity results in a large initial potential energy due to the repulsive branch of the
720-
Lennard-Jones potential [i.e.,~the term in $1/r^{12}$ in Eq.~\eqref{eq:LJ}].
721-
As the energy minimization progresses, the
722-
energy decreases - first rapidly - then more gradually,
723-
before plateauing at a negative value. This indicates that the atoms
724-
have moved to reasonable distances from one another.
714+
The potential energy decreases from a positive value to a negative value
715+
(Figs.~\ref{fig:chart-log} and~\ref{fig:evolution-energy}\,a). The
716+
initially positive potential energy is expected, as the atoms are
717+
created at random positions within the simulation box, with some in very
718+
close proximity to each other. This proximity results in a large
719+
initial potential energy due to the repulsive branch of the
720+
Lennard-Jones potential [i.e.,~the term in $1/r^{12}$ in
721+
Eq.~\eqref{eq:LJ}]. As the energy minimization progresses, the energy
722+
decreases - first rapidly - then more gradually, before plateauing at a
723+
negative value. This indicates that the atoms have moved to reasonable
724+
distances from one another.
725725

726726
Create and save a snapshot image of the simulation state after the
727727
minimization, and compare it to the initial image. You should observe
@@ -778,12 +778,12 @@ \subsubsection{My first input}
778778
duration of 250 time units.
779779

780780
\begin{note}
781-
Since no other fix commands alter forces or velocities,
782-
and periodic boundary conditions are applied in all directions, the MD
783-
simulation will be performed in the microcanonical (NVE) ensemble,
784-
which maintains a constant number of particles and a fixed box volume.
785-
In this ensemble, the system does not exchange energy outside
786-
the simulation box.
781+
Since no other fix commands alter forces or velocities, and periodic
782+
boundary conditions are applied in all directions, the MD simulation
783+
will be performed in the microcanonical (NVE) ensemble, which
784+
maintains a constant number of particles and a fixed box volume. In
785+
this ensemble, the system does not exchange energy with anything
786+
outside the simulation box.
787787
\end{note}
788788

789789
Run the simulation using LAMMPS. Initially, there is no equilibrium
@@ -793,7 +793,8 @@ \subsubsection{My first input}
793793
plateau, indicating that the system has reached equilibrium, with
794794
the total energy fluctuating around a certain constant value.
795795

796-
Now, we change the \lmpcmd{Run} section to (note the shorter run time):
796+
Now, we change the \lmpcmd{Run} section to (note the smaller number of
797+
MD steps):
797798
\begin{lstlisting}
798799
# 5) Run
799800
fix mynve all nve
@@ -802,35 +803,35 @@ \subsubsection{My first input}
802803
run 15000
803804
\end{lstlisting}
804805
The new command adds a Langevin thermostat to the atoms in the group
805-
\lmpcmd{all}, with a desired target temperature of 1.0 temperature units
806-
throughout the run (the two numbers represent the target temperature at the beginning
807-
and at the end of the run, which allows for a temperature ramp if
808-
they differ)~\cite{schneider1978molecular}. A \lmpcmd{damping}
809-
parameter of 0.1 is used. The \lmpcmd{damping} parameter determines how
810-
rapidly the temperature is relaxed to its desired value. In a Langevin
811-
thermostat, the atoms are subject to friction and random noise (in the form
812-
of randomly added velocities). Since a constant friction term removes
813-
more kinetic energy from fast atoms and less from slow atoms, the system
814-
will eventually reach a dynamic equilibrium where the kinetic energy
815-
removed and added are about the same. The number 10917 is a
816-
seed used to initialize the random number generator used inside of
817-
\lmpcmd{fix langevin}; you can change it to perform statistically
818-
independent simulations. In the presence of a thermostat, the MD simulation
819-
will be performed in the canonical or NVT ensemble.
806+
\lmpcmd{all}, with a target temperature of 1.0 temperature units
807+
throughout the run (the two numbers represent the target temperature at
808+
the beginning and at the end of the run, which results in a temperature
809+
ramp if they differ)~\cite{schneider1978molecular}. A \lmpcmd{damping}
810+
parameter of 0.1 is used. It determines how rapidly the temperature is
811+
relaxed to its desired value. In a Langevin thermostat, the atoms are
812+
subject to friction and random noise (in the form of randomly added
813+
velocities). Since a constant friction term removes more kinetic energy
814+
from fast atoms and less from slow atoms, the system will eventually
815+
reach a dynamic equilibrium where the kinetic energy removed and added
816+
are about the same. The number 10917 is a seed used to initialize the
817+
random number generator used inside of \lmpcmd{fix langevin}; you can
818+
change it to perform statistically independent simulations. In the
819+
presence of a thermostat, the MD simulation will be performed in the
820+
canonical or NVT ensemble.
820821

821822
\begin{figure}
822823
\centering
823824
\includegraphics[width=\linewidth]{LJ-energy}
824825
\caption{Potential energy ($p_\text{e}$) of the binary mixture simulated
825826
during \hyperref[lennard-jones-label]{Tutorial 1} as a function of the
826827
step during energy minimization (a) and as a function of time during
827-
molecular dynamics in the NVT ensemble (b). b)~Kinetic energy
828+
molecular dynamics in the NVT ensemble (b), and kinetic energy
828829
($k_\text{e}$) during energy minimization (c) and during molecular
829830
dynamics (d).}
830831
\label{fig:evolution-energy}
831832
\end{figure}
832833

833-
Run the simulation again using LAMMPS. From the information
834+
Run the simulation again using \lammpsgui{}. From the information
834835
printed in the \guicmd{Output} window, one can see that the temperature
835836
starts from 0 but rapidly reaches the requested value and
836837
stabilizes itself near $T=1$ temperature units. One can also observe that
@@ -839,22 +840,23 @@ \subsubsection{My first input}
839840
the molecular dynamics simulation starts, $p_\text{e}$ increases until
840841
it reaches a plateau value of about -0.25. The kinetic energy,
841842
$k_\text{e}$, is equal to zero during energy minimization and then
842-
increases rapibly during molecular dynamics until it reaches
843-
a plateau value of about 1.5 (Fig.~\ref{fig:evolution-energy}\,b).
843+
increases rapidly during molecular dynamics until it reaches
844+
a plateau value of about 1.5 (Fig.~\ref{fig:evolution-energy}\,d).
844845

845846
\paragraph{Trajectory visualization}
846847

847848
So far, the simulation has been mostly monitored through the analysis of
848-
thermodynamic information. To better follow the evolution of the system and visualize
849-
the trajectories of the atoms, let us use the \lmpcmd{dump image} command to
850-
create snapshot images during the simulation. We have already explored
851-
the \guicmd{Image Viewer} window. Open it again and adjust the
852-
visualization to your liking using the available buttons. Now you can
853-
copy the commands used to create this visualization to the clipboard
854-
by either using the \guicmd{Ctrl-D} keyboard shortcut or selecting
855-
\guicmd{Copy dump image command} from the \guicmd{File} menu. This text
856-
can be pasted into the into the \lmpcmd{Visualization} section of
857-
\lmpcmd{PART B} of the \flecmd{initial.lmp} file. This may look like the following:
849+
thermodynamic information. To better follow the evolution of the system
850+
and visualize the trajectories of the atoms, let us use the \lmpcmd{dump
851+
image} command to create snapshot images during the simulation. We
852+
have already explored the \guicmd{Image Viewer} window. Open it again
853+
and adjust the visualization to your liking using the available buttons.
854+
Now you can copy the commands used to create this visualization to the
855+
clipboard by either using the \guicmd{Ctrl-D} keyboard shortcut or
856+
selecting \guicmd{Copy dump image command} from the \guicmd{File} menu.
857+
This text can be pasted into the into the \lmpcmd{Visualization} section
858+
of \lmpcmd{PART B} of the \flecmd{initial.lmp} file. This may look like
859+
the following:
858860
\begin{lstlisting}
859861
dump viz all image 100 myimage-*.ppm type type &
860862
size 800 800 zoom 1.452 shiny 0.7 fsaa yes &
@@ -938,30 +940,41 @@ \subsubsection{Improving the script}
938940
\end{lstlisting}
939941

940942
\begin{note}
941-
A key improvement to the input is the addition of the
942-
\lmpcmd{write\_data} command. This command writes the state
943-
of the system to a text file called \flecmd{improved.min.data}.
944-
This \flecmd{.data} file will be used later
945-
to restart the simulation from the final state of the energy
946-
minimization step, eliminating the need to repeat the system creation and minimization.
943+
A key improvement to the input is the addition of the
944+
\lmpcmd{write\_data} command. This command writes the state of the
945+
system to a text file called \flecmd{improved.min.data}. This
946+
\flecmd{.data} file will be used later to restart the simulation from
947+
the final state of the energy minimization step, eliminating the need
948+
to repeat the system creation and minimization.
947949
\end{note}
948950

949-
Run the \flecmd{improved.min.lmp} file using LAMMPS. At the end of the simulation,
950-
a file called \flecmd{improved.min.data} is created. You can view the contents
951-
of this file from the \lammpsgui{}, by right-clicking on the file name in
952-
the editor and selecting the entry \guicmd{View file `improved.min.data'}.
953-
954-
The created \flecmd{.data} file contains all the information necessary to
955-
restart the simulation, such as the number of atoms, the box size, the
956-
masses, and the pair coefficients. This \flecmd{.data} file also contains the final
957-
positions of the atoms within the \lmpcmd{Atoms} section. The first five
958-
columns of the \lmpcmd{Atoms} section correspond (from left to right) to
959-
the atom indexes (from 1 to the total number of atoms, 1150), the atom
960-
types (1 or 2 here), and the positions of the atoms $x$, $y$, $z$. The
961-
last three columns are image flags that keep track of which atoms
962-
crossed the periodic boundary. The exact format of each line in the
963-
\lmpcmd{Atoms} section depends on the choice of \lmpcmd{atom\_style}, which
964-
determines which per-atom data is set and stored internally in LAMMPS.
951+
Run the \flecmd{improved.min.lmp} file using \lammpsgui{}. At the end
952+
of the simulation, a file called \flecmd{improved.min.data} is created.
953+
You can view the contents of this file from \lammpsgui{}, by
954+
right-clicking on the file name in the editor and selecting the entry
955+
\guicmd{View file `improved.min.data'}.
956+
957+
\begin{figure}
958+
\centering
959+
\includegraphics[width=0.55\linewidth]{LJ-cylinder}
960+
\caption{Visualization of the improved binary mixture input after minimization
961+
during \hyperref[lennard-jones-label]{Tutorial 1}. Colors are the same as in
962+
Fig.~\ref{fig:LJ}.}
963+
\label{fig:improved-min}
964+
\end{figure}
965+
966+
The created \flecmd{.data} file contains all the information necessary
967+
to restart the simulation, such as the number of atoms, the box size,
968+
the masses, and the pair coefficients. This \flecmd{.data} file also
969+
contains the final positions of the atoms within the \lmpcmd{Atoms}
970+
section. The first five columns of the \lmpcmd{Atoms} section
971+
correspond (from left to right) to the atom indexes (from 1 to the total
972+
number of atoms, 1150), the atom types (1 or 2 here), and the positions
973+
of the atoms $x$, $y$, $z$. The last three columns are image flags that
974+
keep track of which atoms crossed the periodic boundary. The exact
975+
format of each line in the \lmpcmd{Atoms} section depends on the choice
976+
of \lmpcmd{atom\_style}, which determines which per-atom data is set and
977+
stored internally in LAMMPS.
965978

966979
\begin{note}
967980
Instead of the \lmpcmdnote{write\_data} command, you can also use the
@@ -978,16 +991,6 @@ \subsubsection{Improving the script}
978991

979992
\paragraph{Restarting from a saved configuration}
980993

981-
\begin{figure}
982-
\centering
983-
\includegraphics[width=0.55\linewidth]{LJ-cylinder}
984-
\caption{Improved visualization of the binary mixture simulated
985-
during \hyperref[lennard-jones-label]{Tutorial 1}. The atoms of type 1 are
986-
represented as small red spheres, the atoms of type 2 as large green spheres,
987-
and the edges of the simulation box are represented as blue sticks.}
988-
\label{fig:improved-min}
989-
\end{figure}
990-
991994
To continue a simulation from the saved configuration, open the
992995
\flecmd{improved.md.lmp} file, which was downloaded during the tutorial setup.
993996
This file contains the \textit{Initialization} part from \flecmd{initial.lmp}
@@ -1021,6 +1024,7 @@ \subsubsection{Improving the script}
10211024
atoms of type 2 inside the cylinder and atoms of type 1 outside the
10221025
cylinder, let us delete the misplaced atoms by adding the following
10231026
commands to \flecmd{improved.md.lmp}:
1027+
10241028
\begin{lstlisting}
10251029
region cyl_in cylinder z 0 0 10 INF INF side in
10261030
region cyl_out cylinder z 0 0 10 INF INF side out
@@ -1128,16 +1132,17 @@ \subsubsection{Improving the script}
11281132
timestep 0.005
11291133
run 300000
11301134
\end{lstlisting}
1131-
Here, there are a few more differences from the previous simulation. First,
1132-
the \lmpcmd{velocity create} command assigns an initial velocity to each
1133-
atom. The initial velocity is chosen so that the average initial
1134-
temperature is equal to 1.0 temperature units. The additional keywords
1135-
ensure that no linear momentum (\lmpcmd{mom yes}) is given to the
1136-
system and that the generated velocities are distributed according to
1137-
a Gaussian distribution. Another improvement is the \lmpcmd{zero yes}
1138-
keyword in the Langevin thermostat, which ensures that the total random
1139-
force applied to the atoms is equal to zero.
1140-
1135+
Here, there are a few more differences from the previous simulation.
1136+
First, the \lmpcmd{velocity create} command assigns an initial velocity
1137+
to each atom. The initial velocity is chosen so that the average
1138+
initial temperature is equal to 1.0 temperature units. The additional
1139+
keywords ensure that no linear momentum (\lmpcmd{mom yes}) is given to
1140+
the system and that the generated velocities are distributed according
1141+
to a Gaussian distribution. Another improvement is the \lmpcmd{zero
1142+
yes} keyword in the Langevin thermostat, which ensures that the total
1143+
random force applied to the atoms is equal to zero. These steps are
1144+
important to prevent the system from starting to drift or move as a
1145+
whole.
11411146
\begin{figure}
11421147
\centering
11431148
\includegraphics[width=\linewidth]{LJ-mixing}
@@ -1149,15 +1154,14 @@ \subsubsection{Improving the script}
11491154
\end{figure}
11501155

11511156
\begin{note}
1152-
The steps to ensure no initial linear momentum and no net total
1153-
force are important to prevent the system from starting to drift or move as a
1154-
whole. For a bulk system with periodic boundary conditions, it is
1155-
expected to remain in place. Accordingly, when computing the temperature from the
1156-
kinetic energy, we use $3N-3$ degrees of freedom since there is no
1157-
global translation. In a drifting system, some of the kinetic energy is
1158-
due to the drift, which means the system itself cools down. In
1159-
extreme cases, the system can freeze while its center of mass drifts very quickly. This phenomenon is
1160-
sometimes referred to as the ``flying ice cube syndrome''~\cite{wong2016good}.
1157+
A bulk system with periodic boundary conditions is expected to remain
1158+
in place. Accordingly, when computing the temperature from the
1159+
kinetic energy, we use $3N-3$ degrees of freedom since there is no
1160+
global translation. In a drifting system, some of the kinetic energy
1161+
is due to the drift, which means the system itself cools down. In
1162+
extreme cases, the system can freeze while its center of mass drifts
1163+
very quickly. This phenomenon is sometimes referred to as the
1164+
``flying ice cube syndrome''~\cite{wong2016good}.
11611165
\end{note}
11621166

11631167
Run \flecmd{improved.md.lmp} and observe the mixing of the two populations
@@ -1175,17 +1179,6 @@ \subsubsection{Improving the script}
11751179
expected during mixing. This can be observed using the entry
11761180
\guicmd{c\_sumcoor12} in the \guicmd{Charts} drop-down menu.
11771181

1178-
\begin{figure}
1179-
\centering
1180-
\includegraphics[width=0.55\linewidth]{LJ-coords}
1181-
\caption{Snapshot of the binary mixture simulated
1182-
during \hyperref[lennard-jones-label]{Tutorial 1} with atoms of type 1
1183-
colored according to their computed $1-2$ coordination
1184-
number from the compute \lmpcmd{coor12}, ranging from turquoise,\lmpcmd{c\_coor12 = 0},
1185-
to yellow, \lmpcmd{c\_coor12 = 1}, and red, \lmpcmd{c\_coor12 = 2}.}
1186-
\label{fig:coords-viz}
1187-
\end{figure}
1188-
11891182
\paragraph{Experiments}
11901183

11911184
Here are some suggestions for further experiments with this system that
@@ -1201,14 +1194,26 @@ \subsubsection{Improving the script}
12011194
\item Append an NVE run (i.e.~without any thermostat) and observe the energy levels.
12021195
\end{itemize}
12031196

1197+
1198+
\begin{figure}
1199+
\centering
1200+
\includegraphics[width=0.55\linewidth]{LJ-coords}
1201+
\caption{Snapshot of the binary mixture simulated
1202+
during \hyperref[lennard-jones-label]{Tutorial 1} with atoms of type 1
1203+
colored according to their computed $1-2$ coordination
1204+
number from the compute \lmpcmd{coor12}, ranging from turquoise,\lmpcmd{c\_coor12 = 0},
1205+
to yellow, \lmpcmd{c\_coor12 = 1}, and red, \lmpcmd{c\_coor12 = 2}.}
1206+
\label{fig:coords-viz}
1207+
\end{figure}
1208+
12041209
Another useful experiment is coloring the atoms in the \guicmd{Slide Show}
12051210
according to an observable, such as their respective coordination
12061211
numbers. To do this, replace the
12071212
\lmpcmd{dump} and \lmpcmd{dump\_modify} commands with the following lines:
12081213
\begin{lstlisting}
12091214
variable coor12 atom (type==1)*(c_coor12)+(type==2)*-1
1210-
dump viz all image 1000 myimage-*.ppm v_coor12 &
1211-
type shiny 0.1 box no 0.01 view 0 0 zoom 1.8 fsaa yes size 800 800
1215+
dump viz all image 1000 myimage-*.ppm v_coor12 type &
1216+
shiny 0.1 box no 0.01 view 0 0 zoom 1.8 fsaa yes size 800 800
12121217
dump_modify viz adiam 1 1 adiam 2 3 backcolor white &
12131218
amap -1 2 ca 0.0 4 min royalblue 0 turquoise 1 yellow max red
12141219
\end{lstlisting}

0 commit comments

Comments
 (0)