pele.potentials._frozen_dof#

Module source

# distutils: language = C++ # cython: language_level=3str

basic potential interface stuff

class pele.potentials._frozen_dof.FrozenPotentialWrapper

Source

cdef class FrozenPotentialWrapper(_pele.BasePotential):

Wrapper for a potential object for freezing degrees of freedom

Parameters:
potentialobject

the pele potential object to be wrapped

reference_coordsnumpy array

a set of reference coordinates. This defines the positions of the frozen coordinates and the total number of degrees of freedom

frozen_doflist

a list of the frozen degrees of freedom

Notes

This uses class FrozenCoordsConverter to convert back and forth between the full set of coordinates and the reduced set of coordinates (those that are still mobile).

The functions getEnergy, etc, accept a reduced set of coordinates, and passes it to the wrapped potential for calculation of the energy.

You can convert between the full and reduced representation using the functions get_reduced_coords() and get_full_coords().

Examples

The following example shows how to wrap the lennard jones potential and freeze the first 6 degrees of freedom (2 atoms). It then does a minimization on the reduced coordinates and prints off some information

import numpy as np from pele.potentials import LJ, FrozenPotentialWrapper from pele.optimize import mylbfgs natoms = 4 pot = LJ()

reference_coords = np.random.uniform(-1, 1, [3*natoms]) print(reference_coords)

# freeze the first two atoms (6 degrees of freedom) frozen_dof = range(6)

fpot = FrozenPotentialWrapper(pot, reference_coords, frozen_dof)

reduced_coords = fpot.coords_converter.get_reduced_coords(reference_coords)

print(“the energy in the full representation:”) print(pot.getEnergy(reference_coords)) print(“is the same as the energy in the reduced representation:”) print(fpot.getEnergy(reduced_coords))

ret = mylbfgs(reduced_coords, fpot) print(“after a minimization the energy is “, ret.energy, “and the rms gradient is”, ret.rms) print(“the coordinates of the frozen degrees of freedom are unchanged”) print(“starting coords:”, reference_coords) print(“minimized coords:”, fpot.coords_converter.get_full_coords(ret.coords))