Source code for metafalcon.interfaces.iface

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

"""Contains a general class for interfacing with quantum chemistry codes."""

import numpy as np

[docs]class iface: """ Parent class for interfaces to quantum chemistry codes. Parameters ---------- symbols : list of str atomic symbols of the molecule coords : np.2darray (shape: (N, 3)) atomic xyz-coordinates of the molecule (bohr) Attributes ---------- symbols : list of str atomic symbols of the molecule coords : np.2darray (shape: (N, 3)) atomic xyz-coordinates of the molecule (bohr) energy : float electronic energy of the molecule calculated most recently (hartrees) gradient : np.2darray (shape: (N, 3)) electronic energy gradient of the molecule with current coordinates (hartree/bohr) converged : bool whether the calculation has converged """ def __init__(self, symbols, coords): """Construct iface object.""" self.symbols = symbols self.coords = coords self.energy = 0.0 self.gradient = np.zeros_like(coords) self.converged = False
[docs] def set_symbols(self, symbols): """ Set symbols attribute of an iface object. Parameters ---------- symbols : list of str atomic symbols of the molecule """ self.symbols = symbols
[docs] def set_coords(self, coords): """ Set coordinates attribute of an iface object. Parameters ---------- coords : np.2darray (shape: (N, 3)) atomic xyz-coordinates of the molecule (bohr) """ self.coords = coords
[docs] def get_energy(self): """ Return the energy calculated by the QM-code. Returns ------- energy : float electronic ground state energy of the molecule calculated most recently (hartrees) """ return self.energy
[docs] def get_gradient(self): """ Return the energy gradient calculated by the QM-code. Returns ------- gradient : np.2darray (shape: (N, 3)) electronic energy gradient of the molecule calculated most recently (hartree/bohr) """ return self.gradient