# -- Init Section --

include system.in.init

# -- Atom Definition Section --

read_data system.data

# -- Settings Section --

include system.in.settings

# -- Run Section --


timestep        1.0
dump            1 all custom 500 traj_npt.lammpstrj id mol type x y z ix iy iz

thermo_style    custom step temp pe etotal press vol epair ebond eangle edihed
thermo          500  # time interval for printing out "thermo" data


velocity groupB zero angular
velocity groupB zero linear
# (I'm not sure if the two lines above are necessary, but they don't hurt.)

# Only the groupB atoms are immobile.

group mobile subtract all groupB

# ------------------------- NPT ---------------------------

# Set temp=300K, pressure=500bar, and equilibrate volume only in the z direction

fix fMoveStuff mobile npt temp 300 300 100 z 500 500 1000.0 dilate mobile

#  ------ QUESTIONABLE (see below): ------

fix Ffreezestuff groupB rigid/npt single temp 300 300 100 z 500 500 1000.0 force * off off off torque * off off off dilate mobile

#     -- Alternate npt rigid method --
# I'm not sure which way is more correct, however 
# this also seems to behave in a reasonable-looking way:
#fix Ffreezestuff groupB rigid single force * off off off torque * off off off dilate mobile
#
# The use of either "fix rigid" or "fix rigid/npt" to immobilize
# an object is somewhat controversial.  Feel free to omit it.
#(Neither Trung or Steve Plimpton use rigid or rigid/npt for immobilizing 
#molecules, but I noticed that at NPT, it does a better job of maintaining 
# the correct volume. However "fix rigid" has changed since then (2011), 
# so this may no longer be true.  Please use this example with caution.)
#  ----------------------------------------

# IMPORTANT for NPT: You must use "neigh_modify" to turn off calculation of the
#                    forces between immobilized atoms.
neigh_modify exclude group groupB groupB

# The next two lines recalculate the temperature 
# using only the mobile degrees of freedom:

compute tempMobile mobile temp
compute pressMobile all pressure tempMobile

thermo_style custom step c_tempMobile c_pressMobile temp press vol

fix_modify fMoveStuff temp tempMobile

run             60000

write_restart  system_after_npt.rst
