Skip to content

Commit 0d08d30

Browse files
committed
continue improving tutorial 3
1 parent 32b14c2 commit 0d08d30

2 files changed

Lines changed: 112 additions & 51 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
variable f0 equal 5
2+
3+
units real
4+
atom_style full
5+
bond_style harmonic
6+
angle_style harmonic
7+
dihedral_style harmonic
8+
pair_style lj/cut/coul/long 10
9+
kspace_style pppm 1e-5
10+
special_bonds lj 0.0 0.0 0.5 &
11+
coul 0.0 0.0 1.0 &
12+
angle yes dihedral yes
13+
14+
read_data ../mergePEGH2O/mix.data
15+
include ../PARM.lmp
16+
17+
group H2O type OW HW
18+
group PEG type C CPos H HC OAlc OE
19+
group ends type OAlc
20+
variable xcm equal xcm(ends,x)
21+
variable oxies atom type==label2type(atom,OAlc)
22+
variable end1 atom v_oxies*(x>v_xcm)
23+
variable end2 atom v_oxies*(x<v_xcm)
24+
25+
group topull1 variable end1
26+
group topull2 variable end2
27+
28+
dump mydmp all image 1000 dump.*.ppn type &
29+
type shiny 0.1 box no 0.01 &
30+
view 0 90 zoom 1.8 fsaa yes bond atom 0.8
31+
dump_modify mydmp backcolor white &
32+
acolor OW red acolor HW white &
33+
acolor OE red acolor OAlc red &
34+
acolor C gray acolor CPos gray &
35+
acolor H white acolor HC white &
36+
adiam OW 0.2 adiam HW 0.2 &
37+
adiam C 3 adiam CPos 3 adiam OAlc 2.8 &
38+
adiam H 1 adiam HC 1 adiam OE 2.8
39+
40+
variable x1 equal xcm(topull1,x)
41+
variable x2 equal xcm(topull2,x)
42+
variable y1 equal xcm(topull1,y)
43+
variable y2 equal xcm(topull2,y)
44+
variable z1 equal xcm(topull1,z)
45+
variable z2 equal xcm(topull2,z)
46+
variable delta_r equal sqrt((v_x1-v_x2)^2+(v_y1-v_y2)^2+(v_z1-v_z2)^2)
47+
compute rgyr PEG gyration
48+
thermo_style custom step temp etotal v_delta_r c_rgyr
49+
thermo 1000
50+
51+
timestep 1.0
52+
fix mynvt all nvt temp 300 300 100
53+
54+
run 30000
55+
56+
fix myaf1 topull1 addforce ${f0} 0 0
57+
fix myaf2 topull2 addforce -${f0} 0 0
58+
59+
run 30000

lammps-tutorials.tex

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,43 +2087,52 @@ \subsubsection{Stretching the PEG molecule}
20872087
contribution from both water and PEG molecules (it was chosen by trial and error).
20882088
Then, copy the same lines as previously:
20892089
{\normalsize \begin{verbatim}
2090-
units real
2091-
atom_style full
2092-
bond_style harmonic
2093-
angle_style harmonic
2094-
dihedral_style harmonic
2095-
pair_style lj/cut/coul/long 10
2096-
kspace_style pppm 1e-5
2097-
special_bonds lj 0.0 0.0 0.5 &
2098-
coul 0.0 0.0 1.0 &
2099-
angle yes dihedral yes
2090+
units real
2091+
atom_style full
2092+
bond_style harmonic
2093+
angle_style harmonic
2094+
dihedral_style harmonic
2095+
pair_style lj/cut/coul/long 10
2096+
kspace_style pppm 1e-5
2097+
special_bonds lj 0.0 0.0 0.5 &
2098+
coul 0.0 0.0 1.0 &
2099+
angle yes dihedral yes
21002100
\end{verbatim}}
21012101
Start the simulation from the equilibrated PEG-water system and include again the
21022102
parameter file by adding the following lines to the \textit{input.lmp}:
21032103
{\normalsize \begin{verbatim}
2104-
read_data ../mergePEGH2O/mix.data
2105-
include ../PARM.lmp
2104+
read_data ../mergePEGH2O/mix.data
2105+
include ../PARM.lmp
21062106
\end{verbatim}}
21072107
Next, let us create some useful atom groups, including H2O and PEG (as previously),
21082108
as well as 2 groups containing a single atom each, the oxygen atoms at the ends
21092109
of the chain. Atoms of types OAlc correspond to the hydroxy (alcohol) group oxygen
21102110
atoms located at the ends of the PEG molecule, which we are going to use to pull
21112111
on the PEG molecule. Add the following lines to the \textit{input.lmp}:
21122112
{\normalsize \begin{verbatim}
2113-
group H2O type OW HW
2114-
group PEG type C CPos H HC OAlc OE
2115-
group ends type OAlc
2116-
variable xcm equal xcm(ends,x)
2117-
variable oxies atom type==label2type(atom,OAlc)
2118-
variable end1 atom v_oxies*(x>v_xcm)
2119-
variable end2 atom v_oxies*(x<v_xcm)
2120-
group topull1 variable end1
2121-
group topull2 variable end2
2113+
group H2O type OW HW
2114+
group PEG type C CPos H HC OAlc OE
2115+
group ends type OAlc
2116+
variable xcm equal xcm(ends,x)
2117+
variable oxies atom type==label2type(atom,OAlc)
2118+
variable end1 atom v_oxies*(x>v_xcm)
2119+
variable end2 atom v_oxies*(x<v_xcm)
2120+
group topull1 variable end1
2121+
group topull2 variable end2
21222122
\end{verbatim}}
2123-
Add the following \textit{dump} command to the input to print the atom positions
2124-
every 1000 steps:
2123+
Add the following \textit{dump} command to create images of the system:
21252124
{\normalsize \begin{verbatim}
2126-
dump mydmp all atom 1000 dump.lammpstrj
2125+
dump mydmp all image 1000 dump.*.ppn type &
2126+
type shiny 0.1 box no 0.01 &
2127+
view 0 90 zoom 1.8 fsaa yes bond atom 0.8
2128+
dump_modify mydmp backcolor white &
2129+
acolor OW red acolor HW white &
2130+
acolor OE red acolor OAlc red &
2131+
acolor C gray acolor CPos gray &
2132+
acolor H white acolor HC white &
2133+
adiam OW 0.2 adiam HW 0.2 &
2134+
adiam C 3 adiam CPos 3 adiam OAlc 2.8 &
2135+
adiam H 1 adiam HC 1 adiam OE 2.8
21272136
\end{verbatim}}
21282137
Let us use a single Nosé-Hoover thermostat applied to all the atoms by adding the
21292138
following lines to \textit{input.lmp}:
@@ -2133,44 +2142,37 @@ \subsubsection{Stretching the PEG molecule}
21332142
\end{verbatim}}
21342143
Let us also print the end-to-end distance of the PEG,
21352144
here defined as the distance between the groups \textit{topull1}
2136-
and \textit{topull2}, as well as the temperature of the system and the gyration
2145+
and \textit{topull2}, as well as the gyration
21372146
radius of the molecule \cite{fixmanRadiusGyrationPolymer1962a}
21382147
by adding the following lines to \textit{input.lmp}:
2139-
% S.G.: should we keep the data file, or just use thermo custom as its better for LAMMPS-GUI?
2140-
{\normalsize \begin{verbatim}
2141-
variable mytemp equal temp
2142-
fix myat1 all ave/time 10 10 100 &
2143-
v_mytemp file temperature.dat
2144-
variable x1 equal xcm(topull1,x)
2145-
variable x2 equal xcm(topull2,x)
2146-
variable y1 equal xcm(topull1,y)
2148+
{\normalsize \begin{verbatim}
2149+
variable x1 equal xcm(topull1,x)
2150+
variable x2 equal xcm(topull2,x)
2151+
variable y1 equal xcm(topull1,y)
21472152
variable y2 equal xcm(topull2,y)
2148-
variable z1 equal xcm(topull1,z)
2149-
variable z2 equal xcm(topull2,z)
2150-
variable delta_r equal &
2151-
sqrt((v_x1-v_x2)^2+(v_y1-v_y2)^2 &
2152-
+(v_z1-v_z2)^2)
2153-
fix myat2 all ave/time 10 10 100 v_delta_r &
2154-
file end-to-end-distance.dat
2155-
compute rgyr PEG gyration
2156-
fix myat3 all ave/time 10 10 100 c_rgyr &
2157-
file gyration-radius.dat
2158-
thermo 1000
2153+
variable z1 equal xcm(topull1,z)
2154+
variable z2 equal xcm(topull2,z)
2155+
variable delta_r equal &
2156+
sqrt((v_x1-v_x2)^2+(v_y1-v_y2)^2 &
2157+
+(v_z1-v_z2)^2)
2158+
compute rgyr PEG gyration
2159+
thermo_style custom step temp etotal v_delta_r c_rgyr
2160+
thermo 1000
21592161
\end{verbatim}}
21602162
Finally, let us simulate 30 picoseconds without any external forcing:
21612163
{\normalsize \begin{verbatim}
2162-
run 30000
2164+
run 30000
21632165
\end{verbatim}}
21642166
This first run will serve as a benchmark to quantify later the changes induced
2165-
by the forcing. Then, let us apply a forcing on the 2 oxygen atoms using two
2167+
by the forcing. Then, let us apply a forcing on the 2 selected oxygen atoms using two
21662168
\textit{add\_force} commands, and run for an extra 30 ps:
21672169
{\normalsize \begin{verbatim}
2168-
fix myaf1 topull1 addforce ${f0} 0 0
2169-
fix myaf2 topull2 addforce -${f0} 0 0
2170-
run 30000
2170+
fix myaf1 topull1 addforce ${f0} 0 0
2171+
fix myaf2 topull2 addforce -${f0} 0 0
2172+
run 30000
21712173
\end{verbatim}}
2172-
Run the \textit{input.lmp} file using LAMMPS. If you open the \textit{dump.lammpstrj}
2173-
file using \textit{VMD}, you should see that the PEG molecule eventually aligns
2174+
Run the \textit{input.lmp} file using LAMMPS. From the generated images of the system,
2175+
you should see that the PEG molecule eventually aligns
21742176
in the direction of the force (as seen in Fig.\,\ref{fig:PEG-in-water}).
21752177
The evolutions of the end-to-end distance and of the gyration radius over
21762178
time show that the PEG is adjusting to the external forcing in less than

0 commit comments

Comments
 (0)