Source code for metafalcon.cvs.cremerpople_theta

# -*- coding: utf-8 -*-

"""Contains a class for using Cremer Pople angle theta as a CV."""

import numpy as np

from .cv import cv
from . import cremerpople

[docs]class cv_cremerpople_theta(cv): """ Cremer-Pople angle theta as collective variable, inherits from `metafalcon.cvs.cv.cv`. Parameters ---------- idx : int index of collective variable in the input file symbols : list of str atomic symbols of the molecule **kwargs : See below Keyword Arguments ----------------- atoms : list of int list of ring atoms to be used for the Cremer-Pople calculation in correct ordering """ def __init__(self, idx, symbols, **kwargs): """Construct Cremer-Pople theta CV object.""" cv.__init__(self, idx, symbols, **kwargs) # standard plotting options self.x = np.linspace(0.5, 2.5, 200) self.ticks = None # unit conversion self.au2unit = 1.0 self.reset_width() # arguments should be saved in the following way self.atoms = self.get_kwargs("atoms")
[docs] def set_s_and_ds(self, coords): """ Calculate theta and its gradient for the current set of coordinates. Parameters ---------- coords : np.2darray cartesian coordinates of the molecule (shape: (N, 3)) """ coords_atoms = coords[self.atoms] theta = cremerpople.find_theta(coords_atoms) with open('theta.dat','a') as f: f.write(str(theta)+'\n') self.s = theta dtheta = np.zeros_like(coords) dtheta[self.atoms] = cremerpople.dtheta(coords_atoms) self.ds_dr = dtheta