RedesignScience / cvpack

Useful Collective Variables for OpenMM
https://redesignscience.github.io/cvpack/latest
MIT License
11 stars 1 forks source link

Coordination CV for centre of mass as an atom #102

Closed sameersaurav closed 1 month ago

sameersaurav commented 1 month ago

I want to use coordination CV around the center of mass of a group. Is it possible to replace g1 in the "Number of Contacts" CV with the center of mass of g1?

With regards, Sameer

craabreu commented 1 month ago

As a subclass of openmm.CustomNonbondedForce, NumberOfContacts can only deal with individual atoms. You can use CentroidFunction, though. The basic idea is the following:

coordination = cvpack.CentroidFunction(
    "1/(1+x^6); x=distance(g1,g2)/threshold",
    unit.dimensionless,
    [g1, g2, g3, g4, ...],
    [[0, 1], [0, 2], [0, 3], ...],
    threshold=X*unit.nanometers,
)

Here, g1, g2, etc are predefined lists of atom indices. This CV will count the contacts between g1 and all other groups, based on their center-of-mass distances.

sameersaurav commented 1 month ago

Thanks a lot.

With best regards, Sameer