| 1 |
# PREREQUISITES: |
| 2 |
# |
| 3 |
# You must use moltemplate.sh to create 3 files: |
| 4 |
# system.data system.in.init system.in.settings |
| 5 |
# (You do not need to run LAMMPS to equilibrate the system before |
| 6 |
# using this file.) |
| 7 |
# |
| 8 |
# Requirements: |
| 9 |
# To run this system at constant pressure, it might help to compile LAMMPS with |
| 10 |
# the optional RIGID package, and use "fix rigid" on the carbon. (Optional.) |
| 11 |
# The use of fix rigid is controversial. This method is demonstrated below. |
| 12 |
# THIS EXAMPLE HAS NOT BEEN RIGOROUSLY TESTED. This simulation may fail. |
| 13 |
# (However the "run.in.nvt" example in this directory should work.) |
| 14 |
# ------------------------------- Initialization Section -------------------- |
| 15 |
|
| 16 |
include "system.in.init" # specify the style of force field used |
| 17 |
|
| 18 |
# ------------------------------- Atom Definition Section ------------------- |
| 19 |
|
| 20 |
read_data "system.data" # load atom coordinates and topology |
| 21 |
|
| 22 |
# ------------------------------- Settings Section -------------------------- |
| 23 |
|
| 24 |
include "system.in.settings" # load the force field parameters |
| 25 |
|
| 26 |
# Use "neigh_modify" to turn off calculation of interactions between immobilized |
| 27 |
# atoms. (Note: group "cGraphene" was defined in the file "system.in.settings") |
| 28 |
|
| 29 |
neigh_modify exclude group Cgraphene Cgraphene |
| 30 |
|
| 31 |
# ------------------------------- Run Section ------------------------------- |
| 32 |
|
| 33 |
|
| 34 |
# Only the Cgraphene atoms are immobile. |
| 35 |
group mobile subtract all Cgraphene |
| 36 |
|
| 37 |
# (Note: The "Cgraphene" group was defined in "system.in.settings".) |
| 38 |
|
| 39 |
# Unfortunately you can not use the LAMMPS "minimize" command on this system |
| 40 |
# because there is no way to immobilize the carbon graphene & nanotube atoms |
| 41 |
# during minimization. Instead, we can use langevin dynamics with a fast |
| 42 |
# damping parameter and a small timestep. |
| 43 |
|
| 44 |
print "---- beginning minimization (using fix langevin, not minimize) ----" |
| 45 |
|
| 46 |
timestep 0.1 |
| 47 |
|
| 48 |
# Give each atom a random initial velocity consistent with a system at 1.0K. |
| 49 |
velocity mobile create 1.0 12345 |
| 50 |
|
| 51 |
fix fxlan mobile langevin 1.0 1.0 100.0 48279 |
| 52 |
fix fxnve mobile nve # <-- needed by fix langevin (see lammps documentation) |
| 53 |
|
| 54 |
thermo 100 |
| 55 |
run 2500 |
| 56 |
|
| 57 |
unfix fxlan |
| 58 |
unfix fxnve |
| 59 |
|
| 60 |
# -- simulation protocol -- |
| 61 |
|
| 62 |
print "--------- beginning simulation (using fix nvt) ---------" |
| 63 |
|
| 64 |
dump 1 all custom 1000 traj_npt.lammpstrj id mol type x y z ix iy iz |
| 65 |
|
| 66 |
unfix fShakeSPCE # Disable SHAKE during minimization and pressure equilibr |
| 67 |
|
| 68 |
thermo_style custom step temp pe etotal press vol epair ebond eangle edihed |
| 69 |
thermo 200 # time interval for printing out "thermo" data |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
# ------------------------- NPT --------------------------- |
| 76 |
|
| 77 |
|
| 78 |
# ------ QUESTIONABLE (see below): ------ |
| 79 |
|
| 80 |
fix Ffreezestuff Cgraphene rigid single force * off off off torque * off off off |
| 81 |
|
| 82 |
# Comment: |
| 83 |
# The use of "fix rigid" to immobilize an object is somewhat controversial. |
| 84 |
# Feel free to omit it. |
| 85 |
# (Neither Trung or Steve Plimpton use fix rigid for immobilizing |
| 86 |
# molecules, but I noticed that at NPT, it does a better job of maintaining |
| 87 |
# the correct volume. However "fix rigid" has changed since then (2011), |
| 88 |
# so this may no longer be true. Please use this example with caution.) |
| 89 |
|
| 90 |
|
| 91 |
# Thermostat+Barostat |
| 92 |
# Set temp=300K, pressure=200bar, and equilibrate volume only in the z direction |
| 93 |
|
| 94 |
fix fxMoveStuff mobile npt temp 300 300 100 z 200 200 1000.0 dilate mobile drag 2.0 |
| 95 |
|
| 96 |
# ---------------------------------------- |
| 97 |
|
| 98 |
# The next two lines recalculate the temperature using |
| 99 |
# only the mobile degrees of freedom (ie. water atom velocities): |
| 100 |
|
| 101 |
compute tempMobile mobile temp |
| 102 |
compute pressMobile all pressure tempMobile |
| 103 |
|
| 104 |
thermo_style custom step c_tempMobile c_pressMobile temp press vol |
| 105 |
|
| 106 |
fix_modify fxMoveStuff temp tempMobile |
| 107 |
|
| 108 |
reset_timestep 0 |
| 109 |
|
| 110 |
timestep 0.25 |
| 111 |
|
| 112 |
run 20000 |
| 113 |
|
| 114 |
timestep 0.5 |
| 115 |
|
| 116 |
run 50000 |
| 117 |
|
| 118 |
|
| 119 |
# Hopefully the barostat is no longer oscillating. Then we can try using fix |
| 120 |
# npt again and omit the "drag 2.0" argument. (A non-zero drag parameter will |
| 121 |
# result in unrealistic fluctuations of volume under NPT conditions.) |
| 122 |
# First, undo the previous "fix npt" |
| 123 |
|
| 124 |
unfix fxMoveStuff |
| 125 |
|
| 126 |
# Then re-apply "fix npt" |
| 127 |
# Set temp=300K, pressure=0bar, and equilibrate volume only in the z direction |
| 128 |
fix fxMoveStuff mobile npt temp 300 300 100 z 0 0 1000.0 dilate mobile |
| 129 |
fix_modify fxMoveStuff temp tempMobile |
| 130 |
|
| 131 |
timestep 0.5 # (Perhaps we can increase this timestep to 1.0? I'm not sure.) |
| 132 |
|
| 133 |
run 5000000 |
| 134 |
|
| 135 |
write_data system_after_npt.data |
| 136 |
|
| 137 |
# (The "write_restart" and "read_restart" commands were buggy in 2012, |
| 138 |
# but they should work also.) |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
# ----- Comment: Avoid using fix rigid/npt on large single rigid objects ----- |
| 147 |
# |
| 148 |
# Use of the following is not recommended: |
| 149 |
# |
| 150 |
# fix Ffreezestuff Cgraphene rigid/npt single temp 300 300 100 z 200 200 1000.0 force * off off off torque * off off off dilate mobile |
| 151 |
# (temp=300K, pressure=200bar, and equilibrate volume only in the z direction) |
| 152 |
# |
| 153 |
# In my experience, the system becomes unstable when applying "fix rigid/npt" |
| 154 |
# to the immobile atoms, while also applying "fix npt" on the solvent atoms. |
| 155 |
# (It is probably a bad idea to use two barostats simultaneously.) |
| 156 |
# ---------------------------------------------------------------------------- |