What is the function for energy calculation in fix-gcmc?

Dear Lammps developers and users,

I am learning how to use fix-gcmc and now I am trying to understand the code. Here fix-gcmc is used together with fix-nvt. Before I thought when calculating energy, both fix-nvt and fix-gcmc use

pair_lj_cut_coul_long.cpp or pair_lj_cut_coul_cut.cpp

However, after some tests, I found that maybe I was wrong. It is true that fix-nvt uses the above two cpp files, but fix-gcmc may be not. I checked the fix_gcmc.cpp file, for the case that the full energy of the system must be calculated, found that in the function of

energy_full(), the following sentence is response for energy calculation:

double total_energy = c_pe->compute_scalar();

I tried to find where is the c_pe->compute_scalar() function defined but I was lost. There are some functions related to compute_scalar(), but I do not know which one is included by “c_pe”. Actually I have not found a class named “c_pe”.

Can someone help me with this and tell me in which cpp-file the function for calculating the energy of fix-gcmc is defined?

Best,

Yongbiao

Dear Lammps developers and users,

     I am learning how to use fix-gcmc and now I am trying to understand the
code. Here fix-gcmc is used together with fix-nvt. Before I thought when
calculating energy, both fix-nvt and fix-gcmc use

pair_lj_cut_coul_long.cpp or pair_lj_cut_coul_cut.cpp

However, after some tests, I found that maybe I was wrong. It is true that
fix-nvt uses the above two cpp files, but fix-gcmc may be not. I checked the
fix_gcmc.cpp file, for the case that the full energy of the system must be
calculated, found that in the function of

energy_full(), the following sentence is response for energy calculation:

double total_energy = c_pe->compute_scalar();

I tried to find where is the c_pe->compute_scalar() function defined but I
was lost. There are some functions related to compute_scalar(), but I do not
know which one is included by "c_pe". Actually I have not found a class
named "c_pe".

Can someone help me with this and tell me in which cpp-file the function for
calculating the energy of fix-gcmc is defined?

this is not so easy to explain in an e-mail, because from your
description it appears that you first need to get a better
understanding of several C and C++ programming concepts, like
pointers, classes, object oriented programming and particularly
polymorphism.

then you can have a look at the developer guide and some of the
presentations steve did about the structure of the LAMMPS code and how
it can handle dynamically all kinds of potential functions. since
understanding C and C++ language constructs is essential for that, you
will have to work on this, if you want to understand what is going on.
you won't find the connections that you are looking for in the way you
are looking for it, as they don't exist in that form. thus your
observations and conclusions - as they currently are - don't make
sense. the situation is different.

with the full energy option, energy is computed (actually accumulated)
the same way in fix gcmc, as it is for any other calculation (which is
defined in verlet.cpp or respa.cpp or the minimizer classes, BTW).

axel.

Also, if you just want to check what is the computed value of the
energy, you can temporarily drop in lines like:

printf("In FixGCMC::energy_full() total_energy = %g \n",total_energy);

When you run the simulation, every MPI process will print that line to
the screen output every time energy_full() is visited. So it is best
to do this with just a single MPI process and just a few iterations of
fix gcmc.

Aidan