Non-equilibrium molecular dynamics with LAMMPS
-
Upload
andrea-benassi -
Category
Science
-
view
125 -
download
9
Transcript of Non-equilibrium molecular dynamics with LAMMPS
Non-‐Equilibrium Molecular Dynamics with LAMMPS
A quick introduc;on
Andrea Benassi
(h>ps://sites.google.com/site/benassia/)
Outline
Some notes on the installa;on Input: general structure Example one: LJ solid………………………………….. A first look to the input file, the fix command Example two: Surface diffusion ………………. Thermostats, the group command Example three: External driving……………... Pushing the system out of equilibrium Example four: rigid molecules………………… Constrained dynamics, the molecule style Advanced input: defining and using variables Output : general structure Computa;ons and Output
Reference Web Page
LAMMPS: Large-‐Scale Atomic/Molecular Massively Parallel Simulator
h>p://lammps.sandia.gov/
Atomis;c simula;ons with pairwise and many-‐body poten;als Force fields for polymers and bio-‐molecules Finite elements calcula;ons with atomis;c/con;nuum coupling Poten;als for granular media
Installa;on AWer downloading the tarball file: 1) typing the command make in the src directory will list the different preconfigured
architectures (the corresponding makefiles are in the src/MAKE folder) and the instruc;ons on how to compile for the desired architecture.
To compile on CSCS Cray edit e.g. Makefile.xt5 and comment lines FFT_INC, FFT_PATH and FFT_LIB, load the needed modules, go back to src and execute make xt5. 2) LAMMPS works with different external packages, type make package to list all the available
packages. To include some of them execute make yes-package name_of_package before the compila;on command. make package-status will list the status of all packages.
4) To modify the path of a library with respect to the preconfigured on, simply edit the
corresponding makefile. To install on Ipazia, for instance, edit the Makefile.mkl. #CC = mpiicc CC = /opt/parasta;on/mpi2-‐intel/bin/mpicc CCFLAGS = -‐O3 -‐fno-‐alias -‐ip -‐unroll0 DEPFLAGS = -‐M LINK = /opt/parasta;on/mpi2-‐intel/bin/mpicc #LINKFLAGS = -‐O -‐L/opt/intel/mkl/10.0.011/lib/em64t LINKFLAGS = -‐O -‐L/opt/intel/ict_2011/mkl/lib/intel64 LIB = -‐lstdc++ -‐lpthread -‐lmkl_intel_lp64 -‐lmkl_intel_thread -‐lmkl_core -‐liomp5 #LIB = -‐lstdc++ -‐lpthread -‐lmkl_intel_lp64 -‐lmkl_intel_thread -‐lmkl_core -‐lguide ARCHIVE = ar ARFLAGS = -‐rc SIZE = size
Code chart
log file
Restart
Trajectories(xyz, pdb, …)
User defined data/variables
Input
LAMMPS engine
f(x)
Input file: overall structure
Ini*aliza*on Simula-on kind Dimensionality Unit system
Input file: overall structure
Ini*aliza*on Simula-on kind Dimensionality Unit system
Structural Informa*on Boundary condi-ons Number and kind of atoms and molecules Atomic Coordinates Defini-on of atom subgroups Masses and ini-al condi-ons
Input file: overall structure
Ini*aliza*on Simula-on kind Dimensionality Unit system
Structural Informa*on Boundary condi-ons Number and kind of atoms and molecules Atomic Coordinates Defini-on of atom subgroups Masses and ini-al condi-ons
Interac*on / Evolu*on info Interac-on poten-al (kinds,parameters,cutoffs) Dynamics algorithm (NVE, NVT, PVT …) Constraints and external forces
Input file: overall structure
Ini*aliza*on Simula-on kind Dimensionality Unit system
Structural Informa*on Boundary condi-ons Number and kind of atoms and molecules Atomic Coordinates Defini-on of atom subgroups Masses and ini-al condi-ons
Interac*on / Evolu*on info Interac-on poten-al (kinds,parameters,cutoffs) Dynamics algorithm (NVE, NVT, PVT …) Constraints and external forces
Execu*on Info / calcula*ons Time step, total simula-on -me … Trajectories and averaged quan--es Restart file
Input file: overall structure
Ini*aliza*on Simula-on kind Dimensionality Unit system
Structural Informa*on Boundary condi-ons Number and kind of atoms and molecules Atomic Coordinates Defini-on of atom subgroups Masses and ini-al condi-ons
Interac*on / Evolu*on info Interac-on poten-al (kinds,parameters,cutoffs) Dynamics algorithm (NVE, NVT, PVT …) Constraints and external forces
Execu*on Info / calcula*ons Time step, total simula-on -me … Trajectories and averaged quan--es Restart file
The input is posi*onal: succeeding commands can override each other or being applied subsequently to the dynamics !!!
Example one: LJ solid + adsorbate
1001 atoms 2 atom types 0.0 15.874 xlo xhi 0.0 7.9370 ylo yhi 0.0 50.000 zlo zhi Atoms 1 1 0.0000000E+00 0.0000000E+00 0.0000000E+00 2 1 0.7935000 0.7935000 0.0000000E+00 3 1 0.0000000E+00 0.7935000 0.7935000 4 1 0.7935000 0.0000000E+00 0.7935000 5 1 1.587000 0.0000000E+00 0.0000000E+00 6 1 2.380500 0.7935000 0.0000000E+00 7 1 1.587000 0.7935000 0.7935000 8 1 2.380500 0.0000000E+00 0.7935000 9 1 3.174000 0.0000000E+00 0.0000000E+00
…
For the details of any command refer to: h>p://lammps.sandia.gov/doc/Manual.html
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 3.5 fix pippo all nve thermo 50 dump pluto all xyz 50 dump.xyz restart 10000 my_restart neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
xlo xhi
zlo
zhi
Example one: LJ solid + adsorbate
1001 atoms 2 atom types 0.0 15.874 xlo xhi 0.0 7.9370 ylo yhi 0.0 50.000 zlo zhi Atoms 1 1 0.0000000E+00 0.0000000E+00 0.0000000E+00 2 1 0.7935000 0.7935000 0.0000000E+00 3 1 0.0000000E+00 0.7935000 0.7935000 4 1 0.7935000 0.0000000E+00 0.7935000 5 1 1.587000 0.0000000E+00 0.0000000E+00 6 1 2.380500 0.7935000 0.0000000E+00 7 1 1.587000 0.7935000 0.7935000 8 1 2.380500 0.0000000E+00 0.7935000 9 1 3.174000 0.0000000E+00 0.0000000E+00
…
For the details of any command refer to: h>p://lammps.sandia.gov/doc/Manual.html
atoms number types number
cell dimensions
veloci;es can also be specified atom by atom in the data file using the keyword Velocities aWer the Atoms one.
atom coordinates
atom number
atom kind
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 3.5 fix pippo all nve thermo 50 dump pluto all xyz 50 dump.xyz restart 10000 my_restart neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
Example one: LJ solid + adsorbate
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 3.5 fix pippo all nve thermo 50 dump pluto all xyz 50 dump.xyz restart 10000 my_restart neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
fix pippo all nve
dump pluto all xyz 50 dump.xyz
command command ID target atoms ID command op;ons
1001 atoms 2 atom types 0.0 15.874 xlo xhi 0.0 7.9370 ylo yhi 0.0 50.000 zlo zhi Atoms 1 1 0.0000000E+00 0.0000000E+00 0.0000000E+00 2 1 0.7935000 0.7935000 0.0000000E+00 3 1 0.0000000E+00 0.7935000 0.7935000 4 1 0.7935000 0.0000000E+00 0.7935000 5 1 1.587000 0.0000000E+00 0.0000000E+00 6 1 2.380500 0.7935000 0.0000000E+00 7 1 1.587000 0.7935000 0.7935000 8 1 2.380500 0.0000000E+00 0.7935000 9 1 3.174000 0.0000000E+00 0.0000000E+00
…
For the details of any command refer to: h>p://lammps.sandia.gov/doc/Manual.html
Restart a previous calcula;on
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 read_restart my_restart boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 3.5 fix pippo all nve thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 read_restart my_restart velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 3.5 fix pippo all nve thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
both posi;ons and veloci;es are restored by the binary file
my_restart
the posi;ons are restored by the binary file while the veloci;es are renewed
the binary2txt tool allows to convert the binary restart file into a textual file to extract informa;on
on posi;on, veloci;es and simula;on cell
Example two: surface diffusion
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.0 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 2.5 fix pippo all nve fix billy all langevin 0.1 0.1 10.0 17786 thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
global thermostat local thermostat
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.0 87287 boundary p p p mass 1 1.0 mass 2 1.0 group bottom id <= 50 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 2.5 fix pippo all nve fix penny bottom langevin 0.1 0.1 10.0 177 thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
To promote diffusion the temperature must come into play, we introduce the Langevin thermostat on top of the NVE dynamics. A local thermostat can be introduced defining a sub-‐group of atoms
Example two: surface diffusion
The ;me necessary to reach the steady state depends on the thermostat parameter Once we reach a steady state all averages and the sta;s;cal sampling should be independent from the thermostat parameter
Example two: surface diffusion To sample an equilibrium ensemble there is no need for a stochas;c thermostat fulfilling the fluctua;on-‐dissipa;on theorem, a Nose`-‐Hoover chain is enough to sa;sfy the equipar;;on theorem.
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 2.5 fix pippo all nve fix billy all langevin 0.1 0.1 10.0 17786 fix pippo all nvt 0.1 0.1 10.0 thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
the Langevin fix is not an integra;on fix, it just modifies the NVE ;me integrator. The NVT fix is an integrator by itself Some fix commands integrate the equa;on of mo;on, some others just modify the integra;on algorithm. Some fix commands are used to calculate physical quan;;es, some others are needed to write them out.
Example two: surface diffusion Sub-‐groups can be also used to impose addi;onal constraints, here we fix the center of mass of the whole substrate, this will be useful when an external driving force will be applied.
dimension 3 units lj atom_style atomic read_data initpos.dat velocity all create 0.1 87287 boundary p p p mass 1 1.0 mass 2 1.0 group substrate id <= 1000 pair_style lj/cut 2.5 pair_coeff 1 1 1.0 1.0 2.5 pair_coeff 2 2 0.0 1.0 2.5 pair_coeff 1 2 0.2 1.0 2.5 fix pippo all nve fix billy all langevin 0.1 0.1 10.0 17786 fix buddy substrate recenter INIT INIT INIT units box thermo 50 dump pluto all xyz 50 dump.xyz neighbor 0.3 bin neigh_modify every 20 delay 0 check no timestep 0.005 run 50000
The recenter fix rescales the CM posi;on to a given value or to the ini;al value. Remember the input file is posi;onal: it is be>er to rescale the coordinates only aWer the complete evolu;on of the whole system took place, i.e. the recenter fix must always be the last one!
Example three: external driving Different kinds of external forces can be applied: to mimic an AFM ;p we can use both a constant force or constant velocity driving.
...
mass 1 1.0 mass 2 1.0E+10 mass 3 1.0 group substrate type 1 group support type 2 group tip type 3 velocity substrate create 0.01 87287 velocity support set 0.0 0.005 0.0 sum no units box velocity tip create 0.0 0.0 0.0 sum no units box pair_style lj/cut 1.5 pair_coeff 1 1 1.0 1.0 1.5 pair_coeff 1 2 0.0 1.0 1.5 pair_coeff 1 3 0.2 1.0 1.5 pair_coeff 2 2 0.0 1.0 1.5 pair_coeff 2 3 0.0 1.0 1.5 pair_coeff 3 3 0.0 1.0 1.5 fix 0 support spring couple tip 1.0 AUTO AUTO AUTO 0.0 fix 1 tip addforce 0.0 0.0 -1.0 fix 2 all nve fix 3 substrate langevin 0.01 0.01 1.0 67869 fix last substrate recenter INIT INIT INIT units box
...
LAMMPS do not allow us to do this so easily: we have to define three types of par;cles for the ;p, the can;lever support and the substrate atoms. If M >> m the support par;cle will move at constant velocity regardless of the spring, and m will only be a negligible perturba;on.
k m v0
k m vint M
M>>m
the Tomlinson model would require us to drive the free end of the spring at constant velocity
A workaround is needed to allow the fix spring to work properly when the rigid body tip cross the periodic boundary condi;ons. See h>p://lammps.sandia.gov/threads/msg26559.html
z
x y
Example three: external driving
0
1
2
3
4
5
6
7
8
9
10
0 1000 2000 3000 4000 5000
y po
sitio
n
time
12.3
12.32
12.34
12.36
12.38
12.4
12.42
12.44
12.46
12.48
12.5
0 1000 2000 3000 4000 5000
z
time
0
0.0005
0.001
0.0015
0.002
0.0025
0.003
0 1000 2000 3000 4000 5000
frict
ion
forc
e
time
Example four: rigid molecules The atom_style molecular must be used, the MOLECULE package must be installed!!! dimension 3 units real atom_style molecular read_data initial_confing.dat velocity all create 200.0 8807 boundary p p p mass 1 12.011 mass 2 0.0001 mass 3 0.0001 pair_style buck 10.0 pair_coeff 1 1 89302.93 0.27778 606.87 pair_coeff 1 2 16372.20 0.27778 0.0 pair_coeff 1 3 7441.911 0.29412 0.0 pair_coeff 2 2 16372.20 0.27778 0.0 pair_coeff 2 3 0.000000 1.00000 0.0 pair_coeff 3 3 5358.176 0.31250 0.0 fix 1 all rigid molecule thermo 50 thermo_style custom step temp etotal pe ke dump 1 all xyz 1000 bulk_200.xyz restart 100000 bella.restart neighbor 0.3 bin neigh_modify every 20 delay 0 check no neigh_modify exclude molecule all run 1000000
120960 atoms 3 atom types 0.0 83.58056 xlo xhi 0.0 72.38289 ylo yhi 0.0 76.77364 zlo zhi Atoms 1 1 1 0.4666309 -0.4264708 3.487395 2 1 1 -0.7416468 0.2906179 3.455781 3 1 1 1.693772 0.2155275 3.102340 4 1 1 -0.7456188 1.707600 3.022896 5 1 1 1.692779 1.566589 2.689721 6 1 1 0.4408169 2.321510 2.648378 7 1 1 0.5103149 -1.786131 3.017221 8 1 1 -1.954889 -0.3433542 2.941832 9 1 1 -0.6602345 -2.400042 2.518675
a new column: the molecule index
this line excludes the intra-‐molecular interac;ons from the total energy calcula;on, it is useful in our case because the type 2 and type 3 atoms are ghost atoms
This is the rigid body dynamics fix! It treats every molecule as a rigid bodies. Alterna;vely one can ask for a subgroup of atoms or for all subgroups of atoms to be treated as rigid bodies.
Example four: rigid molecules The atom_style molecular must be used, the MOLECULE package must be installed!!!
fix 1 all rigid/nvt molecule temp 200.0 200.0 10.0
dimension 3 units real atom_style molecular read_data initial_confing.dat velocity all create 200.0 8807 boundary p p p mass 1 12.011 mass 2 0.0001 mass 3 0.0001 pair_style buck 10.0 pair_coeff 1 1 89302.93 0.27778 606.87 pair_coeff 1 2 16372.20 0.27778 0.0 pair_coeff 1 3 7441.911 0.29412 0.0 pair_coeff 2 2 16372.20 0.27778 0.0 pair_coeff 2 3 0.000000 1.00000 0.0 pair_coeff 3 3 5358.176 0.31250 0.0 fix 1 all rigid molecule thermo 50 thermo_style custom step temp etotal pe ke dump 1 all xyz 1000 bulk_200.xyz restart 100000 bella.restart neighbor 0.3 bin neigh_modify every 20 delay 0 check no neigh_modify exclude molecule all run 1000000
fix 1 all rigid molecule
rigid body NVE
rigid body NVT for equilibrium simula;ons
fix 1 all rigid molecule langevin 200.0 200.0 10.0 19867
rigid body NVT for non-‐equilibrium simula;ons
further constraints can be introduced freezing the rota;onal or transla;onal degrees of freedom of each rigid body.
8x8x9 fullerene x 210 atoms =120960 atoms 128 procs for 12 hours @ ipazia
Example four: rigid molecules Combining external driving with rigid bodies…
0
0.2
0.4
0.6
0.8
1
1.2
1.4
0 200000 400000 600000 800000 1e+06 1.2e+06 1.4e+06 1.6e+06
forc
e [n
N]
time [fsec]
’sega2’ u ($1):($5*0.06889)
Advanced input: defining and using variables Variables can be introduced in the input script via the command variable, the defini;on is unique however a variable can have two different behaviors depending on the way it is referenced
variable t world 50.00 100.00 150.00 variable s world 6627 5328 4541 fix thermostat all langevin $t $t 10.0 $s
variable force equal "ramp(0.0,0.1)" fix pulling tip addforce 0.0 0.0 v_force
fixed value variables evaluated value variables
An increasing pulling force is applied to a group of atoms called tip. A variable force is defined, in the fix addforce the variable is referenced by v_ , this cause the value of the variable to be evaluated at each ;me step according to the instruc;on contained in the variable defini;on. ramp is a mathema;cal func;on which increases the variable value from 0.0 to 0.1 through the simula;on. The equal statement assign to the variable a specific value whose scope is the single run being performed.
Three different simula;ons are simultaneously performed within a replica exchange at the the temperatures 50, 100 and 150 K. In each simultaneous simula;on the thermostat is fixed at temperature $t with a random seed $s. Referencing the variables with $ fixes their value for the whole simula;on.
• Many math func;on can be used to define variables
• loops and condi;onal instruc;ons can be
applied as well
Output (.log file): overall structure
Informa*on about the parsing of the input
Error/warning messages
Output of the thermo command
Sta*s*cs and *ming of the simula*on
fix command compute command
Computa;ons and Output
both fix and compute commands can calculate and store quan;;es
Computa;ons and Output
LAMMPS supports three kinds of variable
local variable global variable per atoms variable
calculated at every ;me for each atom, e.g. posi;ons, veloci;es and
forces, angles and bonds
calculated at every ;me for each atom by each processor
calculated at every ;me for the whole system or a piece of it, e.g.
total energy, center of mass posi;on for a subgroup of atoms
fix command compute command
Computa;ons and Output
Two commands allow to write per atoms and global variables, dump
and thermo respec;vely
local variable global variable
Trajectories(xyz, pdb, …)
User defined data/variables
f(x)
thermo thermo_style
log file
per atoms variable
dump
fix command compute command
Computa;ons and Output
… fix 1 tip addforce 0.0 0.0 -0.05 fix 2 bottom rigid molecule fix 3 substrate rigid molecule fix 4 tip rigid molecule torque * off off off fix 5 support spring couple tip 1.0 AUTO AUTO AUTO 0.0 fix 6 support nve compute 1 substrate temp/com compute 2 support com/molecule dump 1 all xyz 1000 friction_50.xyz thermo_style custom step c_1 f_5[4] c_2[1][1] c_2[1][2] thermo 50
global variables are calculated by these two computes: (1) is the temperature of a por;on of the system the
subgroup substrate, is a scalar (2) is a set of two vectors (a matrix) containing veloci;es
and posi;on of the center of mass of a group of atoms called support
all the fixes which cause the ;me evolu;on of the system can be considered as generators of per atom variables, i.e. the posi;ons, veloci;es and forces of each atom
this fix add a pulling spring to a group of atoms and store, for each ;me step, a four component vector containing the three elas;c force components and the force modulus
global output: each scalar/vector/matrix has a composite name made by C_ of F_ depending whether if it comes from a compute or a fix command + the name/number of the compute/fix + a set of indexes to iden;fy the desired components
per atom output: the posi;ons of all the atoms are stored in a .xyz file every 1000 ;me steps