How to use cclib - 10 common examples

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 / parser / psi4parser.py View on Github external
def _parse_mosyms_moenergies(self, inputfile, spinidx):
        """Parse molecular orbital symmetries and energies from the
        'Post-Iterations' section.
        """
        line = next(inputfile)
        while line.strip():
            for i in range(len(line.split()) // 2):
                self.mosyms[spinidx].append(line.split()[i*2][-2:])
                moenergy = utils.convertor(float(line.split()[i*2+1]), "hartree", "eV")
                self.moenergies[spinidx].append(moenergy)
            line = next(inputfile)
        return
github cclib / cclib / test / io / testxyzwriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        xyz = cclib.io.xyzwriter.XYZ(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(xyz.ccdata, data)
github cclib / cclib / test / io / testxyzwriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        xyz = cclib.io.xyzwriter.XYZ(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(xyz.ccdata, data)
github cclib / cclib / test / io / testcjsonwriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        cjson = cclib.io.cjsonwriter.CJSON(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(cjson.ccdata, data)
github cclib / cclib / test / io / testxyzwriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        xyz = cclib.io.xyzwriter.XYZ(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(xyz.ccdata, data)
github cclib / cclib / test / io / testfilewriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        writer = cclib.io.filewriter.Writer(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(writer.ccdata, data)
github cclib / cclib / test / regression.py View on Github external
fname_norm = normalisefilename(fname.replace(__regression_dir__, ''))

            funcname = "test" + fname_norm
            test_this = funcname in globals()

            funcname_noparse = "testnoparse" + fname_norm
            test_noparse = not test_this and funcname_noparse in globals()

            if not test_noparse:
                datatype = parser_class.datatype if hasattr(parser_class, 'datatype') else ccData
                job_filenames = glob.glob(fname)
                try:
                    if len(job_filenames) == 1:
                        logfile = ccopen(job_filenames[0], datatype=datatype, loglevel=loglevel)
                    else:
                        logfile = ccopen(job_filenames, datatype=datatype, loglevel=loglevel)
                except Exception as e:
                    errors += 1
                    print("ccopen error: ", e)
                    if opt_traceback:
                        print(traceback.format_exc())
                else:
                    if type(logfile) == parser_class:
                        try:
                            logfile.data = logfile.parse()
                        except KeyboardInterrupt:
                            sys.exit(1)
                        except Exception as e:
                            print("parse error:", e)
                            errors += 1
                            if opt_traceback:
                                print(traceback.format_exc())
github cclib / cclib / test / regression.py View on Github external
# to be additionaly prepended with 'testnoparse'.
            test_this = test_noparse = False
            fname_norm = normalisefilename(fname.replace(__regression_dir__, ''))

            funcname = "test" + fname_norm
            test_this = funcname in globals()

            funcname_noparse = "testnoparse" + fname_norm
            test_noparse = not test_this and funcname_noparse in globals()

            if not test_noparse:
                datatype = parser_class.datatype if hasattr(parser_class, 'datatype') else ccData
                job_filenames = glob.glob(fname)
                try:
                    if len(job_filenames) == 1:
                        logfile = ccopen(job_filenames[0], datatype=datatype, loglevel=loglevel)
                    else:
                        logfile = ccopen(job_filenames, datatype=datatype, loglevel=loglevel)
                except Exception as e:
                    errors += 1
                    print("ccopen error: ", e)
                    if opt_traceback:
                        print(traceback.format_exc())
                else:
                    if type(logfile) == parser_class:
                        try:
                            logfile.data = logfile.parse()
                        except KeyboardInterrupt:
                            sys.exit(1)
                        except Exception as e:
                            print("parse error:", e)
                            errors += 1
github cclib / cclib / test / io / testxyzwriter.py View on Github external
def test_init(self):
        """Does the class initialize correctly?"""
        fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
        data = cclib.io.ccread(fpath)
        xyz = cclib.io.xyzwriter.XYZ(data)

        # The object should keep the ccData instance passed to its constructor.
        self.assertEqual(xyz.ccdata, data)
github cclib / cclib / test / regression.py View on Github external
def testQChem_QChem5_0_argon_out(logfile):
    """This job has unit specifications at the end of 'Total energy for
    state' lines.
    """
    assert logfile.data.metadata["package_version"] == "5.0.1"
    nroots = 12
    assert len(logfile.data.etenergies) == nroots
    state_0_energy = -526.6323968555
    state_1_energy = -526.14663738
    assert logfile.data.scfenergies[0] == convertor(state_0_energy, 'hartree', 'eV')
    assert abs(logfile.data.etenergies[0] - convertor(state_1_energy - state_0_energy, 'hartree', 'wavenumber')) < 1.0e-1