Skip to content

Commit b4748b2

Browse files
committed
further improvement of the .tex
1 parent b26c23c commit b4748b2

2 files changed

Lines changed: 83 additions & 76 deletions

File tree

dependencies/.github

lammps-tutorials.tex

Lines changed: 82 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
\definecolor{listing}{rgb}{0.95,0.95,0.95}
6363
\definecolor{command}{rgb}{0.15,0.15,0.15}
6464
\definecolor{download}{rgb}{0.039,0.616,0.851}
65-
\definecolor{note}{rgb}{0.92,0.98,1.00}
65+
%\definecolor{note}{rgb}{0.92,0.98,1.00}
66+
\definecolor{note}{rgb}{1,0.988,0.93}
67+
\definecolor{note_listing}{rgb}{0.94,0.925,0.86}
6668

6769
\lstset{
6870
basicstyle=\small\color{command}, % Use default font + small size and command color
@@ -88,9 +90,13 @@
8890
bottom=5pt, % Extra bottom padding
8991
}
9092

93+
\renewcommand{\floatpagefraction}{0.8} % At least 80% of a page must be used by floats
94+
\renewcommand{\textfraction}{0.1} % At least 10% of a page must contain text
95+
9196
% \renewcommand{\emph}[1]{\underline{#1}} % make \emph{} use underline instead of italic
9297
% S.G.: I went back to italic since all the other italic commands were replaced
9398
\newcommand{\lmpcmd}[1]{\hspace{0pt}\colorbox{listing}{\textcolor{command}{\small{#1}}}\hspace{0pt}} % lammps command
99+
\newcommand{\lmpcmdnote}[1]{\hspace{0pt}\colorbox{note_listing}{\textcolor{command}{\small{#1}}}\hspace{0pt}} % lammps command inside note
94100
\newcommand{\flrcmd}[1]{\textcolor{command}{\texttt{#1}}} % folder in monopace
95101
\newcommand{\flecmd}[1]{\textcolor{command}{\texttt{#1}}} % files name in monopace
96102
%\newcommand{\guicmd}[1]{\textcolor{command}{\texttt{\enquote{#1}}}} % LAMMPS-GUI commands in quotation monopace
@@ -933,17 +939,16 @@ \subsubsection{Improving the script}
933939
determines which per-atom data is set and stored internally in LAMMPS.
934940

935941
\begin{note}
936-
Instead of the \lmpcmd{write\_data} command, you can also use the
937-
command \lmpcmd{write\_restart improve.min.restart} to save the state
938-
of the simulation to a binary restart file. Binary restart files are
939-
more compact, faster to write, contain more information and thus are
940-
often more convenient to use. For example, the choice of atom style
941-
or pair style is recorded, so those commands do not need to be issued
942-
before reading the restart. However, restart files are not expected to be
943-
portable across LAMMPS versions or platforms. Thus, in this tutorial,
944-
we use \lmpcmd{write\_data} so we can provide you with a reference
945-
copy of the data file in the solutions that will work for you,
946-
regardless of your LAMMPS version or platform.
942+
Instead of the \lmpcmdnote{write\_data} command, you can also use the
943+
\lmpcmdnote{write\_restart} command to save the state
944+
of the simulation to a binary restart file. Binary restart files are
945+
more compact, faster to write, and contain more information, making them often
946+
more convenient to use. For example, the choice of \lmpcmdnote{atom\_style}
947+
or \lmpcmdnote{pair\_style} is recorded, so those commands do not need to be issued
948+
before reading the restart. Note however that restart files are not expected to be
949+
portable across LAMMPS versions or platforms. Therefore, in these tutorials,
950+
and with the exception of \hyperref[all-atom-label]{Tutorial 3}, we primarily use \lmpcmdnote{write\_data} to provide you with a reference
951+
copy of the data file that works regardless of your LAMMPS version and platform.
947952
\end{note}
948953

949954
\paragraph{Restarting from a saved configuration}
@@ -1427,10 +1432,10 @@ \subsubsection{Unbreakable bonds}
14271432
they would if no other command was applied to them).
14281433

14291434
\begin{note}
1430-
The \lmpcmd{velocity set}
1435+
The \lmpcmdnote{velocity set}
14311436
commands impose the velocity of a group of atoms at the start of a run but do
1432-
not enforce the velocity during the entire simulation. When \lmpcmd{velocity set}
1433-
is used in combination with \lmpcmd{setforce 0 0 0}, as is the case here, the
1437+
not enforce the velocity during the entire simulation. When \lmpcmdnote{velocity set}
1438+
is used in combination with \lmpcmdnote{setforce 0 0 0}, as is the case here, the
14341439
atoms won't feel any force during the entire simulation. According to the Newton
14351440
equation, no force means no acceleration, meaning that the initial velocity
14361441
will persist during the entire simulation, thus producing a constant velocity motion.
@@ -1571,8 +1576,8 @@ \subsubsection{Breakable bonds}
15711576
to \lmpcmd{breakable.lmp}.
15721577

15731578
\begin{note}
1574-
With the \lmpcmd{metal} units system, times are in picoseconds ($10^{-12}$\,s)
1575-
instead of femtoseconds ($10^{-15}$\,s) in the case of the \lmpcmd{real} units system.
1579+
With the \lmpcmdnote{metal} units system, times are in picoseconds ($10^{-12}$\,s)
1580+
instead of femtoseconds ($10^{-15}$\,s) in the case of the \lmpcmdnote{real} units system.
15761581
It is important to keep this in mind when setting parameters that are expressed
15771582
in time unit, such as the timestep or the time constant of the thermostat.
15781583
\end{note}
@@ -1623,9 +1628,10 @@ \subsubsection{Breakable bonds}
16231628
but that after a few steps, it reaches the target value.
16241629

16251630
\begin{note}
1626-
Bonds cannot be displayed by the \lmpcmd{dump image} when using
1627-
the \lmpcmd{atom\_style atomic}, as it contains no bonds. A tip for displaying bonds
1628-
with the present system is provided at the end of the tutorial.
1631+
Bonds cannot be displayed by the \lmpcmdnote{dump image} when using
1632+
the \lmpcmdnote{atom\_style atomic}, as it contains no bonds.
1633+
A tip for displaying bonds with the present system is provided at
1634+
the end of the tutorial.
16291635
\end{note}
16301636

16311637
\paragraph{Launch the deformation}
@@ -1765,9 +1771,7 @@ \subsubsection{Preparing the water reservoir}
17651771
\begin{note}
17661772
This tutorial uses type labels \cite{typelabel_paper} to map each of the
17671773
numeric atom types with a string (see the \flecmd{parameters.inc} file):
1768-
\begin{lstlisting}
1769-
labelmap atom 1 OE 2 C 3 HC 4 H 5 CPos 6 OAlc 7 OW 8 HW
1770-
\end{lstlisting}
1774+
\lmpcmdnote{labelmap atom 1 OE 2 C 3 HC 4 H 5 CPos 6 OAlc 7 OW 8 HW}
17711775
Therefore, the oxygen and hydrogen atoms of water (respectively types 7 and 8)
17721776
can be referred to as `OW' and `HW', respectively. Similar maps are used for
17731777
the bond types, angle types, and dihedral types.
@@ -1799,83 +1803,86 @@ \subsubsection{Preparing the water reservoir}
17991803
atoms, or the IDs of the atoms that are connected by bonds and angles.
18001804

18011805
Then, let us organize the atoms of types OW and HW of the water molecules in a
1802-
group named \textit{H2O} and perform a small energy minimization. The energy
1803-
minimization is mandatory here given the small \textit{overlap} value of 1 Ångstrom
1804-
chosen in the \textit{create\_atoms} command. Add the following lines into \flecmd{input.lmp}:
1806+
group named \lmpcmd{H2O} and perform a small energy minimization. The energy
1807+
minimization is mandatory here because of the small \lmpcmd{overlap} value
1808+
of 1~Ångstrom chosen in the \lmpcmd{create\_atoms} command. Add the following lines into \flecmd{water.lmp}:
18051809
\begin{lstlisting}
1806-
group H2O type OW HW
1807-
minimize 1.0e-4 1.0e-6 100 1000
1808-
reset_timestep 0
1809-
\end{lstlisting}
1810-
In general, resetting the step of the simulation to 0 using the
1811-
\textit{reset\_timestep} command is optional.
1812-
It is used here because the number of iterations performed by the \textit{minimize}
1813-
command is usually not a round number (since the minimization stops when one of
1814-
four criteria is reached). Let us use the \textit{fix npt} to control the temperature
1815-
of the molecules with a Nosé-Hoover thermostat and the pressure of the system with
1816-
a Nosé-Hoover barostat \cite{nose1984unified, hoover1985canonical, martyna1994constant},
1817-
by adding the following line into \flecmd{input.lmp}:
1818-
\begin{lstlisting}
1819-
fix mynpt all npt temp 300 300 100 &
1820-
iso 1 1 1000
1821-
\end{lstlisting}
1822-
The \textit{fix npt} allows us to impose both a temperature of $300\,\text{K}$
1810+
group H2O type OW HW
1811+
minimize 1.0e-4 1.0e-6 100 1000
1812+
reset_timestep 0
1813+
\end{lstlisting}
1814+
Resetting the step of the simulation to 0 using the
1815+
\lmpcmd{reset\_timestep} command is optional.
1816+
It is used here because the number of iterations performed by the \lmpcmd{minimize}
1817+
command is usually not a round number, since the minimization stops when one of
1818+
four criteria is reached. We will use \lmpcmd{fix npt} to control the temperature
1819+
and pressure of the molecules with a Nosé-Hoover thermostat and barostat,
1820+
respectively \cite{nose1984unified, hoover1985canonical, martyna1994constant}.
1821+
Add the following line into \flecmd{water.lmp}:
1822+
\begin{lstlisting}
1823+
fix mynpt all npt temp 300 300 100 iso 1 1 1000
1824+
\end{lstlisting}
1825+
The \lmpcmd{fix npt} allows us to impose both a temperature of $300\,\text{K}$
18231826
(with a damping constant of $100\,\text{fs}$), and a pressure of 1 atmosphere
1824-
(with a damping constant of $1000\,\text{fs}$). With the \textit{iso} keyword,
1827+
(with a damping constant of $1000\,\text{fs}$). With the \lmpcmd{iso} keyword,
18251828
the three dimensions of the box will be re-scaled simultaneously.
18261829

1827-
Let us output the system into images by adding the following commands to \flecmd{input.lmp}:
1830+
Let us output the system into images by adding the following commands to \flecmd{water.lmp}:
18281831
\begin{lstlisting}
1829-
dump mydmp all image 1000 dump.*.ppm type &
1830-
type shiny 0.1 box no 0.01 &
1831-
view 0 90 zoom 1.8
1832-
dump_modify mydmp backcolor white &
1833-
acolor OW red acolor HW white &
1834-
adiam OW 3 adiam HW 1.5
1832+
dump viz all image 250 myimage-*.ppm type type &
1833+
shiny 0.1 box no 0.01 view 0 90 zoom 3 size 1000 500
1834+
dump_modify viz backcolor white &
1835+
acolor OW red acolor HW white &
1836+
adiam OW 3 adiam HW 1.5
18351837
\end{lstlisting}
1836-
Let us also extract the volume and density in the terminal every 1000 steps:
1838+
Let us also extract the volume and density every 500 steps:
18371839
\begin{lstlisting}
1838-
variable myvol equal vol
1839-
variable myoxy equal count(H2O)/3
1840-
variable myrho equal ${myoxy}/v_myvol
1841-
thermo 1000
1842-
thermo_style custom step temp etotal &
1843-
v_myvol v_myrho
1840+
variable myvol equal vol
1841+
variable myoxy equal count(H2O)/3
1842+
variable rho equal ${myoxy}/v_myvol
1843+
thermo 500
1844+
thermo_style custom step temp etotal v_myvol v_rho
18441845
\end{lstlisting}
1845-
The variable \textit{myoxy} corresponds to the number of atoms divided by 3, i.e.
1846-
the number of molecules, and the variable \textit{myrho} is the number of molecules
1847-
divided by the volume of the simulation box, i.e.~the density (in $\mathrm{\AA{}}^{-3}$).
1846+
The variable \lmpcmd{myoxy} represents the number of atoms divided by 3, which
1847+
corresponds to the number of molecules, and the variable \lmpcmd{myrho} is
1848+
the number of molecules divided by the volume of the simulation box,
1849+
that is, the density (in $\mathrm{\AA{}}^{-3}$).
18481850

1849-
Finally, let us set the timestep to 1.0 fs, and run the simulation for 20 ps by
1850-
adding the following lines into \flecmd{input.lmp}:
1851+
Finally, let us set the timestep to 1.0 fs, and run the simulation for 10 ps by
1852+
adding the following lines into \flecmd{water.lmp}:
18511853
\begin{lstlisting}
1852-
timestep 1.0
1853-
run 20000
1854+
timestep 1.0
1855+
run 10000
18541856

1855-
write_data H2O.data
1857+
write_restart water.restart
18561858
\end{lstlisting}
1857-
% S.G. may be a binary restart file could be used here to illustrate the new functionalities of the GUI?
1858-
The final state is written into \flecmd{H2O.data}. From the value of \textit{myrho},
1859-
it should be clear that the system is quickly reaching its equilibrium
1860-
density (see a snapshot of the equilibrated system in Fig.\,\ref{fig:PEG-water},
1861-
and the evolution of the density in Fig.\,\ref{fig:PEG-density}).
1859+
The final state is written into a binary file named \flecmd{water.restart}.
1860+
Run the input using LAMMPS. From the value of \lmpcmd{myrho}, it is clear that the system is quickly reaching its equilibrium density (see a snapshot of the equilibrated
1861+
system in Fig.\,\ref{fig:PEG-water}, and the evolution of the density
1862+
in Fig.\,\ref{fig:PEG-density}).
18621863

18631864
\begin{figure}
18641865
\centering
18651866
\includegraphics[width=\linewidth]{PEG-water}
1866-
\caption{Water reservoir after equilibration. Oxygen atoms are in red, and hydrogen
1867-
atoms are in white.}
1867+
\caption{The water reservoir from \hyperref[all-atom-label]{Tutorial 3}
1868+
after equilibration. Oxygen atoms are in red, and hydrogen atoms are in white.}
18681869
\label{fig:PEG-water}
18691870
\end{figure}
18701871

18711872
\begin{figure}
18721873
\centering
18731874
\includegraphics[width=\linewidth]{PEG-density}
1874-
\caption{Evolution of the density $\rho$ of water with time $t$. The density
1875-
quickly reaches a plateau.}
1875+
\caption{Evolution of the density $\rho$ of water with time $t$ during
1876+
\hyperref[all-atom-label]{Tutorial 3}.}
18761877
\label{fig:PEG-density}
18771878
\end{figure}
18781879

1880+
\begin{note}
1881+
The binary file created by the \lmpcmdnote{write\_restart} command contains the
1882+
complete state of the simulation, including atomic positions, velocities, and box dimensions (similar to \lmpcmdnote{write\_data}), but also the groups,
1883+
the compute, or the \lmpcmdnote{atom\_style}. Use the \guicmd{Inspect Restart} option of the LAMMPS-GUI to vizualize the content saved in \flecmd{water.restart}.
1884+
\end{note}
1885+
18791886
\subsubsection{Solvating the PEG in water}
18801887
Now that the water reservoir is equilibrated, we can safely include the PEG polymer
18811888
in the water. The PEG molecule topology was downloaded from the ATB repository

0 commit comments

Comments
 (0)