I was trying to modify the pair_dpd source code to a pairwise force that will shift its coefficient if the interaction between the two atoms is activated, which is dependent on how long the two atoms are together within a close distance.
I wrote some statements in the compute and coeff functions, as well as some necessary modifications in other places. I am about to compile it, but really not sure about the scope of the input coefficients as doubles defined in coeff(), as I have to use them in my compute().
Also, I am not sure where does the Single() get the coefficient. My coeff[i][j] is not given a value in coeff() but assigned in compute(). I hope Single() will get coeff[i][j] as the same value as the one from compute().
I have attached the cpp and header files.
Thank you in advance,
pair_plat.cpp (11.4 KB)
pair_plat.h (2.12 KB)
There are lots of issues with your code. For starters, it doesn’t even compile due to very obvious typos.
But also, you are confusing arrays that are indexed by atom type with arrays that are indexed by local atom index and you are assuming that the local index will always refer to the same atom (i.e. with the same atom id or atom->tag value), which is not true either since atoms migrate between subdomains and are resorted occasionally.
if you need to store data from previous time steps, you need to also manage its communication when atoms are exchanged, this is best done by importing a custom property from a fix property/atom instance, which will do that communication for you. but you also need to consider that the same atom (i.e. atom with the same atom id or tag) may be present multiple times (when the system cell is small and the communication cutoff correspondingly large).
but you don’t need to worry about the single method, it is only used for some special features in LAMMPS. usually setting single_enable = 0 in the pair style constructor (and then deleting that function from implementation and header file) is sufficient. then those features using the single() method will abort with an error that this pair style is not supported.