def test_ccrepo_ccpvdz(self):
        db = look4bas.Database()
        db.update()

        findings = db.search_basisset("^cc-pVDZ$",
                                      regex=True,
                                      sources=["ccrepo"])
        assert len(findings) == 1
        bset = findings[0]
        assert bset["name"] == "cc-pVDZ"
        len(bset["atoms"]) == 35

        bset = db.lookup_basisset_full(bset)
        germanium = [at for at in bset["atoms"] if at["atnum"] == 32]
        assert len(germanium) == 1
        germanium = germanium[0]

        assert len(germanium["functions"]) == 11
        five_contracted = [
            fun for fun in germanium["functions"] if len(fun["exponents"]) == 5
        ]
        assert len(five_contracted) == 1

        assert five_contracted[0]["angular_momentum"] == 2
        assert five_contracted[0]["exponents"] == [
            74.7620000, 21.3020000, 7.3436000, 2.5651000, 0.8197000
        ]
        assert five_contracted[0]["coefficients"] == [
            0.0257684, 0.1454421, 0.3713721, 0.4800002, 0.2896800
        ]
    def test_emsl_def2svp(self):
        db = look4bas.Database()
        db.update()

        findings = db.search_basisset("^Def2-SVP$",
                                      regex=True,
                                      sources=["EMSL"])
        assert len(findings) == 1
        bset = findings[0]
        assert bset["name"] == "Def2-SVP"
        len(bset["atoms"]) == 72

        bset = db.lookup_basisset_full(bset)
        silicon = [at for at in bset["atoms"] if at["atnum"] == 14]
        assert len(silicon) == 1
        silicon = silicon[0]

        assert len(silicon["functions"]) == 8
        five_contracted = [
            fun for fun in silicon["functions"] if len(fun["exponents"]) > 4
        ]
        assert len(five_contracted) == 2

        assert five_contracted[0]["angular_momentum"] == 0
        assert five_contracted[0]["exponents"] == [
            6903.7118686, 1038.4346419, 235.87581480, 66.069385169,
            20.247945761
        ]
        assert five_contracted[1]["angular_momentum"] == 1
Beispiel #3
0
def main():
    """
    Main function to start the CLI
    """

    # Parse the commandline arguments
    parser = argparse.ArgumentParser(
        description=
        "Commandline tool to search and download Gaussian basis sets. "
        "The tool downloads (and caches) the list of basis sets from the emsl basis set "
        "exchange (https://bse.pnl.gov/bse/portal) and/or the ccrepo "
        "(https://grant-hill.group.shef.ac.uk/ccrepo/) "
        "for offline search and allows to "
        "easily download individual basis sets from it.", )
    add_cmd_args_to(parser)
    args = parser.parse_args()
    cmd_post_parsing_cleanup(args)

    # Setup database:
    data_base = look4bas.Database(args.dbfile)

    if args.force_update:
        data_base.clear()

    if args.dbsource == "archive":
        data_base.update()
    elif args.dbsource == "direct":
        data_base.update_from_source_sites()
    else:
        data_base.update(url=args.dbsource)

    if data_base.empty:
        raise SystemExit("The database seems to be empty. "
                         "This could indicate that an update failed. "
                         "Try running 'look4bas --force-update'.")

    # Search for basis sets
    findings = search_basissets(data_base, args)
    if not findings:
        raise SystemExit("No basis set matched your search")

    # Since args.download may be absent or present, but without a value,
    # we cannot plainly use 'if args.download' here.
    if args.download is not None:
        download_results(args, data_base, findings)
    else:
        display.print_basissets(findings,
                                **args.format,
                                highlight_atnums=args.elements,
                                source_to_colour=config.source_to_colour)
Beispiel #4
0
#!/usr/bin/env python3
import look4bas
import json

# Search for Def2-SVP
db = look4bas.Database()
findings = db.search_basisset(pattern="^Def2-SVP$", regex=True)

if not findings or len(findings) > 1:
    print("Could not find Def2-SVP")

# Retrieve full basis set information online
bset = db.lookup_basisset_full(findings[0])

# Build a mapping from the atom number to the list
# of ecp definitions
num_map = {at["atnum"]: at["ecp"] for at in bset["atoms"] if "ecp" in at}

# Build mapping from the atom symbol to the list
# of ecp definitions
element_list = look4bas.elements.iupac_list()
symbol_map = {element_list[atnum]["symbol"]: functions
              for atnum, functions in num_map.items()}

# Print ecp definiton for Hafnium
print("ECP definition for Hafnium:")
print(json.dumps(symbol_map["Hf"], indent=2, sort_keys=True))