Пример #1
0
def globals_setup(new_root):
    """Sets up the globals for the calculator instance.
    """
    from matdb.io import read
    from matdb.calculators.utility import paths, set_paths

    target = relpath("./tests/AgPd/matdb_qe")
    config = path.expanduser(path.abspath(target))
    if path.isabs(config):
        root, config = path.split(config)
    else:
        root, config = path.dirname(config), config

    configyml = read(root, config)
    configyml["root"] = new_root

    set_paths(configyml)
Пример #2
0
def test_set_paths():
    """Tests the setting of the global paths."""
    from matdb.calculators.utility import paths, set_paths

    target = relpath("./tests/AgPd/matdb")
    config = path.expanduser(path.abspath(target))
    if path.isabs(config):
        root, config = path.split(config)
    else:
        root, config = path.dirname(config), config

    configyml = read(root, config)

    set_paths(configyml)

    name = configyml["title"].strip().replace(' ', '_')
    namehash = str(sha1(name.encode("ASCII")).hexdigest())
    assert namehash in paths
    assert "vasp" in paths[namehash]
    for k, v in paths[namehash]["vasp"].items():
        assert "tests/vasp" in v
Пример #3
0
def test_build_calc():
    """Tests the setting of the calc builder."""

    from matdb.calculators.utility import build_calc
    from matdb.io import read
    from matdb.calculators.utility import paths, set_paths
    from matdb.utility import _set_config_paths

    _set_config_paths("AgPd_Enumerated", '.')

    target = relpath("./tests/AgPd/matdb")
    config = path.expanduser(path.abspath(target))
    if path.isabs(config):
        root, config = path.split(config)
    else:
        root, config = path.dirname(config), config

    configyml = read(root, config)

    set_paths(configyml)

    kwargs = {
        "kpoints": {
            "rmin": 50
        },
        "potcars": {
            "directory": "./tests/vasp",
            "xc": "pbe"
        }
    }

    res = build_calc("Vasp", None, **kwargs)

    assert res.key == "vasp"

    res = None
    res = build_calc("Vasp", '.', **kwargs)

    assert res.key == "vasp"