Replies: 1 comment
-
You don't provide a full minimal working example, so I can only guess. You appear to be taking all the needed steps:
There are many moving parts to your code. To troubleshoot, you need to break the problem in to smaller parts.
These tests will help you narrow down whether the problem is with the A minimal working example should use |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
since the code iam using is quite long and seperated over multiple files iam reproducing the important lines.
So my problem is that i have a simulation running with multiple custom forces using the
hoomd.md.force.Custom
class and now i am willing to log the forces each for its own. To create a GSD file where all the different forces per time step are listed. I implemented a logger follwing the documentation(https://hoomd-blue.readthedocs.io/en/latest/tutorial/02-Logging/02-Saving-Array-Quantities.html) in the following way:class custom_force(hoomd.md.force.Custom):
(here just how the force is defined according to the documentation. This already works since the simulation is running and yielding the right output.)
def force_writer(config:dict, cell: hoomd.md.nlist, filename='forces.gsd'):
then there is a simulation class where i add and call the writer like this
self.gsd_force_writer = setup_force_writer(self.config,
setup_nlist(self.config),
f"{self.output_path_no_ext}_force.gsd")
self.simulation.operations.writers.append(self.gsd_force_writer)
self.gsd_force_writer.flush()
the GSD file actually is generated but when i try
traj = gsd.hoomd.open("forces.gsd", mode="r")
traj[0].log.keys()
i get
dict_keys([])
as output. Somehow this also happens for the trajectory GSD file, however when i convert it to a H5 file the file includes the trajectory.
Iam not sure now if i have to add a loggable to my custom force or if the force defined in the class like
class custom_force(hoomd.md.force.Custom):
def set_forces(self, timestep):
with self.cpu_local_force_arrays as arrays:
arrays.force[:] =...
is already logged as quantitiy=["forces"]. Would be nice if somone knows anything about it. It would also be helpful if i need some other type of command to verify if there is something written in the GSD file.
Beta Was this translation helpful? Give feedback.
All reactions