User-Defined Fixes

Hi everyone,

(This message is a duplicate because the formatting on my previous post got mangled somehow)

I’m writing to ask for some advice in making a few modifications to the LAMMPS source code,
most likely in the form of new fixes. In particular, I’m using LAMMPS to handle the classical
integration in a new quantum-classical methodology. The model I’m studying involves proton
transfer in a polar solvent, where the proton is treated as the relevant quantum mechanical sub-
system, while the rest of the transfer complex and the solvent is classical.

In this approach, what I need LAMMPS to do is:

1.) Provide the electrostatic potential felt by the proton for a given solvent configuration at two
different locations along its reaction path as output at each time step.
2.) Propagate the solvent under the average electrostatic force of the proton in both of these
configurations.

The first item is relatively straightforward, since I can get the potential energy from pre-existing
fixes, and set the proton at the proper location, then use a “run 0” command to get the output I
need, provided I use repeated “run 1” commands to propagate the system one step at a time. The
second item is where the issue arises, since it seems that MD packages don’t typically calculate
this type of average force.

My current idea to solve this is to define a post-force fix which can be called after the forces are
initially calculated to correct them from a single-configuration force to an average. However, in
poking through the code, I noticed that the Verlet::Setup() method doesn’t call the post-force fixes,
and since I’m stepping through the integration with multiple “run 1” commands, this will get
called each time (assuming I understand the program flow correctly), which would leave my first
half Verlet step with incorrect forces.

I was wondering if anyone had a suggestion for how I could address this issue. I realize that using
“pre no” on top of the run command might help, since the correctly-calculated forces from the
Verlet::Run() method should carry over then, but I’ve found that using this command seems to
change the trajectories I get out, at least for my system. The only other ideas I have are to try and
incorporate the potential calculation into the fix and run it automatically at each time step, to get
around the repeated use of “run 1” commands, or to add a line to call my fix in Verlet::Setup(), but
I’d like to avoid modifying core routines if at all possible.

Thanks for your time,
Thomas Allen
Makri Group
UIUC

Hi everyone,

(This message is a duplicate because the formatting on my previous post got
mangled somehow)

I'm writing to ask for some advice in making a few modifications to the
LAMMPS source code,
most likely in the form of new fixes. In particular, I'm using LAMMPS to
handle the classical
integration in a new quantum-classical methodology. The model I'm studying
involves proton
transfer in a polar solvent, where the proton is treated as the relevant
quantum mechanical sub-
system, while the rest of the transfer complex and the solvent is classical.

In this approach, what I need LAMMPS to do is:

1.) Provide the electrostatic potential felt by the proton for a given
solvent configuration at two
different locations along its reaction path as output at each time step.
2.) Propagate the solvent under the average electrostatic force of the
proton in both of these
configurations.

The first item is relatively straightforward, since I can get the potential
energy from pre-existing
fixes, and set the proton at the proper location, then use a "run 0" command
to get the output I
need, provided I use repeated "run 1" commands to propagate the system one
step at a time. The
second item is where the issue arises, since it seems that MD packages don't
typically calculate
this type of average force.

My current idea to solve this is to define a post-force fix which can be
called after the forces are
initially calculated to correct them from a single-configuration force to an
average. However, in
poking through the code, I noticed that the Verlet::Setup() method doesn't
call the post-force fixes,
and since I'm stepping through the integration with multiple "run 1"
commands, this will get
called each time (assuming I understand the program flow correctly), which
would leave my first
half Verlet step with incorrect forces.

I was wondering if anyone had a suggestion for how I could address this
issue. I realize that using
"pre no" on top of the run command might help, since the
correctly-calculated forces from the
Verlet::Run() method should carry over then, but I've found that using this
command seems to
change the trajectories I get out, at least for my system. The only other

you should try to find out why.

ideas I have are to try and
incorporate the potential calculation into the fix and run it automatically
at each time step, to get
around the repeated use of "run 1" commands, or to add a line to call my fix
in Verlet::Setup(), but
I'd like to avoid modifying core routines if at all possible.

if you think you would need to use a lot of run 0/1 statements then i
would interpret that as a sign that you need to write your own
integrator, i.e. a modified version of verlet.cpp for example.

if the basic principle of your calculation is to propagate on the
average of two (or more) configurations, then probably you should do
this using two (or more) replica (e.g. like parallel replica MD). it
takes a bit more effort to set up initially, but will become easier to
maintain in the long run.

axel.

I noticed that the Verlet::Setup() method doesn’t
call the post-force fixes,

V::setup() does call the setup() method of all
the fixes. And that method can call post_force().
Several fixes do this, e.g. fix_setforce.cpp.

I don’t really understand what you’re trying to do,
but if you are trying to maintain 2 (or more) replicas
of the system, then doing it like LAMMPS allows
with “partitions” for the different replicas could make
your life easier. E.g. the neb command maintains
N different replicas, which are like a path that the
dynamics relaxes along.

Steve

Thank you, Steve and Axel, for your prompt replies.

I think I have a better idea of how to create the correct fix now.

-Thomas