How to use the cclib.method.calculationmethod.Method function in cclib

To help you get started, we’ve selected a few cclib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cclib / cclib / cclib / method / fragments.py View on Github external
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Fragment analysis based on parsed ADF data."""

import logging
import random

import numpy
numpy.inv = numpy.linalg.inv

from cclib.method.calculationmethod import Method


class FragmentAnalysis(Method):
    """Convert a molecule's basis functions from atomic-based to fragment MO-based"""
    def __init__(self, data, progress=None, loglevel=logging.INFO,
                 logname="FragmentAnalysis of"):

        # Call the __init__ method of the superclass.
        super(FragmentAnalysis, self).__init__(data, progress, loglevel, logname)
        self.parsed = False

    def __str__(self):
        """Return a string representation of the object."""
        return "Fragment molecule basis of %s" % (self.data)

    def __repr__(self):
        """Return a representation of the object."""
        return 'Fragment molecular basis("%s")' % (self.data)
github cclib / cclib / cclib / method / population.py View on Github external
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Population analyses based on cclib data."""

import logging

import numpy

from cclib.method.calculationmethod import Method


class Population(Method):
    """An abstract base class for population-type methods."""

    def __init__(self, data, progress=None, \
                 loglevel=logging.INFO, logname="Log"):

        # Call the __init__ method of the superclass.
        super(Population, self).__init__(data, progress, loglevel, logname)
        self.fragresults = None

    def __str__(self):
        """Return a string representation of the object."""
        return "Population"

    def __repr__(self):
        """Return a representation of the object."""
        return "Population"
github cclib / cclib / cclib / method / opa.py View on Github external
import random

import numpy

from cclib.method.calculationmethod import Method


def func(x):
    if x==1:
        return 1
    else:
        return x+func(x-1)


class OPA(Method):
    """Overlap population analysis."""

    def __init__(self, *args):

        # Call the __init__ method of the superclass.
        super(OPA, self).__init__(logname="OPA", *args)

    def __str__(self):
        """Return a string representation of the object."""
        return "OPA of %s" % (self.data)

    def __repr__(self):
        """Return a representation of the object."""
        return 'OPA("%s")' % (self.data)

    def calculate(self, indices=None, fupdate=0.05):
github cclib / cclib / cclib / method / nuclear.py View on Github external
def get_isotopic_masses(charges):
    """Return the masses for the given nuclei, respresented by their
    nuclear charges.
    """
    _check_periodictable(_found_periodictable)
    masses = []
    for charge in charges:
        el = pt.elements[charge]
        isotope = get_most_abundant_isotope(el)
        mass = isotope.mass
        masses.append(mass)
    return np.array(masses)


class Nuclear(Method):
    """A container for methods pertaining to atomic nuclei."""

    def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"):

        self.required_attrs = ('natom','atomcoords','atomnos','charge')

        super(Nuclear, self).__init__(data, progress, loglevel, logname)

    def __str__(self):
        """Return a string representation of the object."""
        return "Nuclear"

    def __repr__(self):
        """Return a representation of the object."""
        return "Nuclear"
github cclib / cclib / cclib / method / moments.py View on Github external
"""Calculation of electric multipole moments based on data parsed by cclib."""

import sys

if sys.version_info <= (3, 3):
    from collections import Iterable
else:
    from collections.abc import Iterable

import numpy

from cclib.parser.utils import convertor
from cclib.method.calculationmethod import Method


class Moments(Method):
    """A class used to calculate electric multipole moments.

    The obtained results are stored in `results` attribute as a
    dictionary whose keys denote the used charge population scheme.
    """
    def __init__(self, data):
        self.required_attrs = ('atomcoords', 'atomcharges')
        self.results = {}

        super(Moments, self).__init__(data)

    def __str__(self):
        """Returns a string representation of the object."""
        return "Multipole moments of %s" % (self.data)

    def __repr__(self):
github cclib / cclib / cclib / method / electrons.py View on Github external
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Calculate properties for electrons."""

import logging

import numpy

from cclib.method.calculationmethod import Method


class Electrons(Method):
    """A container for methods pertaining to electrons."""

    def __init__(self, data, progress=None, loglevel=logging.INFO, logname="Log"):

        self.required_attrs = ('atomnos','charge','coreelectrons')

        super(Electrons, self).__init__(data, progress, loglevel, logname)

    def __str__(self):
        """Returns a string representation of the object."""
        return "Electrons"

    def __repr__(self):
        """Returns a representation of the object."""
        return "Electrons"
github cclib / cclib / cclib / method / density.py View on Github external
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Building the density matrix from data parsed by cclib."""

import logging
import random

import numpy

from cclib.method.calculationmethod import Method


class Density(Method):
    """Calculate the density matrix"""
    def __init__(self, data, progress=None, loglevel=logging.INFO,
                 logname="Density"):

        # Call the __init__ method of the superclass.
        super(Density, self).__init__(data, progress, loglevel, logname)

    def __str__(self):
        """Return a string representation of the object."""
        return "Density matrix of %s" % (self.data)

    def __repr__(self):
        """Return a representation of the object."""
        return 'Density matrix("%s")' % (self.data)

    def calculate(self, fupdate=0.05):
github cclib / cclib / src / cclib / method / orbitals.py View on Github external
#
# The library is free software, distributed under the terms of
# the GNU Lesser General Public version 2.1 or later. You should have
# received a copy of the license along with cclib. You can also access
# the full license online at http://www.gnu.org/copyleft/lgpl.html.

"""Analyses related to orbitals."""

import logging

import numpy

from cclib.method.calculationmethod import Method


class Orbitals(Method):
    """A class for orbital related methods."""

    def __init__(self, data, progress=None, \
                 loglevel=logging.INFO, logname="Log"):

        self.required_attrs = ('mocoeffs','moenergies','homos')
        # Call the __init__ method of the superclass.
        super(Orbitals, self).__init__(data, progress, loglevel, logname)
        self.fragresults = None

    def __str__(self):
        """Return a string representation of the object."""
        return "Orbitals"

    def __repr__(self):
        """Return a representation of the object."""