Skip to content

Commit 6d9d7e4

Browse files
committed
review first part of tutorial 1
1 parent 9f24794 commit 6d9d7e4

1 file changed

Lines changed: 64 additions & 74 deletions

File tree

lammps-tutorials.tex

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ \subsection{Software/system requirements}
348348
Choose a package with `GUI' in the file name (it will contain
349349
LAMMPS--GUI and a LAMMPS executable for the console). These
350350
pre--compiled packages aim to be portable and therefore omit support for
351-
running in parallel with MPI. \hyperref[using-lammps-gui]{Appendix
351+
running in parallel with MPI. \hyperref[using-lammps-gui-label]{Appendix
352352
\ref{using-lammps-gui-label}} has instructions for installing
353353
LAMMPS--GUI and using its most relevant features for the
354354
tutorials.
@@ -407,7 +407,7 @@ \subsection{About LAMMPS--GUI}
407407
\item Wizard dialogs to set up these tutorials
408408
\end{itemize}
409409

410-
\hyperref[using-lammps-gui]{Appendix \ref{using-lammps-gui-label}}
410+
\hyperref[using-lammps-gui-label]{Appendix \ref{using-lammps-gui-label}}
411411
contains basic instructions for installation and using LAMMPS--GUI with
412412
the tutorials presented here. A complete description of all LAMMPS--GUI
413413
features is in the LAMMPS manual \cite{lammps_gui_docs}.
@@ -559,14 +559,13 @@ \subsubsection{My first input}
559559
use the \lmpcmd{lattice} command and the default lattice spacing is 1.0
560560
in x-, y-, or z-direction.
561561

562-
The second line, \lmpcmd{create\_box 2 simbox}, creates a
563-
simulation box based on the region \lmpcmd{simbox} with two
564-
types of atoms. From this point on, any command referencing an atom
565-
type larger than \textit{2} will trigger an error. You may specify more
566-
atom types than what are necessary, but for each atom type you must set
567-
the mass and provide force field parameters for all of them. Not doing
568-
so will cause LAMMPS to abort with an error at the beginning of a
569-
minimization or an MD run.
562+
The second line, \lmpcmd{create\_box 2 simbox}, creates a simulation box
563+
based on the region \lmpcmd{simbox} with two types of atoms. From this
564+
point on, any command referencing an atom type larger than \textit{2}
565+
will trigger an error. You may specify more atom types than what are
566+
necessary, but for each atom type you must set the mass and provide
567+
force field parameters. Not doing so will cause LAMMPS to abort with an
568+
error at the beginning of a minimization or an MD run.
570569

571570
The third line, \lmpcmd{create\_atoms (\dots)}, creates 1500 atoms of type
572571
\textit{1} at random positions within the region
@@ -586,13 +585,13 @@ \subsubsection{My first input}
586585
\begin{lstlisting}
587586
# 3) Settings
588587
mass 1 1.0
589-
mass 2 10.0
588+
mass 2 5.0
590589
pair_style lj/cut 4.0
591590
pair_coeff 1 1 1.0 1.0
592591
pair_coeff 2 2 0.5 3.0
593592
\end{lstlisting}
594593

595-
The two \lmpcmd{mass} commands assign a mass of 1.0 and 10.0 mass units
594+
The two \lmpcmd{mass} commands assign a mass of 1.0 and 5.0 mass units
596595
to the atoms of type 1 and 2, respectively.
597596

598597
The third line, \lmpcmd{pair\_style lj/cut 4.0}, requests that the atoms
@@ -605,14 +604,7 @@ \subsubsection{My first input}
605604
the depth of the potential well that sets the interaction strength, and
606605
$\sigma_{ij}$ represents the distance where the potential energy of the
607606
LJ potential is zero. Here, the indexes \textit{ij} refer to pairs of
608-
particle types \textit{i} and \textit{j}. Sometimes the LJ potential is
609-
formulated using the minimum of the potential
610-
$\bar{\sigma} = 2^{\frac{1}{6}}\sigma$:
611-
$$E_{ij} (r) = \epsilon_{ij} \left[ \left( \dfrac{\bar{\sigma}_{ij}}{r} \right)^{12}
612-
- 2\left( \dfrac{\bar{\sigma}_{ij}}{r} \right)^{6} \right], ~
613-
\text{for} ~ r < r_c.$$
614-
This is the \emph{same} potential, only the $\sigma$ parameters must
615-
be converted through dividing by $2^{\frac{1}{6}}$.
607+
particle types \textit{i} and \textit{j}.
616608

617609
The fourth line, \lmpcmd{pair\_coeff 1 1 1.0 1.0}, sets the
618610
Lennard-Jones coefficients for the interactions between pairs of atoms
@@ -628,6 +620,15 @@ \subsubsection{My first input}
628620
$\sigma_{12} = \sqrt{1.0 \times 3.0} = 1.732$.
629621

630622
\paragraph{Single point energy}
623+
\begin{figure}
624+
\centering
625+
\includegraphics[width=0.55\linewidth]{LJ}
626+
\caption{The binary mixture simulated during \hyperref[lennard-jones-label]{Tutorial 1}.
627+
The atoms of type 1 are represented as small red spheres, the atoms of type 2 as large
628+
green spheres, and the edges of the simulation box are represented a blue sticks}
629+
\label{fig:LJ}
630+
\end{figure}
631+
631632
The system is now fully parameterized and the input ready to compute
632633
forces. Let us fill in the two last remaining categories,
633634
\textit{Visualization}, and \textit{Run}, by adding the following lines
@@ -636,18 +637,19 @@ \subsubsection{My first input}
636637
# 4) Visualization
637638
thermo 10
638639
thermo_style custom step etotal press
639-
640640
# 5) Run
641641
run 0 post no
642642
\end{lstlisting}
643643

644-
The \textit{thermo} command asks LAMMPS to print thermodynamic
644+
The \lmpcmd{thermo 10} command asks LAMMPS to print thermodynamic
645645
information to the console every given number of steps, in this case,
646-
every 10 simulation steps. The \textit{thermo\_style custom} command specifies
647-
\emph{which} output LAMMPS should print. This selection prints the
648-
step number (\textit{step}), the total energy (\textit{etotal}), and the
649-
pressure (\textit{press}). The \textit{run 0} command instructs LAMMPS
650-
to perform only force and energy initialization.
646+
every 10 simulation steps. The \lmpcmd{thermo\_style custom} command
647+
specifies \emph{which} output LAMMPS should print. This selection
648+
prints the step number (\textit{step}), the total energy
649+
(\textit{etotal}), and the pressure (\textit{press}). The \lmpcmd{run
650+
0 post no} command instructs LAMMPS to perform only force and energy
651+
initialization and the \lmpcmd{post no} option disables the post-run
652+
summary and statistics output.
651653

652654
You can now run LAMMPS. It should finish quickly and with the default
653655
settings, LAMMPS--GUI will open two new windows, one with the console
@@ -657,61 +659,52 @@ \subsubsection{My first input}
657659
data. Since no real simulation steps have been performed, the charts
658660
are empty.
659661

660-
\begin{figure}
661-
\centering
662-
\includegraphics[width=0.55\linewidth]{LJ}
663-
\caption{The binary mixture simulated during \hyperref[lennard-jones-label]{Tutorial 1}.
664-
The atoms of type 1 are represented as small red spheres, the atoms of type 2 as large
665-
green spheres, and the edges of the simulation box are represented a blue sticks}
666-
\label{fig:LJ}
667-
\end{figure}
668-
669662
\paragraph{Snapshot Image}
670663

671-
At this point it is also possible to create a snapshot image of the
664+
At this point it is possible to create a snapshot image of the
672665
current system using the \textit{Image Viewer} window. The image viewer
673666
works by telling LAMMPS to render an image of the current system using
674-
its own render library through the \textit{dump image} command. The
667+
its own render library through the \lmpcmd{dump image} command. The
675668
resulting image is read in and displayed. The various buttons can be
676669
used to change what is shown and how it is rendered. The image of
677670
figure \ref{fig:LJ} was created this way. This will always create an
678671
image of the currently active state of the system. Save the image for
679672
later comparisons.
680673

681674
\paragraph{Energy minimization}
682-
Now replace the \textit{run} command with the \textit{minimize} command
675+
Now replace the \lmpcmd{run} command line with a \lmpcmd{minimize} command
683676
as shown below.
684677
\begin{lstlisting}
685678
# 5) Run
686679
minimize 1.0e-6 1.0e-6 1000 10000
687680
\end{lstlisting}
688681

689-
\begin{figure}
690-
\centering
691-
\includegraphics[width=0.45\linewidth]{chart-1}
692-
\includegraphics[width=0.45\linewidth]{output-1}
693-
\caption{\textit{Chart} (left) and \textit{Output} (right) window of LAMMPS-GUI after performing
694-
the minimization simulation of \hyperref[lennard-jones-label]{Tutorial 1}.}
695-
\label{fig:chart-log}
696-
\end{figure}
697-
698682
This tells LAMMPS to perform an energy minimization of the system. That
699683
is, LAMMPS will compute the forces on all atoms and then update the
700684
positions according to a selected algorithm so that the potential energy
701685
will decrease. By default, LAMMPS uses the conjugate gradient (CG)
702686
algorithm \cite{hestenes1952methods}. The simulation will stop as soon
703687
as the minimizer algorithm cannot find a way to lower the potential
704-
energy. Except for trivial systems, minimization algorithms will find
705-
a local minimum rather than the global minimum.
688+
energy. Except for trivial systems, minimization algorithms will find a
689+
local minimum rather than the global minimum.
706690

707691
Run the minimization and observe that LAMMPS-GUI will capture the output
708-
and update the chart in real-time. This run executes quickly (depending on
709-
your computer's capability) and may fail to
710-
capture some of the thermodynamic data (see figure \ref{fig:chart-log}).
711-
In that case, use the \textit{Preferences} dialog to reduce the
712-
GUI update interval and switch to single threaded, unaccelerated
713-
execution in the Accelerators tab. You can repeat the run. Each new run
714-
will start fresh, forgetting the current system and starting over from the top.
692+
and update the chart in real-time. This run executes quickly (depending
693+
on your computer's capability) and LAMMPS--GUI may fail to capture some
694+
of the thermodynamic data (see figure \ref{fig:chart-log}). In that
695+
case, use the \textit{Preferences} dialog to reduce the data update
696+
interval and switch to single threaded, unaccelerated execution in the
697+
Accelerators tab. You can repeat the run. Each new run will start
698+
fresh, forgetting the current system and starting over from the top.
699+
700+
\begin{figure}
701+
\centering
702+
\includegraphics[width=0.45\linewidth]{chart-1}
703+
\includegraphics[width=0.45\linewidth]{output-1}
704+
\caption{\textit{Chart} (left) and \textit{Output} (right) window of LAMMPS-GUI after performing
705+
the minimization simulation of \hyperref[lennard-jones-label]{Tutorial 1}.}
706+
\label{fig:chart-log}
707+
\end{figure}
715708

716709
The potential energy can be seen to decrease from a positive value to a
717710
negative value. The initially positive value of the potential energy is
@@ -727,19 +720,19 @@ \subsubsection{My first input}
727720
minimization and compare the two images. You should see that atoms
728721
are ``clumping together''.
729722

730-
Since the \textit{thermo\_style} command also includes the \textit{press}
723+
Since the \lmpcmd{thermo\_style} command also includes the \textit{press}
731724
keyword, it is possible to switch from plotting the total energy to
732725
showing the pressure by choosing \textit{Press} in \textit{Select data}
733726
drop down menu.
734727

735728
\paragraph{Molecular dynamics}
736729

737-
After the energy minimization, any overlapping atoms have been displaced,
738-
and the system is now ready to perform a molecular dynamics simulation
739-
using the minimized geometry. Since we want to start from the result of
740-
the energy minimization step, we can append commands for the MD simulation
741-
to the same input script, \textit{initial.lmp}. After the
742-
\textit{minimize} command, add the following lines:
730+
After the energy minimization, any overlapping atoms have been
731+
displaced, and the system is now ready to perform a molecular dynamics
732+
simulation using the minimized geometry. Since we want to start from
733+
the result of the energy minimization step, we can append commands for
734+
the MD simulation to the same input script, \textit{initial.lmp}. After
735+
the \textit{minimize} command, add the following lines:
743736
\begin{lstlisting}
744737
# PART B - MOLECULAR DYNAMICS
745738
# 4) Visualization
@@ -750,12 +743,12 @@ \subsubsection{My first input}
750743
Since LAMMPS reads the input from top to bottom and acts on each line
751744
immediately, these lines will be executed \emph{after} the energy
752745
minimization. There is no need to re-initialize or re-define the
753-
system. The \textit{thermo} command is called a second time to change
746+
system. The \lmpcmd{thermo} command is called a second time to change
754747
the previous value of 10 to a value of 50 as soon as \textit{PART B} of
755-
the simulation starts. In addition, a new \textit{thermo\_style}
748+
the simulation starts. In addition, a new \lmpcmd{thermo\_style}
756749
command changes which thermodynamic information to be printed by LAMMPS
757-
during \textit{PART B}. This is done because, during molecular
758-
dynamics, the system will have a non-zero temperature (\textit{temp})
750+
during \textit{PART B}. This is done because during molecular
751+
dynamics the system will have a non-zero temperature (\textit{temp})
759752
and kinetic energy (\textit{ke}) and it is useful to monitor those.
760753
Here, \textit{pe} is the potential energy of the system, such that
761754
\textit{pe + ke = etotal}.
@@ -768,7 +761,7 @@ \subsubsection{My first input}
768761
timestep 0.005
769762
run 10000
770763
\end{lstlisting}
771-
The \textit{fix nve} command is used to update the positions and the
764+
The \lmpcmd{fix nve} command is used to update the positions and the
772765
velocities of the atoms in the group \textit{all} at every step. The
773766
group \textit{all} is a default group that contains every atom. The
774767
last two lines set the value of the \textit{timestep} and the number of
@@ -782,12 +775,9 @@ \subsubsection{My first input}
782775
box and the number of particles and the box volume are constant. We can
783776
see that there is no equilibrium between potential and kinetic energy
784777
yet, as the former is falling while the latter is rising. If you extend
785-
the run for many more steps, the values for both kinetic and
778+
the run for more steps (say 100000), the values for both kinetic and
786779
potential energy will plateau (indicating equilibrium) and the total
787-
energy should fluctuate around some constant value. To achieve the
788-
latter, we have to reduce errors by increasing the cutoff to 5 length
789-
units and reducing the timestep to 0.0025 time units since the choices
790-
of 2.5 and 0.005 are quite aggressive.
780+
energy should fluctuate around some constant value.
791781

792782
Now we change the \textit{Run} section to:
793783
\begin{lstlisting}

0 commit comments

Comments
 (0)