Page 1 of 1

Freezing atom positions

Posted: Tue Apr 04, 2023 8:26 am
by hnadeem2
I have a 5 residue system with MET at each end and I want to freeze the sulfur atom positions. As per this post : https://github.com/openmm/openmm/issues/2665, and a couple of other ones, the only solution provided was to set the mass to zero.
I have tried that and it did not work for me, could that be because sulfur atoms are covalently-bonded to other atoms which are subject to forces?
I have tried a custom force using a harmonic potential to squeeze the atoms in that narrow potential and it has worked, but I was wondering why the setting the mass to zero does not work instead.

Best,
Hassan

Re: Freezing atom positions

Posted: Tue Apr 04, 2023 9:07 am
by peastman
In what way did it not work? If an atom is massless, it won't move. It doesn't matter what element it is or what it's bonded to.

Remember that you need to set the mass before creating the Simulation/Context. Once the Context is created, any further changes to the System are ignored.

Re: Freezing atom positions

Posted: Tue Apr 04, 2023 3:30 pm
by hnadeem2
The atoms seem to be moving in the simulation.

I used the following code to set the SD atoms mass to zero before creating the Simulation object

Code: Select all

    totalrestrainedatoms=['SD']
    for i, atom_crd in enumerate(parm.positions):
      if parm.atoms[i].name in totalrestrainedatoms:
        system.setParticleMass(i, 0.0)

Re: Freezing atom positions

Posted: Tue Apr 04, 2023 4:01 pm
by hnadeem2
I figured it out, thanks.
My mistake was loading a checkpoint file after setting the masses to zero.

Re: Freezing atom positions

Posted: Tue Apr 04, 2023 4:29 pm
by peastman
Can you post your full script, along with any input files needed to reproduce it?