Skip to content

Commit 40fea7f

Browse files
committed
improve figure placement and layout for tutorials 1 and 2
also some small corrections and reformulations are added.
1 parent fc84962 commit 40fea7f

1 file changed

Lines changed: 105 additions & 105 deletions

File tree

lammps-tutorials.tex

Lines changed: 105 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -801,17 +801,6 @@ \subsubsection{My first input}
801801

802802
\paragraph{Molecular dynamics}
803803

804-
\begin{figure}
805-
\centering
806-
\includegraphics[width=\linewidth]{LJ-energy}
807-
\caption{(a) Potential energy, $U$, of the binary mixture as a function of the
808-
step during energy minimization in \hyperref[lennard-jones-label]{Tutorial 1}.
809-
(b) Potential energy, $U$, as a function of time during molecular dynamics in
810-
the NVT ensemble. (c) Kinetic energy, $K$, during energy minimization.
811-
(d) Kinetic energy, $K$, during molecular dynamics.}
812-
\label{fig:evolution-energy}
813-
\end{figure}
814-
815804
After energy minimization, any overlapping atoms are displaced, and
816805
the system is ready for a molecular dynamics simulation. To continue
817806
from the result of the minimization step, append the MD simulation
@@ -896,6 +885,17 @@ \subsubsection{My first input}
896885
presence of a thermostat, the MD simulation will be performed in the
897886
canonical or NVT ensemble.
898887

888+
\begin{figure}
889+
\centering
890+
\includegraphics[width=\linewidth]{LJ-energy}
891+
\caption{(a) Potential energy, $U$, of the binary mixture as a function of the
892+
step during energy minimization in \hyperref[lennard-jones-label]{Tutorial 1}.
893+
(b) Potential energy, $U$, as a function of time during molecular dynamics in
894+
the NVT ensemble. (c) Kinetic energy, $K$, during energy minimization.
895+
(d) Kinetic energy, $K$, during molecular dynamics.}
896+
\label{fig:evolution-energy}
897+
\end{figure}
898+
899899
Run the simulation again using \lammpsgui{}. From the information
900900
printed in the \guicmd{Output} window, one can see that the temperature
901901
starts from 0 but rapidly reaches the requested value and
@@ -988,7 +988,6 @@ \subsubsection{Improving the script}
988988
# 5) Run
989989
minimize 1.0e-6 1.0e-6 1000 10000
990990
\end{lstlisting}
991-
992991
We want to create the atoms of types 1 and 2 in two separate
993992
regions. To achieve this, we need to add two \lmpcmd{region} commands and then
994993
reintroduce the \lmpcmd{create\_atoms} commands, this time using the new
@@ -1021,7 +1020,6 @@ \subsubsection{Improving the script}
10211020
the final state of the energy minimization step, eliminating the need
10221021
to repeat the system creation and minimization.
10231022
\end{note}
1024-
10251023
Run the \flecmd{improved.min.lmp} file using \lammpsgui{}. At the end
10261024
of the simulation, a file called \flecmd{improved.min.data} is created.
10271025
You can view the contents of this file from \lammpsgui{}, by
@@ -1041,15 +1039,6 @@ \subsubsection{Improving the script}
10411039
of \lmpcmd{atom\_style}, which determines which per-atom data is set and
10421040
stored internally in LAMMPS.
10431041

1044-
\begin{figure}
1045-
\centering
1046-
\includegraphics[width=0.75\linewidth]{LJ-cylinder}
1047-
\caption{Visualization of the improved binary mixture input after minimization
1048-
during \hyperref[lennard-jones-label]{Tutorial 1}. Colors are the same as in
1049-
Fig.~\ref{fig:LJ}.}
1050-
\label{fig:improved-min}
1051-
\end{figure}
1052-
10531042
\begin{note}
10541043
Instead of the \lmpcmdnote{write\_data} command, you can also use the
10551044
\lmpcmdnote{write\_restart} command to save the state
@@ -1092,6 +1081,15 @@ \subsubsection{Improving the script}
10921081
read_data improved.min.data
10931082
\end{lstlisting}
10941083

1084+
\begin{figure}
1085+
\centering
1086+
\includegraphics[width=0.55\linewidth]{LJ-cylinder}
1087+
\caption{Visualization of the improved binary mixture input after minimization
1088+
during \hyperref[lennard-jones-label]{Tutorial 1}. Colors are the same as in
1089+
Fig.~\ref{fig:LJ}.}
1090+
\label{fig:improved-min}
1091+
\end{figure}
1092+
10951093
By visualizing the system (see Fig.~\ref{fig:improved-min}), you may
10961094
have noticed that some atoms left their original region during
10971095
minimization. To start the simulation from a clean slate, with only
@@ -1135,17 +1133,6 @@ \subsubsection{Improving the script}
11351133
group grp_t2_out delete
11361134
\end{lstlisting}
11371135

1138-
\begin{figure}
1139-
\centering
1140-
\includegraphics[width=\linewidth]{LJ-evolution}
1141-
\caption{Evolution of the system from \hyperref[lennard-jones-label]{Tutorial 1}
1142-
during mixing. The three snapshots show respectively the system
1143-
at $t=0$ (left panel), $t=75$ (middle panel), and $t=1500$ (right panel). The
1144-
atoms of type 1 are represented as small turquoise spheres and the atoms of type 2
1145-
as large blue spheres.}
1146-
\label{fig:evolution-population}
1147-
\end{figure}
1148-
11491136
Let us monitor the number of atoms of each type inside the cylinder as a
11501137
function of time by creating the following equal-style variables:
11511138
\begin{lstlisting}
@@ -1159,8 +1146,8 @@ \subsubsection{Improving the script}
11591146
\begin{note}
11601147
{\color{blue}The \lmpcmd{n1\_in} and \lmpcmd{n2\_in} defined above are
11611148
equal-style variables, which evaluate a numerical expression using the
1162-
\lmpcmd{count()} function. Other common LAMMPS variable types include
1163-
atom-style, index, and loop.}
1149+
\lmpcmd{count()} function. Other LAMMPS variable styles include
1150+
atom, index, file, loop, string, and vector.}
11641151
\end{note}
11651152

11661153
In addition to counting the atoms in each region, we will also extract
@@ -1183,7 +1170,8 @@ \subsubsection{Improving the script}
11831170
first compute is referenced by the second, and we reference the second
11841171
in a \lmpcmd{thermo\_style custom} command (see below).
11851172

1186-
\begin{note} {\color{blue} LAMMPS \lmpcmd{compute} commands can produce
1173+
\begin{note}
1174+
{\color{blue} LAMMPS \lmpcmd{compute} commands can produce
11871175
a wide variety of data and one can identify the category from the
11881176
name of the compute style: global data (no suffix), local data
11891177
(/local suffix), per-atom data (/atom suffix), per-chunk data
@@ -1210,6 +1198,17 @@ \subsubsection{Improving the script}
12101198
section, as the settings are taken from the \flecmd{.data} file.
12111199
\end{note}
12121200

1201+
\begin{figure}
1202+
\centering
1203+
\includegraphics[width=\linewidth]{LJ-evolution}
1204+
\caption{Evolution of the system from \hyperref[lennard-jones-label]{Tutorial 1}
1205+
during mixing. The three snapshots show respectively the system
1206+
at $t=0$ (left panel), $t=75$ (middle panel), and $t=1500$ (right panel). The
1207+
atoms of type 1 are represented as small turquoise spheres and the atoms of type 2
1208+
as large blue spheres.}
1209+
\label{fig:evolution-population}
1210+
\end{figure}
1211+
12131212
Finally, let us complete the script by adding the following lines to
12141213
\flecmd{improved.md.lmp}:
12151214
\begin{lstlisting}
@@ -1248,6 +1247,16 @@ \subsubsection{Improving the script}
12481247
important to prevent the system from starting to drift or move as a
12491248
whole.
12501249

1250+
\begin{figure}
1251+
\centering
1252+
\includegraphics[width=\linewidth]{LJ-mixing}\\[-2ex]
1253+
\caption{a)~Evolution of the numbers $N_\text{1, in}$ and $N_\text{2, in}$ of atoms
1254+
of types 1 and 2, respectively, within the \lmpcmd{cyl\_in} region as functions
1255+
of time $t$. b)~Evolution of the coordination number $C_{1-2}$ (compute \lmpcmd{sumcoor12})
1256+
between atoms of types 1 and 2.}
1257+
\label{fig:mixing}
1258+
\end{figure}
1259+
12511260
\begin{note}
12521261
A bulk system with periodic boundary conditions is expected to remain
12531262
in place. Accordingly, when computing the temperature from the
@@ -1258,17 +1267,6 @@ \subsubsection{Improving the script}
12581267
very quickly. This phenomenon is sometimes referred to as the
12591268
``flying ice cube syndrome''~\cite{wong2016good}.
12601269
\end{note}
1261-
1262-
\begin{figure}
1263-
\centering
1264-
\includegraphics[width=\linewidth]{LJ-mixing}
1265-
\caption{a)~Evolution of the numbers $N_\text{1, in}$ and $N_\text{2, in}$ of atoms
1266-
of types 1 and 2, respectively, within the \lmpcmd{cyl\_in} region as functions
1267-
of time $t$. b)~Evolution of the coordination number $C_{1-2}$ (compute \lmpcmd{sumcoor12})
1268-
between atoms of types 1 and 2.}
1269-
\label{fig:mixing}
1270-
\end{figure}
1271-
12721270
Run \flecmd{improved.md.lmp} and observe the mixing of the two populations
12731271
over time (see also Fig.~\ref{fig:evolution-population}). From the
12741272
variables \lmpcmd{n1\_in} and \lmpcmd{n2\_in}, you can track the number
@@ -1299,6 +1297,17 @@ \subsubsection{Improving the script}
12991297
\item Append an NVE run (i.e.~without any thermostat) and observe the energy levels.
13001298
\end{itemize}
13011299

1300+
\begin{figure}
1301+
\centering
1302+
\includegraphics[width=0.50\linewidth]{LJ-coords}
1303+
\caption{Snapshot of the binary mixture simulated
1304+
during \hyperref[lennard-jones-label]{Tutorial 1} with atoms of type 1
1305+
colored according to their computed $1-2$ coordination
1306+
number from the compute \lmpcmd{coor12}, ranging from turquoise,\lmpcmd{c\_coor12 = 0},
1307+
to yellow, \lmpcmd{c\_coor12 = 1}, and red, \lmpcmd{c\_coor12 = 2}.}
1308+
\label{fig:coords-viz}
1309+
\end{figure}
1310+
13021311
\begin{note}
13031312
{\color{blue}
13041313
In contrast to the \lmpcmd{fix nve} command, which integrates Newton's equations
@@ -1317,18 +1326,6 @@ \subsubsection{Improving the script}
13171326
dump_modify viz adiam 1 1 adiam 2 3 backcolor white &
13181327
amap -1 2 ca 0.0 4 min royalblue 0 turquoise 1 yellow max red
13191328
\end{lstlisting}
1320-
1321-
\begin{figure}
1322-
\centering
1323-
\includegraphics[width=0.55\linewidth]{LJ-coords}
1324-
\caption{Snapshot of the binary mixture simulated
1325-
during \hyperref[lennard-jones-label]{Tutorial 1} with atoms of type 1
1326-
colored according to their computed $1-2$ coordination
1327-
number from the compute \lmpcmd{coor12}, ranging from turquoise,\lmpcmd{c\_coor12 = 0},
1328-
to yellow, \lmpcmd{c\_coor12 = 1}, and red, \lmpcmd{c\_coor12 = 2}.}
1329-
\label{fig:coords-viz}
1330-
\end{figure}
1331-
13321329
Run LAMMPS again. Atoms of type 1 are now colored based on the value
13331330
of \lmpcmd{c\_coor12}, which is mapped continuously from turquoise to yellow
13341331
and red for atoms with the highest coordination (Fig.~\ref{fig:coords-viz}).
@@ -1338,16 +1335,24 @@ \subsubsection{Improving the script}
13381335
\subsection{Tutorial 2: Pulling on a carbon nanotube}
13391336
\label{carbon-nanotube-label}
13401337

1338+
\begin{figure}
1339+
\centering
1340+
\includegraphics[width=0.55\linewidth]{CNT}
1341+
\caption{The carbon nanotube (CNT) simulated during
1342+
\hyperref[carbon-nanotube-label]{Tutorial 2}.}
1343+
\label{fig:CNT}
1344+
\end{figure}
1345+
13411346
In this tutorial, the system of interest is a small, single-walled
13421347
carbon nanotube (CNT) in an empty box (Fig.~\ref{fig:CNT}). The CNT is
13431348
strained by imposing a constant velocity on the edge atoms. To
13441349
illustrate the difference between conventional and reactive force
13451350
fields, this tutorial is divided into two parts: in the first part, a
13461351
conventional molecular force field (called
13471352
OPLS-AA~\cite{jorgensenDevelopmentTestingOPLS1996}) is used and the
1348-
{\color{blue}form of the bonded potential ensure that the} bonds between
1349-
the atoms of the CNT are unbreakable. In the second part, a reactive,
1350-
{\color{blue} many-body} force field (called
1353+
{\color{blue}functional form of the bonded potential ensures that the}
1354+
bonds between the atoms of the CNT are unbreakable. In the second part,
1355+
a reactive, {\color{blue} many-body} force field (called
13511356
AIREBO~\cite{stuart2000reactive}) is used, which allows chemical bonds
13521357
to break under large strain.
13531358

@@ -1361,25 +1366,20 @@ \subsection{Tutorial 2: Pulling on a carbon nanotube}
13611366
parameters file named \flecmd{unbreakable.inc}, as well as the scripts
13621367
required for the second part of the tutorial.
13631368

1364-
\begin{figure}
1365-
\centering
1366-
\includegraphics[width=0.55\linewidth]{CNT}
1367-
\caption{The carbon nanotube (CNT) simulated during
1368-
\hyperref[carbon-nanotube-label]{Tutorial 2}.}
1369-
\label{fig:CNT}
1370-
\end{figure}
1371-
13721369
\subsubsection{Unbreakable bonds}
13731370

1374-
With most conventional molecular force fields, the chemical bonds between
1375-
atoms are defined at the start of the simulation and remain fixed, regardless
1376-
of the forces applied to the atoms. {\color{blue}In this tutorial, these bonds
1377-
are explicitly specified in the \lmpcmd{.data} file, which is read using the \lmpcmd{read\_data} command (see below).}
1378-
Bonds are typically modeled as springs
1379-
with equilibrium distances $r_0$ and force constants $k_\text{b}$:
1380-
$U_\text{b} = k_\text{b} \left( r - r_0 \right)^2$. Additionally, angular and
1381-
dihedral constraints are often imposed to preserve the molecular structure
1382-
by maintaining the relative orientations of neighboring atoms.
1371+
With most conventional molecular force fields, the chemical bonds
1372+
between atoms are defined at the start of the simulation and remain
1373+
fixed, regardless of the forces applied to the atoms. {\color{blue}In
1374+
this tutorial, these bonds are explicitly specified in the
1375+
\lmpcmd{.data} file, which is read using the \lmpcmd{read\_data}
1376+
command (see below).}
1377+
Bonds are typically modeled as springs {\color{blue}following Hooke's
1378+
law} with equilibrium distances $r_0$ and force constants $k_\text{b}$:
1379+
$U_\text{b} = k_\text{b} \left( r - r_0 \right)^2$. Additionally,
1380+
angular and dihedral {\color{blue}interactions} are often imposed to
1381+
preserve the molecular structure by maintaining the relative
1382+
orientations of neighboring atoms.
13831383

13841384
\paragraph{The LAMMPS input}
13851385

@@ -1518,10 +1518,11 @@ \subsubsection{Unbreakable bonds}
15181518
and $x > x_\text{max}$ (\lmpcmd{rtop}, for region top).
15191519

15201520
\begin{note}
1521-
{\color{blue}
1522-
So far, variables have been referenced dynamically during the run using
1523-
the \lmpcmd{v\_} prefix, which evaluates the variable as it evolves over time.
1524-
Here, a dollar sign (\$) is used to reference the variable at the time the script is read.}
1521+
{\color{blue} So far, variables have been referenced
1522+
dynamically during the run using the \lmpcmd{v\_} prefix, which
1523+
evaluates the variable as it evolves over time. Here, a dollar sign
1524+
(\$) is used to expand the variable immediately at the time the input
1525+
script is read.}
15251526
\end{note}
15261527

15271528
Finally, let us define 3 groups of atoms corresponding to the atoms
@@ -1585,8 +1586,8 @@ \subsubsection{Unbreakable bonds}
15851586
\end{lstlisting}
15861587
Re-setting the atom IDs is necessary before using the \lmpcmd{velocity} command
15871588
when atoms were deleted, which is done here with the \lmpcmd{reset\_atoms} command.
1588-
The \lmpcmd{velocity} command gives initial velocities to the atoms of the middle
1589-
group \lmpcmd{cnt\_mid}, ensuring an initial temperature of $T = 300\,\text{K}$
1589+
The \lmpcmd{velocity} command {\color{blue}assigns random} initial velocities to the atoms of the middle
1590+
group \lmpcmd{cnt\_mid} {\color{blue} from a uniform distribution}, ensuring an initial temperature of $T = 300\,\text{K}$
15901591
for these atoms.
15911592

15921593
Let us specify the thermalization and the dynamics of the system. Add the following
@@ -1605,10 +1606,10 @@ \subsubsection{Unbreakable bonds}
16051606
\begin{note}
16061607
{\color{blue}The Nosé-Hoover thermostat only controls the temperature of
16071608
the atoms belonging to the specified \lmpcmd{cnt\_mid} group. Atoms outside
1608-
this group are not affected by the thermostat.}
1609+
this group are not affected.}
16091610
\end{note}
16101611

1611-
To restrain the motion of the atoms at the edges, let us add the following
1612+
To {\color{blue}immobilize} the atoms at the edges, let us add the following
16121613
commands to \flecmd{unbreakable.lmp}:
16131614
\begin{lstlisting}
16141615
fix mysf1 cnt_top setforce 0 0 0
@@ -1619,8 +1620,8 @@ \subsubsection{Unbreakable bonds}
16191620
The two \lmpcmd{setforce} commands cancel the forces applied on the atoms of the
16201621
two edges, respectively. The cancellation of the forces is done at every step,
16211622
and along all 3 directions of space, $x$, $y$, and $z$, due to the use of
1622-
\lmpcmd{0 0 0}. {\color{blue}Although the forces on these atoms is set to zero,
1623-
the \lmpcmd{fix} still stores the forces acting on the group before
1623+
\lmpcmd{0 0 0}. {\color{blue}Although the force on these atoms is set to zero,
1624+
the \lmpcmd{fix} stores the force vector acting on the group \emph{before}
16241625
cancellation, which can later be extracted for analysis (see below).}
16251626
The two \lmpcmd{velocity} commands set the initial velocities
16261627
along $x$, $y$, and $z$ to 0 for the atoms of \lmpcmd{cnt\_top} and
@@ -1629,13 +1630,12 @@ \subsubsection{Unbreakable bonds}
16291630
they would if no other command was applied to them).
16301631

16311632
\begin{note}
1632-
The \lmpcmdnote{velocity set}
1633-
command imposes the velocity of a group of atoms at the start of a run but does
1634-
not enforce the velocity during the entire simulation. When \lmpcmdnote{velocity set}
1635-
is used in combination with \lmpcmdnote{setforce 0 0 0}, as is the case here, the
1636-
atoms won't feel any force during the entire simulation. According to the Newton
1637-
equation, no force means no acceleration, meaning that the initial velocity
1638-
will persist during the entire simulation, thus producing a constant velocity motion.
1633+
The \lmpcmdnote{velocity set} command {\color{blue}adjusts} the velocities of
1634+
a group of atoms {\color{blue}immediately} but {\color{blue}has no effect}
1635+
\emph{during} the simulation. When \lmpcmdnote{velocity set} is used
1636+
in combination with \lmpcmdnote{setforce 0 0 0}, as is the case here, the
1637+
initial velocity will persist during the entire simulation, thus producing
1638+
a constant velocity {\color{blue} motion or no motion at all}.
16391639
\end{note}
16401640

16411641
\paragraph{Outputs}
@@ -1775,7 +1775,7 @@ \subsubsection{Breakable bonds}
17751775
\end{lstlisting}
17761776
\begin{note} {\color{blue}The AIREBO force field is a many-body
17771777
potential where interactions are not only between pairs of atoms,
1778-
but also triples and quadruples representing angles and dihedral
1778+
but also triples and quadruples representing angle and dihedral
17791779
interactions. This means, that there are different rules for the
17801780
\lmpcmd{pair\_coeff} command: there must be only one command that
17811781
covers all permutations of atom types by using two '*' wildcards.
@@ -1815,6 +1815,14 @@ \subsubsection{Breakable bonds}
18151815

18161816
\paragraph{Start the simulation}
18171817

1818+
\begin{figure}
1819+
\centering
1820+
\includegraphics[width=\linewidth]{CNT-deformed-breakable}
1821+
\caption{CNT with broken bonds. This image was generated using
1822+
VMD~\cite{vmd_home,humphrey1996vmd} with the \guicmd{DynamicBonds} representation.}
1823+
\label{fig:CNT-deformed-breakable}
1824+
\end{figure}
1825+
18181826
Here, let us perform a similar deformation as the previous one.
18191827
In \lmpcmd{breakable.lmp}, replace the \lmpcmd{run 0 post no} line with:
18201828
\begin{lstlisting}
@@ -1868,14 +1876,6 @@ \subsubsection{Breakable bonds}
18681876
Run the simulation. Some bonds are expected to break before the end of the
18691877
simulation (Fig.~\ref{fig:CNT-deformed-breakable}).
18701878

1871-
\begin{figure}
1872-
\centering
1873-
\includegraphics[width=\linewidth]{CNT-deformed-breakable}
1874-
\caption{CNT with broken bonds. This image was generated using
1875-
VMD~\cite{vmd_home,humphrey1996vmd} with the \guicmd{DynamicBonds} representation.}
1876-
\label{fig:CNT-deformed-breakable}
1877-
\end{figure}
1878-
18791879
Looking at the evolution of the energy, one can see that the total
18801880
energy $E$ is initially increasing with the deformation. When bonds
18811881
break, the energy relaxes abruptly, as can be seen near $t=32~\text{ps}$

0 commit comments

Comments
 (0)