Potential energy in replica exchange

Dear all,
I am trying to use parallel tempering method to improve my sampling. I also want to couple the replica exchange with umbrella sampling bias potential in each window. Currently, my US utilizes the 'fix restrain" with “fix_modify energy yes”. The question is when LAMMPS decides the swap by Metropolis criterion, will it include the bias potential?
Thanks in advance for any suggestions.

I don’t know. You better set up a simple test.

Is there a way that I can let LAMMPS print out the random number used in Metropolis?

You have to modify the source code to add log statements and then recompile.

I am not quite familiar with C++. I am quoting the section in “temper.cpp”:

      if (me_universe < partner)
        printf("SWAP %d & %d: yes = %d,Ts = %d %d, PEs = %g %g, Bz = %g %g\n",

I guess this is related to the random number. How should I modify it? Many thanks.

Then you should find somebody local that is and can assist you directly.

If you are asking to enable this output: there is a comment at the top of the file with a define. If you remove the comment characters ‘//’ and recompile, this conditionally compiled code will be included.

If you want instructions on how to further adjust this, you would be asking for somebody else doing what is essentially your work. That means, that you are asking for somebody to collaborate with you. This is beyond the scope of this forum.

My advice is the same as above: best find somebody local that is willing to either collaborate with you or tutor you so that you can do the work (= hacking) yourself.

Just want to update my test and keep a record in case any others are interested in this question in the future.
From my logfile:

Step T0 T1 T2 T3
0 0 1 2 3
SWAP 0 & 2: yes = 0 0.880702,Ts = 0 1, PEs = 50.703 52.1793, Bz = -0.11947 0.887391
100 0 1 3 2

At step 100, LAMMPS tried to swap T0 (298K) with T1(313K).

Logfile for T0:

Step Temp KinEng PotEng TotEng f_REST
0 342.86502 70.51907 54.86158 125.38065 5.7228963
100 311.54368 64.077026 50.703039 114.78006 0.062730585

Logfile for T1:

Step Temp KinEng PotEng TotEng f_REST
0 342.86502 70.51907 54.86158 125.38065 5.7228963
100 319.03015 65.616811 52.179325 117.79614 0.067139898

I have used “fix_modify energy”, so my PotEng contains the bias potential.

Based on the Pmin{1, exp( (E0-E1)(1/kT0 - 1/kT1) )}, at step 100:
(E0-E1) = -1.4763
(1/kT0 - 1/kT1) = 0.080926
(E0-E1)(1/kT0 - 1/kT1) = -0.1194711
exp((E0-E1)(1/kT0 - 1/kT1)) = 0.8873896

The random number generated by LAMMPS at step 100 is 0.880702, which is smaller than exp((E0-E1)(1/kT0 - 1/kT1)). So the attempt to swap failed. All the numbers are consistent.

Take away point: after using “fix_modify energy yes”, the bias potential will be included in the Metropolis swap during the replica exchange. The “temper” in LAMMPS can be coupled with umbrella sampling, thus there should be no problem of using replica-exchange umbrella sampling (REUS).


Thanks for reporting back so that others can benefit from your tests.