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
  1. Make sure this function can be imported in your current python environment.

    1. Put this code under your running environment with a filename my_colvar.py

    2. prepend the directory that contains the my_colvar.py to your PYTHONPATH

  2. 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
  1. Make sure this function can be imported in your current python environment.

    1. Put this code under your running environment with a filename my_potential.py

    2. prepend the directory that contains the my_potential.py to your PYTHONPATH

  2. specify it in the yaml config.

    potential: my_potential.NewPotential