Implementing a field theory interaction add-on

Hi all,
I have started to do some development on this project by making it a child class of PPPM. I have been able to modify modify_params in kspace.cpp to be able to accept a new parameter as well as actually invoke my new class using kspace_style tild (tild is the name of my new class). However, I still have a few questions before I can really move forward.

I have a few questions regarding compute group/group and its use of kspace.1. Where is the compute group/group invoked/executed? I figured it gets called because of ComputeStyle(group/group, ComputeGroupGroup) but can’t find where group/group is actually evaluated/processedp. Is there an equivalent string comparison for invoking compute functions?

  1. How (and where) does CompGroupGroup class invoke the kspace::compute_group_group function?
  2. Can one kspace_style be used with multiple compute functions, and if so, can you specify an interaction parameter (float) as an argument that would be used during the compute function?
  3. Is there a way to force the amount of grid points for the FFT and the grid points for the PPPM are exactly the same? If I force them to be the same, I think it would be easier to convolve the density fields.
  4. Lastly, would the modification of the checks for the modify_params rountine count as a trivial change to the core code?

Thanks in advance,
Christian

Hi all,
I have started to do some development on this project by making it a child class of PPPM. I have been able to modify `modify_params` in kspace.cpp to be able to accept a new parameter as well as actually invoke my new class using `kspace_style tild` (tild is the name of my new class). However, I still have a few questions before I can really move forward.

i don't think that this is a good idea. from your posts, i didn't
really understand what it is that you want to implement, but it seems
that is different from other kspace styles in LAMMPS. only that you
want to use the density->FFT->convolution->FFT->apply potential
paradigm.
PPPM is set up to complement pair styles with coul/long to have a full
treatment of coulomb interactions. there are checks for it, so that it
seems much more reasonable to derive from Kspace directly (PPPMDisp,
which add long-range treatment for the (1/r)^6 term to PPPM does so
instead of deriving from PPPM. but another important question is:
since there can be only one kspace style at a time, so how would your
kspace style coexist with potentials requiring long-range coulomb?
...and if you have a solution for that, would your additional feature
*require* long-range coulomb (and a matching complementary short-range
pair style)?

I have a few questions regarding `compute group/group` and its use of kspace.

Where is the `compute group/group` invoked/executed?

of course in compute_group_group.cpp in the function
ComputeGroupGroup::kspace_contribution() which calls
force->kspace->compute_group_group()

I figured it gets called because of `ComputeStyle(group/group, ComputeGroupGroup)` but can't find where `group/group` is actually evaluated/processedp. Is there an equivalent string comparison for invoking compute functions?

no. LAMMPS uses polymorphism.

How (and where) does CompGroupGroup class invoke the kspace::compute_group_group function?

have you head of a tool called "grep"?

$ grep -n compute_group_group compile/lammps/src/compute_group_group.cpp
22:#include "compute_group_group.h"
336: force->kspace->compute_group_group(groupbit,jgroupbit,0);
346: force->kspace->compute_group_group(groupbit,jgroupbit,1);

Can one kspace_style be used with multiple compute functions, and if so, can you specify an interaction parameter (float) as an argument that would be used during the compute function?

yes and no. there must be only one function called "compute()" and its
arguments cannot be changed, or you would violate the requirements of
polymorphism unless you change *all* compute functions, which is not
likely going to happen. you can - of course - have a regular compute()
function that calls other compute functions depending on some global
setting stored in your class.

Is there a way to force the amount of grid points for the FFT and the grid points for the PPPM are exactly the same? If I force them to be the same, I think it would be easier to convolve the density fields.

i don't understand the question. the grid for density and the field
are "local" grids that stretch across the individual subdomain owned
by each MPI rank. they have to be communicated/redistributed into
"sticks" or "pencils" for the parallel(!) FFTs, since for an FFT data
must be continuous in one direction. hence the parallel 1-d FFT must
be followed (in the simple case) with a transpose, then another FFT
and another transpose and the final forward FFT, to have the data in
reciprocal space for the convolution to determine the derivative. and
then - of course - the process must be reversed.

Lastly, would the modification of the checks for the modify_params rountine count as a trivial change to the core code?

yes. but at this point, i believe there are much more serious
conceptional issues, that need to be addressed. what you are asking
and how you seem to be looking at the code is making me worry a lot
about your approach and your difficulties of reading and understanding
existing code.

axel.

For those interested, my in-house code does the following:

  1. For each molecule, add it to its respective rho field using a particle to mesh scheme (A homopolymers and A molecules on an AB diblock get added to the same rho field).

  2. FFTW-MPI the densities and multiply them by a FFTW-MPI of a Gaussian potential gradient (perform a convolution).

  3. Inverse the convolution back to real space and multiply it by the appropriate \chi parameter and the average density of the system.

  4. Add this result in the gradient field for each monomer type.

  5. Repeat steps 2-4 for every interaction between types of molecules (chiAB, chiAC, chiBC, etc.)

  6. Multiply the accumulated gradients for each field by the grid weight for each monomer.
    Based on this description, it does sound like a Kspace style of computation (as opposed to a fix with a post_force() method).
    Can you use this with one or more of the standard pair styles as-is, or does the short-range part need to be modified,
    similar to the pair coul/long potentials?

My suggestion would be that you do not derive a new class from PPPM, but just create
a new KSpace style class, e.g. a sibling to PPPM, MSM, etc.

You may end up copying a lot of PPPM code into your class, but you may also
end of modifying basically every method in PPPM.

Once you have the stand-alone class working, then you can figure out
whether to keep it stand-alone or make it derive from PPPM, based on how
much duplicate code and methods there are. Iintially I suggest you
not be constrained by the way PPPM is written. Doing things like
step 5 imply different data structures and logic.

I also suggest you put your new command(s) in a package, e.g. USER-FIELD or the like.

Steve

My apologies. I did not notice the response.

Axel:
Thank you for your comments.

The condition about having one kspace style is something we were concerned about on our end as well.

Ideally, I would like this added functionality to be able to be used alongside Coulomb interactions since I know of people who combine what I seek to implement with Coulomb interactions.

Having our new functionality set as a kspace style would complicate things, hence my concern.

If we were to bring over the PPPM(Disp) functionality (the mesh scheme, fourier transform, etc) into another class type, what would you recommend?

Also, in hindsight, I realized some of my questions from the previous email were premature since I was able to eventually find the answers and better understand some mechanisms (such as the grid points and changing between the two sets of grid points).

Steve:
This does involve long range calculations based off kspace. I forgot to include the final step where the gradient is then applied to the monomers based off the grid weights. Nevertheless, the main routine is the same.

If this were to be classified as a kspace style, what would be the best way to have this integrate with Coulomb kspace styles? Would having a second kspace style pointer be a solution?

Storing the new commands in a USER package makes sense; I don’t know how to specifically make another package but that’s a concern for later down the road.

Christian