| 1 |
# PREREQUISITES: |
| 2 |
# |
| 3 |
# You must use moltemplate.sh to create 4 files: |
| 4 |
# system.data system.in.init system.in.settings system.in.charges |
| 5 |
# (Follow the instructions in README_setup.sh, |
| 6 |
# or run the file as a script using ./README_setup.sh) |
| 7 |
|
| 8 |
# ------------------------------- Initialization Section -------------------- |
| 9 |
|
| 10 |
include system.in.init |
| 11 |
|
| 12 |
# ------------------------------- Atom Definition Section ------------------- |
| 13 |
|
| 14 |
read_data system.data |
| 15 |
|
| 16 |
# ------------------------------- Settings Section -------------------------- |
| 17 |
|
| 18 |
include system.in.settings |
| 19 |
include system.in.charges |
| 20 |
|
| 21 |
# ------------------------------- Run Section ------------------------------- |
| 22 |
|
| 23 |
# Explanation. |
| 24 |
# Unless you use packmol (or some other geometry generation program), |
| 25 |
# the initial geometry created by moltemplate using a lattice is |
| 26 |
# extremely unrealistic for a liquid, and likely to put the system |
| 27 |
# a kinetic trap (local minimum). So this example uses high temperatures |
| 28 |
# to completely obliterate any memory of that initial lattice shape. |
| 29 |
# Then it uses a combination of high pressures and cooling to bring |
| 30 |
# the system back down to a temperature and density of a liquid at 1atm, 300K. |
| 31 |
|
| 32 |
# I am using a 4-step equilibraion process (expand, minimize, |
| 33 |
# reorient, compress). The system (as defined in the "system.data" file) |
| 34 |
# is already expanded. That means there are 3 steps left: |
| 35 |
|
| 36 |
dump dumpeq1 all custom 50 traj_eq1_min.lammpstrj id mol type x y z ix iy iz |
| 37 |
thermo_style custom step temp ke pe etotal epair ebond eangle edihed press vol |
| 38 |
thermo 50 |
| 39 |
|
| 40 |
# -- Equilibration: part 1: initial minimization -- |
| 41 |
|
| 42 |
# Note: In general, it's always a good idea to minimize the system at first. |
| 43 |
|
| 44 |
minimize 1.0e-5 1.0e-7 100000 400000 |
| 45 |
undump dumpeq1 |
| 46 |
|
| 47 |
write_data system_after_eq1_min.data |
| 48 |
|
| 49 |
# -- Equilibration part 2: reorienting the molecules (NVT) -- |
| 50 |
|
| 51 |
timestep 1.0 |
| 52 |
dump dumpeq2 all custom 200 traj_eq2_reorient.lammpstrj id mol type x y z ix iy iz |
| 53 |
|
| 54 |
# Run the system at high temperature (at constant volume) to reorient the |
| 55 |
# the molecules (which would otherwise be pointing in the same direction). |
| 56 |
|
| 57 |
# To speed it up, I randomize the atomic positions for a few thousand steps |
| 58 |
# using fix langevin (and fix nve). Then I switch to fix nvt (Nose-Hoover). |
| 59 |
# (If I start with fix nvt (Nose-Hoover), it seems to get "stuck" for a while.) |
| 60 |
|
| 61 |
# Give each atom a random initial velocity consistent with a system at 900K. |
| 62 |
velocity all create 900.0 12345 |
| 63 |
|
| 64 |
# Run a short simulation using a Langevin thermostat. |
| 65 |
|
| 66 |
fix fxlan all langevin 900.0 900.0 120 48279 |
| 67 |
fix fxnve all nve |
| 68 |
|
| 69 |
run 4000 |
| 70 |
|
| 71 |
unfix fxlan |
| 72 |
unfix fxnve |
| 73 |
# Now continue the simulation at high temperature using fix nvt (Nose-Hoover). |
| 74 |
fix fxnvt all nvt temp 900.0 900.0 100.0 |
| 75 |
|
| 76 |
run 50000 |
| 77 |
undump dumpeq2 |
| 78 |
|
| 79 |
|
| 80 |
write_data system_after_eq2_reorient.data |
| 81 |
|
| 82 |
unfix fxnvt |
| 83 |
|
| 84 |
# -- equilibration part 3: Equilibrating the density (NPT) -- |
| 85 |
|
| 86 |
# Originally, the simulation box (in "system.data" and "system.lt") was |
| 87 |
# unrealistically large. The spacing between the molecules was large also. |
| 88 |
# I did this to enable the molecules to move freely and reorient themselves. |
| 89 |
# After doing that, we should run the simulation under NPT conditions to |
| 90 |
# allow the simulation box to contract to it's natural size. We do that here: |
| 91 |
# To help it collapse, we begin the simulation at a relatively high pressure |
| 92 |
# Later on, we will slowly decrease it to 1 bar. |
| 93 |
|
| 94 |
# First cool the system. (Do this at high pressure to avoid bubble formation.) |
| 95 |
|
| 96 |
dump dumpeq3 all custom 200 traj_eq3_npt.lammpstrj id mol type x y z ix iy iz |
| 97 |
fix fxnpt all npt temp 900.0 260.0 100.0 iso 500.0 500.0 1000.0 drag 2.0 |
| 98 |
|
| 99 |
timestep 1.0 |
| 100 |
run 20000 |
| 101 |
|
| 102 |
# At the very end of the previous simulation, the temperature dropped below |
| 103 |
# the boiling point. Run the simulation for longer at these conditions to |
| 104 |
# give it a chance for the vapor -> liquid transition to complete. |
| 105 |
# We will also slowly decrease the pressure to 1 bar. |
| 106 |
|
| 107 |
unfix fxnpt |
| 108 |
fix fxnpt all npt temp 260.0 260.0 100.0 iso 500.0 1.0 1000.0 drag 2.0 |
| 109 |
|
| 110 |
timestep 1.0 |
| 111 |
run 100000 |
| 112 |
|
| 113 |
write_data system_after_eq3_npt.data |
| 114 |
|