pele.utils.frozen_atoms#

Module source

tools for dealing with frozen atoms. Especially in relation to neighbor lists

class pele.utils.frozen_atoms.MultiComponentSystemFreeze[source]

Source

class MultiComponentSystemFreeze(basepot):

a potential wrapper for multiple potentials with frozen particles

The primary reason to use this class is that frozen-frozen interactions need only be calculated once

Parameters:
potentials_mobile

a list of potential objects that include mobile atoms

potentials_frozen

a list of potentials including only frozen atoms

pele.utils.frozen_atoms.makeBLJNeighborListPotFreeze()[source]

Source

def makeBLJNeighborListPotFreeze(
    natoms, frozenlist, ntypeA=None, rcut=2.5, boxl=None
):

create the potential object for the kob andersen binary lennard jones with frozeen particles

Parameters:
natoms

number of atoms in the system

frozenlist

list of frozen atoms

ntypeA

number of atoms of type A. It is assumed that they have indices in [0,ntypeA]

rcut

the cutoff for the lj potential in units of sigA

boxl

the box length for periodic box. None for no periodic boundary conditions

class pele.utils.frozen_atoms.FreezePot[source]

Source

class FreezePot(basepot):

potential wrapper for frozen particles

the gradient will be set to zero for all frozen particles

Parameters:
pot

the potential object

frozen

a list of frozen particles

FreezePot.NumericalDerivative()[source]

Source

def NumericalDerivative(self, coords, eps=1e-6):

return the gradient calculated numerically

FreezePot.NumericalHessian()[source]

Source

def NumericalHessian(self, coords, eps=1e-6):

return the Hessian matrix of second derivatives computed numerically

this takes 2*len(coords) calls to getGradient

class pele.utils.frozen_atoms.FrozenCoordsConverter[source]

Source

class FrozenCoordsConverter:

a tool to convert to and from the reduce set of coordinate in a system with frozen atoms

Parameters:
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

FrozenPotWrapper.__init__()[source]

Source

def __init__(self, potential, reference_coords, frozen_dof):

Wrapper for a potential object for freezing degrees of freedom

This is obsolete, use pele.potentials._frozen_dof.FrozenPotentialWrapper instead

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 and getEnergyGradient accept a reduced set of coordinates, adds passes it to the wrapped potential for calculation of the energy.

You can convert between the full and reduced representation using the functions coords_converter.get_reduced_coords() and coords_converter.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 from pele.utils.frozen_atoms import FrozenPotWrapper 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 = FrozenPotWrapper(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)

FrozenPotWrapper.__getattr__()[source]

Source

def __getattr__(self, name):

If this class does not have the attribute then pass the call on to self.underlying_pot