How to use the cclib.parser 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 / test / test_data.py View on Github external
import cclib


__filedir__ = os.path.realpath(os.path.dirname(__file__))


# We need this in Python3 for importing things from the same directory
# within the unit test files.
sys.path.insert(1, os.path.join(__filedir__, 'data'))


parser_names = [
    "ADF", "DALTON", "GAMESS", "GAMESSUK", "Gaussian", "Jaguar", "Molpro",
    "Molcas", "MOPAC", "NWChem", "ORCA", "Psi4", "QChem", "Turbomole",
]
all_parsers = {name: getattr(cclib.parser, name) for name in parser_names}

# Not used currently, but keeping in a list to keep track of which parsers
# are in the legacy bin.
legacy_parser_names = ["Psi3"]


module_names = [
    "SP", "SPun", "GeoOpt", "Basis", "Core",    # Basic calculations.
    "MP", "CC", "CI", "TD", "TDun",             # Post-SCF calculations.
    "vib", "BOMD", "Polar", "Scan",             # Other property calculations.
]
all_modules = {tn: importlib.import_module('.data.test' + tn, package='test')
               for tn in module_names}


def gettestdata():
github cclib / cclib / test / parser / testutils.py View on Github external
def test_pairs(self):
        """Do flipped conversions correspond to each other?"""

        convertor = cclib.parser.utils.convertor

        pairs_proportional = (
            ("Angstrom", "bohr"), ("wavenumber", "eV"),
            ("wavenumber", "kcal/mol"), ("eV", "kJ/mol"), ("coulomb", "e"))
        pairs_inverse = (("nm", "wavenumber"),)

        for unit1, unit2 in pairs_proportional:
            conv1 = convertor(1.0, unit1, unit2)
            conv2 = 1.0 / convertor(1.0, unit2, unit1)
            self.assertAlmostEqual((conv1 - conv2) / conv1, 0.0)
        for unit1, unit2 in pairs_inverse:
            conv1 = convertor(1.0, unit1, unit2)
            conv2 = convertor(1.0, unit2, unit1)
            self.assertAlmostEqual((conv1 - conv2) / conv1, 0.0)
github cclib / cclib / test / data / testScan.py View on Github external
"""Test scan logfiles in cclib"""

import os
import unittest

import numpy
import cclib

from skip import skipForParser


__filedir__ = os.path.realpath(os.path.dirname(__file__))


OPT_DONE = cclib.parser.data.ccData.OPT_DONE
OPT_NEW = cclib.parser.data.ccData.OPT_NEW


class GenericScanTestBase(unittest.TestCase):
    """Base relaxed potential energy surface scan unittest."""

    def assertOptNew(self, optstatus_value):
        return optstatus_value & OPT_NEW == OPT_NEW

    def assertOptDone(self, optstatus_value):
        return optstatus_value & OPT_DONE == OPT_DONE


class GenericScanTest_optdone_bool(GenericScanTestBase):
    """Generic relaxed potential energy surface scan unittest."""
github cclib / cclib / test / parser / testutils.py View on Github external
def test_basic(self):
        """Are some basic conversions correct?"""
        convertor = cclib.parser.utils.convertor
        self.assertAlmostEqual(convertor(1.89, "bohr", "Angstrom"), 1.0, places=3)
        self.assertAlmostEqual(convertor(0.529, "Angstrom", "bohr"), 1.0, places=3)
        self.assertAlmostEqual(convertor(627.5, "kcal/mol", "hartree"), 1.0, places=3)
github schneiderfelipe / pnictogen / pnictogen / __init__.py View on Github external
# -*- coding: utf-8 -*-

"""Core functionality."""

import os
import sys
import argparse
import importlib
from pkg_resources import require, resource_filename, resource_listdir

import cclib
from jinja2 import Environment, FileSystemLoader, TemplateNotFound

__version__ = require(__name__)[0].version

table = cclib.parser.utils.PeriodicTable()

REPOSITORY = {
    os.path.splitext(name)[0]: resource_filename(__name__, "repo/" + name)
    for name in resource_listdir(__name__, "repo")
}


class Atoms:
    """
    This is a simple umbrella object for many sources of data so as to make
    everything behave like ``cclib.parser.ccData``.

    Parameters
    ----------
    data : ccData-like
        Any object that behaves like ``cclib.parser.ccData``.