Source code for metafalcon.cvs.cremerpople_phi

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

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

import numpy as np

from .cv import cv
from . import cremerpople

[docs]class cv_cremerpople_phi(cv): """ Cremer-Pople angle phi 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 phi 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] phi = cremerpople.find_phi(coords_atoms) with open('phi.dat','a') as f: f.write(str(phi)+'\n') self.s = phi dphi = np.zeros_like(coords) dphi[self.atoms] = cremerpople.dphi(coords_atoms) self.ds_dr = dphi