Define your own …
Collective Variables
This module defines all the build-in collective variables
The way to add new collective variables is to write a classs from the base class Colvar
The class has to have two functions: compute(self, x) and jacobian(self, x). The former reads in n-dimensional vector and return a two-dimensional one. The later reads in n-dimensional vector and return 5x2 (colxrow) matrix.
from ndsimulator.colvars import Colvar
class NewColvar(Colvar):
colvardim = 1 # the output dimension
jacobian = np.zeros(3) # if the jacobian is a constant
def compute(self, x):
...
return c
def jacobian(self, x):
...
return j
Make sure this function can be imported in your current python environment.
Put this code under your running environment with a filename my_colvar.py
prepend the directory that contains the my_colvar.py to your PYTHONPATH
specify it in the yaml config.
colvar: my_colvar.NewColvar true_colvar: my_colvar.NewColvar
Potentials
This module defines all the build-in potentials, including double well, gaussian, mueller-brown, and three-hole.
write a new python function class from the base class Potential
from ndsimulator.potentials import Potential
class NewPotential(Potential):
ndim = 3 # set to None if it works for arbiturary dimension
require_colvar = True # if it is derived from some underlying transformation
def compute(self, x):
...
return e, f
Make sure this function can be imported in your current python environment.
Put this code under your running environment with a filename my_potential.py
prepend the directory that contains the my_potential.py to your PYTHONPATH
specify it in the yaml config.
potential: my_potential.NewPotential