1) There is no need to use setforce. You can apply "fix npt" or "fix
nvt" to the "free" (mobile) group of atoms instead of group "all".
2) At constant pressure I recommend using "neigh_modify exclude group
fixed fixed" improves (but does not completely fix) the virial. (But
doing that and using "fix rigid" seems to work well.)
3) In a reply to a recent post last week:
http://sourceforge.net/mailarchive/message.php?msg_id=30018547
I posted an input script which immobilized a large solute:
http://www.moltemplate.org/examples/translocation/run.in.npt
In particular, the relevant portion of that script is below:
----------- excerpt: -----------
fix 1 fixed rigid single force * off off off torque * off off off
#(Neither Trung or Steve Plimpton use fix rigid for immobilizing objects, but
# I noticed that at NPT, it does a significantly better job of maintaining
# the correct volume)
neigh_modify exclude group fixed fixed
compute tempFree free temp
compute pressFree all pressure tempFree
thermo_style custom step c_tempFree c_pressFree temp press vol
# Set temp=300K, pressure=500bar, anisotropic equilibration
fix 2 free npt temp 300 300 100 aniso 500 500 1000.0 dilate free
fix_modify 2 temp tempFree
-------- end of excerpt -------
(Small changes: in the excerpt above I renamed the groups to "fixed"
and "free", to match the immobile and mobile groups in your example.
Credit goes to Trung who instructed me to use "fix_modify" to use the
temperature computed from the mobile group of atoms. I hope I am
reproducing it correctly here.)
Cheers
Andrew
P.S.
---- Regarding the virial: ----
If you want to keep the coordinates of the rigid atoms from being
expanded or compacted as the volume is increased or decreased, you
should use "dilate free", as I did above. In that case, only the
positions of the free atoms will be rescaled.
Under the hood, this requires a modification to the virial: all of the
forces acting on the immobilized "fixed" atoms must be excluded from
the virial. (Or equivalently, the constraint forces used to keep the
object motionless should be included in the virial. Perhaps this is
more intuitive way to think about the issue: All the forces acting on
all the particles must be included in the virial, including the
constraint forces. I attached a quick proof I wrote to motivate this
to myself a year ago but it's not very well written. In any case,
"neigh_modify exclude group fixed fixed" only eliminates forces
between atoms within the "fixed" group. This helps but it does not
eliminate contributions to the virial from the remaining mobile "free"
atoms acting on the fixed atoms.)
However the above combination of "neigh_modify exclude group fixed
fixed" AND "fix rigid" seems to work.
The post at:
http://sourceforge.net/mailarchive/message.php?msg_id=30018547
includes a discussion of the pros and cons of this approach.
Cheers again
Andrew
virial_immobile_atoms_sm.pdf (101 KB)