Skip to content

Commit

Permalink
Plumed CNCV (duartegroup#114)
Browse files Browse the repository at this point in the history
* Update plumed.py

* Update plumed.py

* Update mlptrain/sampling/plumed.py

Co-authored-by: Veronika Juraskova <veronika.juraskova@email.cz>

* Update mlptrain/sampling/plumed.py

Co-authored-by: Veronika Juraskova <veronika.juraskova@email.cz>

* add m and n in plumed CN

* add m and n in plumed CN

* add m and n in plumed CN

* Update mlptrain/sampling/plumed.py

Co-authored-by: Veronika Juraskova <veronika.juraskova@email.cz>

* Update mlptrain/sampling/plumed.py

Co-authored-by: Veronika Juraskova <veronika.juraskova@email.cz>

* add default values of n and m

* add default values of n and m

* add default values of n and m

---------

Co-authored-by: Veronika Juraskova <veronika.juraskova@email.cz>
Co-authored-by: Veronika Juraskova <veronika.juraskova@chem.ox.ac.uk>
  • Loading branch information
3 people authored Nov 29, 2024
1 parent cbb38fd commit 1f6dacf
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions mlptrain/sampling/plumed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,61 @@ def __init__(self, name: str, atom_groups: Sequence = None):
)


class PlumedCNCV(_PlumedCV):
def __init__(
self,
name: str,
ref: float,
n: int = 6,
m: int = 12,
atom_groups: Sequence = None,
):
"""
PLUMED collective variable as a coordination number (CN) between two atoms or groups of atoms
e.g. [(0, 2)] gives ζ =[1-(r_02/r_ref)^n]/ [1-(r_02/r_ref)^m]
which corresponds to the CN between atoms 0 and 2.
To ensure that the CN has continuous derivatives,
we use a rational switching function consistent with PLUMED.
More information: https://www.plumed.org/doc-v2.9/user-doc/html/_c_o_o_r_d_i_n_a_t_i_o_n.html
-----------------------------------------------------------------------
Arguments:
name: (str) Name of the collective variable
ref: (float) Reference values to distinguish different states
n, m: (int) Parameters used to adjust the shape of the function
atom_groups: (Sequence[Sequence[int]]) List of atom index sequences
which are used to generate DOFs
"""

super().__init__(name=name, atom_groups=atom_groups)

self._set_units()

self.ref = ref

self.n = n

self.m = m

func = f'(1-({self.dof_names[0]}/{self.ref})^{self.n})/(1-({self.dof_names[0]}/{self.ref})^{self.m})'

self.setup.extend(
[
f'{self.name}: '
f'CUSTOM ARG={self.dof_sequence} '
f'VAR={self.dof_sequence} '
f'FUNC={func} '
f'PERIODIC=NO'
]
)


class PlumedCustomCV(_PlumedCV):
"""Class used to initialise a PLUMED collective variable from a file"""

Expand Down

0 comments on commit 1f6dacf

Please sign in to comment.