Hello,
I am trying to visualize forces on an active matter system with the python reference. The .gsd file is generated by hoomd and i used some custom forces to model the active matter system. These are logged in the .gsd file but since they are custom ovito doesnt label them as particles property, but lists them in the Global attributes coloumn in the app. My question is now, how to read them out from the pipeline. Or if thats not possible is there a way i can add them to the pipeline without reading them out first save them as arrays and add them then .
Greetings
Hannes
Please place your per-particle data under the log/particles/
chunk prefix. Then OVITO will load it is a particle property. Data with just a log/
prefix is loaded as global attributes.
See the remarks here: HOOMD Schema - GSD 3.4.2 documentation
Thanks for your reply. Somehow that does not fix my problem because the custom forces are already logged with a prefix /particles/engine_hoomd/my_custom_force. (engine_hoomd here is the folder where the forces are implemented in my simulation). I have no problem with the hoomd gsd reader to read out the forces. Somehow in the pipeline the forces are stored as flattened arrays in attributes “chunk” with the prefix particles/engine_hoomd/my_custom_force. So i have no idea how to change the chunk where i log the force since, only using hoomd, it appears to be right where the forces are logged.
Perhaps you can share the gsd with me. Then I can investigate in more detail what’s happening.
Currently, OVITO looks for user-defined properties only in log/particles/
, not in particles/
I suggest you take a look at the source code of the OVITO GSD file reader yourself. The part from line 269 onwards is particularly relevant, because it loads the user-defined properties. The preceding code loads all standard properties (whose chunk names start with particles/
).
Since iam not allowed to upload any files yet, i try this:
Following the HOOMD documentation at this point (Saving Array Quantities - HOOMD-blue 5.0.1 documentation) where it explains how to read out the logged data from a GSD file when i do it with mine (traj[0].log.keys()
) i get the following output: dict_keys(['particles/engine_hoomd/potentials/LymburnAlignmentForce/forces', 'particles/engine_hoomd/potentials/LymburnHomingForce/forces', 'particles/engine_hoomd/potentials/LymburnSpeedController/forces'])
which are my custom forces for the system. So iam confused since, how i understand it, see here the log dictionary which is filled with per particle (particles/
) quantities.
I also dont really get from the HOOMD documentation how i should change the chunk where my forces are logged in since the logger and writer functions given by them already puts these quantities in the right chunk, the right chunk for HOOMD at least.
If you don’t want to share your file publicly you can always email it to us at [email protected].
Thanks for sending the gsd file via email. I’ve opened the file in OVITO 3.11.3 and can now tell you what actually happens. After that, we can discuss what you would like to happen.
Like you already wrote, the file contains three log chunks with per-particle data:
log/particles/engine_hoomd/potentials/LymburnAlignmentForce/forces
log/particles/engine_hoomd/potentials/LymburnHomingForce/forces
log/particles/engine_hoomd/potentials/LymburnSpeedController/forces
OVITO uses only the last part in each path to derive a new name for the imported particle property (OVITO property names must not contains slashes). Thus, all three arrays are imported as a property named forces
, overwriting each other. Effectively, only the third forces array gets imported due to the naming conflict. You can find this property as an extra column “forces” in the data inspector panel (see screenshot).
Note that the forces
property is a user-defined property without an automatic visual representation. For OVITO, it’s just a numeric data array. To visualize the values as arrow glyphs in OVITO Basic, you can copy them over to the Force
standard property predefined by the program. This standard property has an attached visual element, which allows visualizing the vectors. The copying can be accomplished by inserting a Compute Property modifier into the pipeline as shown in the screenshot.
Let me know if you could follow these steps so far.
Thanks for your detailed reply.
At first it was thought of a test to see if the logging in HOOMD works properly and if the logged forces are properly. Now the idea is to set up a pipeline where i can choose, by a function e.g., what forces i want to be displayed. To investigate certain parameter configurations for the force terms or further analysis.
My idea for that was, since the forces are still in the pipeline object but in the global attributes folder, to read them out and add them to the pipeline explicitly for each frame. Which brings me back to the Title of this tread.
Trying to read out the array-like global attributes and transfer them to the particles is a dead end if you are using OVITO Basic, because that’s something requiring the Python capabilities of OVITO Pro.
But I’ve made code changes to the GSD file reader that will enable the direct visualization of the logged per-particle force vectors, even in OVITO Basic. The new version loads all three data arrays as user-defined particle properties (see the ‘Particles’ page of the data inspector) and, additionally, it creates 3 corresponding vector visual elements, which appear in the pipeline editor. This makes it easier to visualize the data – the Compute Property modifier is no longer needed. The visualization is dynamic of course: The force arrows get updated when you play back the trajectory animation.
You can download a preview version of OVITO Basic 3.12.0 here. Let me know if you need further help.
Thanks a lot, this is very helpful for me.