Skip to content

Commit 057856e

Browse files
committed
clean tutorial 1, read avatar
1 parent fb3f95e commit 057856e

File tree

6 files changed

+506
-408
lines changed

6 files changed

+506
-408
lines changed

figures/LJ-avatar.png

474 KB
Loading

figures/LJ-energy.png

3.21 KB
Loading

files/tutorial1/solution/initial.ipynb

Lines changed: 9 additions & 23 deletions
Large diffs are not rendered by default.

files/tutorial1/solution/initial.lmp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ dump_modify viz pad 9 boxcolor darkblue backcolor white adiam 1 1.6 adiam 2 4.8
3232
fix mynve all nve
3333
fix mylgv all langevin 1.0 1.0 0.1 1530917
3434
timestep 0.005
35-
run 10000
35+
run 15000

files/tutorial1/solution/initial.log

Lines changed: 437 additions & 337 deletions
Large diffs are not rendered by default.

lammps-tutorials.tex

Lines changed: 59 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,19 @@ \subsection{Tutorial 1: Lennard-Jones fluid}
434434
The objective of this tutorial is to perform a simple MD simulation
435435
using LAMMPS. The system consists of a Lennard-Jones fluid composed of neutral
436436
particles with two different effective diameters, contained within a
437-
cubic box with periodic boundary conditions (Fig.~\ref{fig:LJ}). In
437+
cubic box with periodic boundary conditions (Fig.~\ref{fig:LJ-avarar}). In
438438
this tutorial, the temperature of the system is maintained using a
439439
Langevin thermostat~\cite{schneider1978molecular}, and basic quantities,
440440
including potential and kinetic energies, are calculated from the simulation.
441441

442+
\begin{figure}
443+
\centering
444+
\includegraphics[width=0.55\linewidth]{LJ-avatar}
445+
\caption{The binary mixture simulated in \hyperref[lennard-jones-label]{Tutorial 1},
446+
with the small atoms of type 1 in green and large atoms of type 2 in blue.}
447+
\label{fig:LJ-avatar}
448+
\end{figure}
449+
442450
\subsubsection{My first input}
443451

444452
To run a simulation using LAMMPS, you need to write an input script containing
@@ -616,8 +624,9 @@ \subsubsection{My first input}
616624
\begin{figure}
617625
\centering
618626
\includegraphics[width=0.55\linewidth]{LJ}
619-
\caption{The binary mixture simulated during \hyperref[lennard-jones-label]{Tutorial 1}.
620-
The atoms of type 1 are represented as small red spheres, the atoms of type 2 as large
627+
\caption{The binary mixture simulated in \hyperref[lennard-jones-label]{Tutorial 1}.
628+
This image was generated directly from the LAMMPS--GUI. Atoms of
629+
type 1 are represented as small red spheres, atoms of type 2 as large
621630
green spheres, and the edges of the simulation box are represented as blue sticks.}
622631
\label{fig:LJ}
623632
\end{figure}
@@ -726,69 +735,73 @@ \subsubsection{My first input}
726735

727736
\paragraph{Molecular dynamics}
728737

729-
After the energy minimization, any overlapping atoms have been
730-
displaced, and the system is now ready to perform a molecular dynamics
731-
simulation using the minimized geometry. Since we want to start from
732-
the result of the energy minimization step, we can append commands for
733-
the MD simulation to the same input script, \flecmd{initial.lmp}. After
734-
the \lmpcmd{minimize} command, add the following lines:
738+
After energy minimization, any overlapping atoms are displaced, and
739+
the system is ready for a molecular dynamics simulation. To continue
740+
from the result of the minimization step, append the MD simulation
741+
commands to the same input script, \flecmd{initial.lmp}. Add the
742+
following lines immediately after the \lmpcmd{minimize} command:
735743
\begin{lstlisting}
736744
# PART B - MOLECULAR DYNAMICS
737745
# 4) Visualization
738746
thermo 50
739747
thermo_style custom step temp etotal pe ke press
740748
\end{lstlisting}
741749

742-
Since LAMMPS reads the input from top to bottom and acts on each line
743-
immediately, these lines will be executed \emph{after} the energy
744-
minimization. There is no need to re-initialize or re-define the
745-
system. The \lmpcmd{thermo} command is called a second time to change
746-
the previous value of 10 to a value of 50 as soon as \textit{PART B} of
750+
Since LAMMPS reads inputs from top to bottom, these lines will
751+
be executed \emph{after} the energy minimization. Therefore,
752+
there is no need to re-initialize or re-define the
753+
system. The \lmpcmd{thermo} command is called a second time to
754+
update the output frequency from 10 to 50 as soon as \lmpcmd{PART B} of
747755
the simulation starts. In addition, a new \lmpcmd{thermo\_style}
748-
command changes which thermodynamic information is to be printed by LAMMPS
749-
during \textit{PART B}. This is done because during molecular
750-
dynamics, the system will have a non-zero temperature (\textit{temp})
751-
and kinetic energy (\textit{ke}) and it is useful to monitor those.
752-
Here, \textit{pe} is the potential energy of the system, such that
753-
\textit{pe + ke = etotal}.
756+
command is introduced to specify the thermodynamic information LAMMPS should
757+
print during during \lmpcmd{PART B}. This adjustment is done because during molecular
758+
dynamics, the system exhibits non-zero temperature (\lmpcmd{temp})
759+
and kinetic energy (\lmpcmd{ke}), which are useful to monitor.
760+
The \lmpcmd{pe} keyword represents the potential energy of the system, such that
761+
\lmpcmd{pe} + \lmpcmd{ke} = \lmpcmd{etotal}.
754762

755-
Then, let us add a second \lmpcmd{Run} category by adding the following
756-
lines to \emph{PART B} of \flecmd{initial.lmp}:
763+
Then, add a second \lmpcmd{Run} category by including the following
764+
lines in \lmpcmd{PART B} of \flecmd{initial.lmp}:
757765
\begin{lstlisting}
758766
# 5) Run
759767
fix mynve all nve
760768
timestep 0.005
761-
run 10000
769+
run 50000
762770
\end{lstlisting}
763-
The \lmpcmd{fix nve} command is used to update the positions and
771+
The \lmpcmd{fix nve} command updates the positions and
764772
velocities of the atoms in the group \lmpcmd{all} at every step. The
765773
group \lmpcmd{all} is a default group that contains every atom. The
766-
last two lines set the value of the \lmpcmd{timestep} and the number of
774+
last two lines specify the value of the \lmpcmd{timestep} and the number of
767775
steps for the \lmpcmd{run}, respectively, corresponding to a total
768-
duration of 50 time units.
776+
duration of 250 time units.
769777

770-
Since there are no other fix commands that change forces or velocities,
771-
and since we have periodic boundary conditions in all directions, the MD
772-
simulation will be performed in the microcanonical or NVE ensemble.
773-
This means the system has no exchange of energy outside the simulation
774-
box and the number of particles and the box volume are constant. We can
775-
see that there is no equilibrium between potential and kinetic energy
776-
yet, as the former is falling while the latter is rising. If you extend
777-
the run for more steps (say 100,000), the values for both kinetic and
778-
potential energy will plateau (indicating equilibrium), and the total
779-
energy should fluctuate around some constant value.
778+
\begin{note}
779+
Since no other fix commands alter forces or velocities,
780+
and periodic boundary conditions are applied in all directions, the MD
781+
simulation will be performed in the microcanonical (NVE) ensemble,
782+
which maintains a constant number of particles and a fixed box volume.
783+
In this ensemble, the system does not exchange energy outside
784+
the simulation box.
785+
\end{note}
786+
787+
Run the simulation using LAMMPS. Initially, there is no equilibrium
788+
between potential and kinetic energy, as the potential energy
789+
decreases while the kinetic energy increases. After approximately
790+
40\,000 steps, the values for both kinetic and potential energy
791+
plateau, indicating that the system has reached equilibrium, with
792+
the total energy fluctuating around a certain constant value.
780793

781-
Now we change the \lmpcmd{Run} section to:
794+
Now, we change the \lmpcmd{Run} section to (note the shorter run time):
782795
\begin{lstlisting}
783796
# 5) Run
784797
fix mynve all nve
785798
fix mylgv all langevin 1.0 1.0 0.1 1530917
786799
timestep 0.005
787-
run 10000
800+
run 15000
788801
\end{lstlisting}
789802
The new command adds a Langevin thermostat to the atoms in the group
790803
\lmpcmd{all}, with a desired target temperature of 1.0 temperature units
791-
throughout the run (the two numbers stand for the target at the beginning
804+
throughout the run (the two numbers represent the target temperature at the beginning
792805
and at the end of the run, which allows for a temperature ramp if
793806
they differ)~\cite{schneider1978molecular}. A \lmpcmd{damping}
794807
parameter of 0.1 is used. The \lmpcmd{damping} parameter determines how
@@ -803,17 +816,17 @@ \subsubsection{My first input}
803816
independent simulations. In the presence of a thermostat, the MD simulation
804817
will be performed in the canonical or NVT ensemble.
805818

806-
Run the simulation again using LAMMPS. From the information
819+
Run the simulation again using LAMMPS. From the information
807820
printed in the \guicmd{Output} window, one can see that the temperature
808821
starts from 0 but rapidly reaches the requested value and
809-
stabilizes itself near $T=1$ temperature units. One can also see that
822+
stabilizes itself near $T=1$ temperature units. One can also observe that
810823
the potential energy, $p_\text{e}$, rapidly decreases during energy
811824
minimization (see also Fig.~\ref{fig:evolution-energy}\,a). After
812825
the molecular dynamics simulation starts, $p_\text{e}$ increases until
813826
it reaches a plateau value of about -0.25. The kinetic energy,
814827
$k_\text{e}$, is equal to zero during energy minimization and then
815-
increases during molecular dynamics until it reaches a plateau value of
816-
about 1.5 (Fig.~\ref{fig:evolution-energy}\,b).
828+
increases rapibly during molecular dynamics until it reaches
829+
a plateau value of about 1.5 (Fig.~\ref{fig:evolution-energy}\,b).
817830

818831
\begin{figure}
819832
\centering
@@ -839,7 +852,6 @@ \subsubsection{My first input}
839852
\guicmd{Copy dump image command} from the \guicmd{File} menu. This text
840853
can be pasted into the into the \lmpcmd{Visualization} section of
841854
\lmpcmd{PART B} of the \flecmd{initial.lmp} file. This may look like the following:
842-
843855
\begin{lstlisting}
844856
dump viz all image 100 myimage-*.ppm type type &
845857
size 800 800 zoom 1.452 shiny 0.7 fsaa yes &
@@ -853,14 +865,14 @@ \subsubsection{My first input}
853865
\lmpcmd{diameter}, respectively. Run the \flecmd{initial.lmp} using
854866
LAMMPS again, and a new window named \guicmd{Slide Show} will pop up.
855867
It will show each image created by the \lmpcmd{dump image} as it is
856-
created and after the simulation is finished (or stopped), the slide
857-
show viewer allows you to animate the trajectory by cycling through the
868+
created. After the simulation is finished (or stopped), the slideshow
869+
viewer allows you to animate the trajectory by cycling through the
858870
images. The window also allows you to export the animation to a movie
859871
(provided the FFMpeg program is installed) and to bulk delete those
860872
image files.
861873

862874
The rendering of the system can be further adjusted using the many
863-
options of the \lmpcmd{dump image} command. The value for the
875+
options of the \lmpcmd{dump image} command. Fir instance, the value for the
864876
\lmpcmd{shiny} keyword is used to adjust the shininess of the atoms, the
865877
\lmpcmd{box} keyword adds or removes a representation of the box, and
866878
the \lmpcmd{view} and \lmpcmd{zoom} keywords adjust the camera (and so

0 commit comments

Comments
 (0)