Understanding rmass

Dear LAMMPS users,

I’m struggling to understand atom.rmass.

The documentation and a previous thread (https://lammps.sandia.gov/threads/msg22749.html) tell me that it is a per-atom mass, and is used when using atoms of type sphere.

However, when writing a custom pair potential, and applying it to atoms of type sphere, I find that the contents of double *rmass = atom->rmass in the .cpp file, I get an array of what appears to be garbage values.

I am initialising my system by reading from a data file which sets unit densities and varying diameters, before setting the mass in the input file with “set atom * mass 1”, which I believe sets a per-atom mass (https://lammps.sandia.gov/doc/set.html).

If I output the masses in my dump file, I get the masses I am expecting to get, suggesting that rmass is not the relevant mass array in my case. I don’t understand why it isn’t, and would like to remedy this lack of understanding.

I find the same behaviour if I edit the colloid potential to print rmass and run the colloid example.
However, if I print rmass in the granular example, I do not get garbage.

Would someone be able to help me understand what determines which mass array is the relevant mass array?

Best wishes,
Rahul

Dear LAMMPS users,

I’m struggling to understand atom.rmass.

The documentation and a previous thread (https://lammps.sandia.gov/threads/msg22749.html) tell me that it is a per-atom mass, and is used when using atoms of type sphere.

However, when writing a custom pair potential, and applying it to atoms of type sphere, I find that the contents of double *rmass = atom->rmass in the .cpp file, I get an array of what appears to be garbage values.

are you sure, you are accessing that array correctly? please note, that the atom indexing in the local, distributed data like rmass, x, f, tag and so on is different from the atom id (which is stored in atom->tag).

I am initialising my system by reading from a data file which sets unit densities and varying diameters, before setting the mass in the input file with “set atom * mass 1”, which I believe sets a per-atom mass (https://lammps.sandia.gov/doc/set.html).

If I output the masses in my dump file, I get the masses I am expecting to get, suggesting that rmass is not the relevant mass array in my case. I don’t understand why it isn’t, and would like to remedy this lack of understanding.

i disagree with your logic.

I find the same behaviour if I edit the colloid potential to print rmass and run the colloid example.
However, if I print rmass in the granular example, I do not get garbage.

Would someone be able to help me understand what determines which mass array is the relevant mass array?

you can access the atom->rmass array when atom->rmass_flag is non-zero and you may not, if it is zero.
you can find these tests all over the LAMMPS code where, e.g. fixes or compute, need to access particle masses.
also, if the rmass array is not set up, you will get not “garbage” but a segmentation fault, as atom->rmass will then be NULL.

axel.