Hi,
I am trying to output the per-particle virial of a simulation to a GSD file. As discussed in a post from another user I made sure to flag hoomd to calculate the net_virial so it actually calculates the virial per particle.
In the documentation for hoomd.dump.gsd and under "User-defined log quantities" it says to "Associate a name with a callable python object that returns a numpy array in log, and gsd will save the data you provide on every frame."
I tried adding a name 'particles/forces' to log via hoomd.analyze.log and then defining 'particles/forces' through the register_callback method. I associated 'particles/forces' with a function that returns an array of the virial of each particle using system.particles[i].net_virial and iterating over all particles. However, on each step that the quantities should be outputted, I receive the warning "*Warning*: analyze.log: Log callback particles/forces returned invalid value, logging 0."
If I instead associate these names with functions that return scalars or 1x1 numpy arrays via set_callback, this warning disappears. Looking at the source code, it appears that the output of the callable python object is being cast into a "scalar" and printing that warning message if it cannot be cast into a scalar.
Is it possible to log arrays of per-particle data, as the documentation in hoomd.dump.gsd suggests? If so, how can I do it?
Much thanks,
Luke