Freezing atom positions

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Hassan Nadeem
Posts: 11
Joined: Tue Apr 04, 2023 8:20 am

Freezing atom positions

Post by Hassan Nadeem » Tue Apr 04, 2023 8:26 am

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

User avatar
Peter Eastman
Posts: 2611
Joined: Thu Aug 09, 2007 1:25 pm

Re: Freezing atom positions

Post by Peter Eastman » Tue Apr 04, 2023 9:07 am

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.

User avatar
Hassan Nadeem
Posts: 11
Joined: Tue Apr 04, 2023 8:20 am

Re: Freezing atom positions

Post by Hassan Nadeem » Tue Apr 04, 2023 3:30 pm

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)

User avatar
Hassan Nadeem
Posts: 11
Joined: Tue Apr 04, 2023 8:20 am

Re: Freezing atom positions

Post by Hassan Nadeem » Tue Apr 04, 2023 4:01 pm

I figured it out, thanks.
My mistake was loading a checkpoint file after setting the masses to zero.

User avatar
Peter Eastman
Posts: 2611
Joined: Thu Aug 09, 2007 1:25 pm

Re: Freezing atom positions

Post by Peter Eastman » Tue Apr 04, 2023 4:29 pm

Can you post your full script, along with any input files needed to reproduce it?

POST REPLY