Source code for metafalcon.cvs.cremerpople_q

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

"""Contains a class for using Cremer Pople total amplitude Q as a CV."""

import numpy as np

from .cv import cv
from . import cremerpople
from .. import constants as c

[docs]class cv_cremerpople_q(cv): """ Cremer-Pople total ampltiude Q 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 Q 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 = c.a0 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 Q 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] Q = cremerpople.find_Q(coords_atoms) with open('Q.dat','a') as f: f.write(str(Q)+'\n') self.s = Q dQ = np.zeros_like(coords) dQ[self.atoms] = cremerpople.dQ(coords_atoms) self.ds_dr = dQ