Skip to content

Commit 3130534

Browse files
committed
continue improving tutorial 2
1 parent 7f31b87 commit 3130534

4 files changed

Lines changed: 105 additions & 55 deletions

File tree

File renamed without changes.

files/tutorial3/pureH2O/input.lmp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
units real
3+
atom_style full
4+
bond_style harmonic
5+
angle_style harmonic
6+
dihedral_style harmonic
7+
pair_style lj/cut/coul/long 10
8+
kspace_style pppm 1e-5
9+
special_bonds lj 0.0 0.0 0.5 &
10+
coul 0.0 0.0 1.0 angle yes
11+
12+
region box block -45 45 -15 15 -15 15
13+
create_box 8 box &
14+
bond/types 7 &
15+
angle/types 8 &
16+
dihedral/types 4 &
17+
extra/bond/per/atom 3 &
18+
extra/angle/per/atom 6 &
19+
extra/dihedral/per/atom 10 &
20+
extra/special/per/atom 14
21+
22+
include ../PARM.lmp
23+
24+
molecule h2omol H2O-SPCFw.mol
25+
create_atoms 0 random 1050 87910 NULL mol &
26+
h2omol 454756 overlap 1.0 maxtry 50
27+
28+
group H2O type OW HW
29+
minimize 1.0e-4 1.0e-6 100 1000
30+
reset_timestep 0
31+
32+
fix mynpt all npt temp 300 300 100 &
33+
iso 1 1 1000
34+
35+
dump mydmp all image 500 dump.*.jpg type type &
36+
shiny 0.1 box no 0.01 view 0 90 zoom 1.8
37+
dump_modify mydmp backcolor white &
38+
acolor OW red acolor HW white &
39+
adiam OW 3 adiam HW 1.5
40+
41+
variable myvol equal vol
42+
variable myoxy equal count(H2O)/3
43+
variable rho equal ${myoxy}/v_myvol
44+
thermo 1000
45+
thermo_style custom step temp etotal v_myvol v_rho
46+
47+
timestep 1.0
48+
run 20000
49+
write_data H2O.data

lammps-tutorials.tex

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ \subsubsection{Preparing the water reservoir}
18561856
\end{verbatim}}
18571857

18581858
Download and save the
1859-
\href{https://raw.githubusercontent.com/lammpstutorials/lammpstutorials-article/main/files/tutorial3/PARM.lmp}{\textit{PARM.lmp}}
1859+
\href{\filepath tutorial3/PARM.lmp}{\textit{PARM.lmp}}
18601860
file next to the \textit{pureH2O/} folder. This example uses type labels, which
18611861
are strings that map to each of the numeric atom types, bond types, angles types,
18621862
etc. in the simulation. Type labels can be any string defined by the user, and we
@@ -1888,7 +1888,7 @@ \subsubsection{Preparing the water reservoir}
18881888
\end{verbatim}}
18891889
When LAMMPS fails to create the desired number of molecules, a WARNING appears
18901890
in the \textit{log} file. The molecule template called
1891-
\href{https://raw.githubusercontent.com/lammpstutorials/lammpstutorials-article/main/files/tutorial3/H2O-SPCFw.mol}{\textit{H2O-SPCFw.mol}}
1891+
\href{\filepath tutorial3/pureH2O/H2O-SPCFw.mol}{\textit{H2O-SPCFw.mol}}
18921892
must be downloaded and saved in the \textit{pureH2O/} folder. This template contains
18931893
the necessary structural information of a water molecule, such as the number of
18941894
atoms, or the IDs of the atoms that are connected by bonds, angles, etc.
@@ -1921,8 +1921,9 @@ \subsubsection{Preparing the water reservoir}
19211921

19221922
Let us output the system into images by adding the following commands to \textit{input.lmp}:
19231923
{\normalsize \begin{verbatim}
1924-
dump mydmp all image 1000 dump.*.ppn type type &
1925-
shiny 0.1 box no 0.01 view 0 90 zoom 1.8
1924+
dump mydmp all image 1000 dump.*.ppn type &
1925+
type shiny 0.1 box no 0.01 &
1926+
view 0 90 zoom 1.8
19261927
dump_modify mydmp backcolor white &
19271928
acolor OW red acolor HW white &
19281929
adiam OW 3 adiam HW 1.5
@@ -1933,7 +1934,8 @@ \subsubsection{Preparing the water reservoir}
19331934
variable myoxy equal count(H2O)/3
19341935
variable myrho equal ${myoxy}/v_myvol
19351936
thermo 1000
1936-
thermo_style custom step temp etotal v_myvol v_myrho
1937+
thermo_style custom step temp etotal &
1938+
v_myvol v_myrho
19371939
\end{verbatim}}
19381940
The variable \textit{myoxy} corresponds to the number of atoms divided by 3, i.e.
19391941
the number of molecules, and the variable \textit{myrho} is the number of molecules
@@ -1964,8 +1966,8 @@ \subsubsection{Preparing the water reservoir}
19641966
\begin{figure}
19651967
\centering
19661968
\includegraphics[width=\linewidth]{PEG-density}
1967-
\caption{Evolution of the density $\rho$ of water with time $t$. The density $\rho$
1968-
reaches a plateau after $t \approx 10\,\text{ps}$.}
1969+
\caption{Evolution of the density $\rho$ of water with time $t$. The density
1970+
quickly reaches a plateau.}
19691971
\label{fig:PEG-density}
19701972
\end{figure}
19711973

@@ -1988,81 +1990,80 @@ \subsubsection{Solvating the PEG in water}
19881990
Create a new blank file in it, call it \textit{input.lmp}. Within \textit{input.lmp},
19891991
copy the same first lines as previously:
19901992
{\normalsize \begin{verbatim}
1991-
units real
1992-
atom_style full
1993-
bond_style harmonic
1994-
angle_style harmonic
1995-
dihedral_style harmonic
1996-
pair_style lj/cut/coul/long 10
1997-
kspace_style pppm 1e-5
1998-
special_bonds lj 0.0 0.0 0.5 coul 0.0 0.0 1.0 &
1999-
angle yes dihedral yes
1993+
units real
1994+
atom_style full
1995+
bond_style harmonic
1996+
angle_style harmonic
1997+
dihedral_style harmonic
1998+
pair_style lj/cut/coul/long 10
1999+
kspace_style pppm 1e-5
2000+
special_bonds lj 0.0 0.0 0.5 coul 0.0 0.0 1.0 &
2001+
angle yes dihedral yes
20002002
\end{verbatim}}
20012003
Then, import the previously generated data file \textit{H2O.data} as well as the \textit{PARM.lmp} file:
20022004
{\normalsize \begin{verbatim}
2003-
read_data ../pureH2O/H2O.data &
2004-
extra/bond/per/atom 3 &
2005-
extra/angle/per/atom 6 &
2006-
extra/dihedral/per/atom 10 &
2007-
extra/special/per/atom 14
2008-
include ../PARM.lmp
2005+
read_data ../pureH2O/H2O.data &
2006+
extra/bond/per/atom 3 &
2007+
extra/angle/per/atom 6 &
2008+
extra/dihedral/per/atom 10 &
2009+
extra/special/per/atom 14
2010+
include ../PARM.lmp
20092011
\end{verbatim}}
20102012
Download the template called
2011-
\href{https://raw.githubusercontent.com/lammpstutorials/lammpstutorials-article/main/files/tutorial3/PEG-GROMOS.mol}{\textit{PEG-GROMOS.mol}}
2013+
\href{\filepath tutorial3/mergePEGH2O/PEG-GROMOS.mol}{\textit{PEG-GROMOS.mol}}
20122014
for the PEG molecule, and then create a single molecule in the middle of the box:
20132015
{\normalsize \begin{verbatim}
2014-
molecule pegmol PEG-GROMOS.mol
2015-
create_atoms 0 single 0 0 0 mol pegmol 454756
2016+
molecule pegmol PEG-GROMOS.mol
2017+
create_atoms 0 single 0 0 0 mol pegmol 454756
20162018
\end{verbatim}}
20172019
Let us create 2 groups to differentiate the PEG from the H2O, by adding the following
20182020
lines into \textit{input.lmp}:
20192021
{\normalsize \begin{verbatim}
2020-
group H2O type OW HW
2021-
group PEG type C CPos H HC OAlc OE
2022+
group H2O type OW HW
2023+
group PEG type C CPos H HC OAlc OE
20222024
\end{verbatim}}
20232025
Water molecules that are overlapping with the PEG must be deleted to avoid future crashing.
20242026
Add the following line into \textit{input.lmp}:
20252027
{\normalsize \begin{verbatim}
2026-
delete_atoms overlap 2.0 H2O PEG mol yes
2028+
delete_atoms overlap 2.0 H2O PEG mol yes
20272029
\end{verbatim}}
20282030
Here the value of 2 Ångstroms for the overlap cutoff was fixed arbitrarily and can
20292031
be chosen through trial and error. If the cutoff is too small, the simulation will
20302032
crash. If the cutoff is too large, too many water molecules will unnecessarily be
2031-
deleted. Finally, let us use the \textit{fix npt} to control the temperature, as
2033+
deleted.
2034+
2035+
Finally, let us use the \textit{fix npt} to control the temperature, as
20322036
well as the pressure by allowing the box size to be rescaled along the \textit{x} axis:
20332037
{\normalsize \begin{verbatim}
2034-
fix mynpt all npt temp 300 300 100 x 1 1 1000
2035-
timestep 1.0
2036-
\end{verbatim}}
2037-
Once more, let us dump the atom positions as well as the system temperature and volume:
2038-
{\normalsize \begin{verbatim}
2039-
dump mydmp all atom 100 dump.lammpstrj
2040-
thermo 100
2041-
variable mytemp equal temp
2042-
variable myvol equal vol
2043-
fix myat1 all ave/time 10 10 100 &
2044-
v_mytemp file temperature.dat
2045-
fix myat2 all ave/time 10 10 100 &
2046-
v_myvol file volume.dat
2038+
fix mynpt all npt temp 300 300 100 x 1 1 1000
2039+
timestep 1.0
20472040
\end{verbatim}}
2048-
Let us also print the total enthalpy:
2041+
Once more, let us create images of the systems:
20492042
{\normalsize \begin{verbatim}
2050-
variable myenthalpy equal enthalpy
2051-
fix myat3 all ave/time 10 10 100 &
2052-
v_myenthalpy file enthalpy.dat
2043+
dump mydmp all image 1000 dump.*.ppn type &
2044+
type shiny 0.1 box no 0.01 &
2045+
view 0 90 zoom 1.8 fsaa yes bond atom 0.8
2046+
dump_modify mydmp backcolor white &
2047+
acolor OW red acolor HW white &
2048+
acolor OE red acolor OAlc red &
2049+
acolor C gray acolor CPos gray &
2050+
acolor H white acolor HC white &
2051+
adiam OW 0.2 adiam HW 0.2 &
2052+
adiam C 3 adiam CPos 3 adiam OAlc 2.8 &
2053+
adiam H 1 adiam HC 1 adiam OE 2.8
2054+
thermo 1000
20532055
\end{verbatim}}
20542056
Finally, let us perform a short equilibration and print the
20552057
final state in a data file. Add the following lines to the data file:
20562058
{\normalsize \begin{verbatim}
2057-
run 30000
2058-
write_data mix.data
2059-
\end{verbatim}}
2060-
If you open the \textit{dump.lammpstrj} file using VMD or have a look at the
2061-
evolution of the volume in \textit{volume.dat}, you should see that the box
2062-
dimensions slightly evolve along \textit{x} to accommodate the new configuration.
2063-
In addition, the temperature remains close to the target value of $300~\text{K}$
2064-
throughout the entire simulation, and the enthalpy is almost constant, suggesting
2065-
that the system was close to equilibrium from the start.
2059+
run 30000
2060+
write_data mix.data
2061+
\end{verbatim}}
2062+
From the outputs, you can make sure that the temperature remains close to the
2063+
target value of $300~\text{K}$ throughout the entire simulation, and the that
2064+
the volume and total energy are almost constant, suggesting
2065+
that the system was close to equilibrium from the start. See a snapshot of the
2066+
system in Fig.\,\ref{fig:PEG-solvated}.
20662067

20672068
\begin{figure}
20682069
\centering

0 commit comments

Comments
 (0)