Skip to content

Getting a CustomCentroidBondForce error when attempting to add RadiusOfGyrationSq to system. #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dsclassen opened this issue Apr 3, 2025 · 0 comments

Comments

@dsclassen
Copy link

dsclassen commented Apr 3, 2025

I'm seeing an error when I attempt to implement RadiusOfGyrationSq

# Add custom CV for radius of gyration
num_atoms = system.getNumParticles()
print(f"Number of atoms in system: {num_atoms}")
rgsq = cvpack.RadiusOfGyrationSq(list(range(num_atoms)),pbc=False ,weighByMass=False, name="RadiusOfGyrationSq")
rgsq.addToSystem(system)

# Create integrator
timestep = 0.001 * picoseconds
print(f"Using timestep: {timestep}")
integrator = VerletIntegrator(timestep)

# Load previous state (restart)
with open(os.path.join( heat_dir, heated_restart_file_name), encoding="utf-8") as f:
    state = XmlSerializer.deserialize(f.read())

# Create simulation
simulation = Simulation(modeller.topology, system, integrator)
simulation.context.setState(state)

and this is the error:

Number of atoms in system: 8234
Using timestep: 0.001 ps
Traceback (most recent call last):
  File "/Users/classen/projects/openmm-test/scripts/md.py", line 81, in <module>
    simulation = Simulation(modeller.topology, system, integrator)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/classen/miniconda3/envs/openmm/lib/python3.12/site-packages/openmm/app/simulation.py", line 102, in __init__
    self.context = mm.Context(self.system, self.integrator)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/classen/miniconda3/envs/openmm/lib/python3.12/site-packages/openmm/openmm.py", line 2488, in __init__
    _openmm.Context_swiginit(self, _openmm.new_Context(*args))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
openmm.OpenMMException: CustomCentroidBondForce: Weights for group 3132 add to 0

I am defining other restraints earlier in the md.py file, but if I comment out rgsq.addToSystem(system) then the simulation runs without error.

p.s. I am using a version of this Rigid Body code which may be interfering with cvpack?

https://github.com/openmm/openmm/blob/master/examples/extras/rigid.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant