SSAGESproject / SSAGES

Software Suite for Advanced General Ensemble Simulations
GNU General Public License v3.0
81 stars 28 forks source link

Why are the "Evaluate" function called two times ? #27

Closed wxsongsh closed 3 years ago

wxsongsh commented 3 years ago

Dear SSAGES Developers,

When I run the example in the SSAGES-0.9.2-alpha/Examples/User/Meta/ADP (SSAGES combined with lammps), I found that the "Evaluate" function in the TorsionalCV.h file is called two times at each step. As a testing, I added a simple std::cout<<"testing"<<'\n'; sentence in the "Evaluate" function.

As I know, this function calculate both the value and gradient of the CV in the post-integration phase of every iteration. Why is the "Evaluate" function called two times at every iteration?

Looking forward to you repy. Thanks!

mquevill commented 3 years ago

The example input JSON file at https://github.com/SSAGESproject/SSAGES/blob/release-0.9/Examples/User/Meta/ADP/Meta.json defines 2 different torsional CVs, commonly known as "phi" and "psi" in peptides. When plotted together, these are known as a Ramachandran plot. (Example here: https://github.com/SSAGESproject/SSAGES/blob/release-0.9/Examples/User/ABF/Example_AlanineDipeptide/Sample_Outputs/G_EnergySurface.png)

If you modify the input JSON file to only define one torsional angle, it should only call Evaluate() once per iteration. Both the value and the gradient are calculated in the same call to Evaluate().

[Additionally, if you are running with MPI, a standard std::cout call will be printed for every process. So mpirun -np 4 ./ssages Meta.json would print "testing" 4 times per iteration.]

wxsongsh commented 3 years ago

Thanks. I get it.

For the MPI, I do it like this: int meme; MPI_Comm_rank(MPI_COMM_WORLD,&meme); if(meme==0) { std::cout<<snapshot.GetIteration()<<" steps"<<'\n'; ... }