Esempio n. 1
0
def test_run_procedure(tmp_path):
    """Tests qcengine run-procedure with geometric, psi4, and JSON input"""
    def check_result(stdout):
        output = json.loads(stdout)
        assert output["provenance"]["creator"].lower() == "geometric"
        assert output["success"] is True

    inp = {"schema_name": "qcschema_optimization_input",
           "schema_version": 1,
           "keywords": {
               "coordsys": "tric",
               "maxiter": 100,
               "program": "psi4"
           },
           "input_specification": {
               "schema_name": "qcschema_input",
               "schema_version": 1,
               "driver": "gradient",
               "model": {"method": "HF", "basis": "sto-3g"},
               "keywords": {},
           },
           "initial_molecule": get_molecule("hydrogen")}
    inp = OptimizationInput(**inp)

    args = ["run-procedure", "geometric", inp.json()]
    check_result(run_qcengine_cli(args))

    args = ["run-procedure", "geometric", os.path.join(tmp_path, "input.json")]
    with util.disk_files({"input.json": inp.json()}, {}, cwd=tmp_path):
        check_result(run_qcengine_cli(args))

    args = ["run-procedure", "geometric", inp.json()]
    check_result(run_qcengine_cli(args, stdin=inp.json()))
Esempio n. 2
0
def test_disk_files():

    infiles = {"thing1": "hello", "thing2": "world", "other": "everyone"}
    outfiles = {"thing*": None, "other": None}
    with util.temporary_directory(suffix="this") as tmpdir:
        with util.disk_files(infiles=infiles, outfiles=outfiles, cwd=tmpdir):
            pass

    assert outfiles.keys() == {"thing*", "other"}
    assert outfiles["thing*"]["thing1"] == "hello"
    assert outfiles["other"] == "everyone"
Esempio n. 3
0
def test_disk_files(outfiles_load):

    infiles = {"thing1": "hello", "thing2": "world", "other": "everyone"}
    outfiles = {"thing*": None, "other": None}
    with util.temporary_directory(suffix="this") as tmpdir:
        with util.disk_files(infiles=infiles,
                             outfiles=outfiles,
                             cwd=tmpdir,
                             outfiles_load=outfiles_load):
            pass

    assert outfiles.keys() == {"thing*", "other"}
    if outfiles_load:
        assert outfiles["thing*"]["thing1"] == "hello"
        assert outfiles["other"] == "everyone"
    else:
        assert isinstance(outfiles["thing*"]["thing1"], pathlib.PurePath)
        assert isinstance(outfiles["other"], pathlib.PurePath)
Esempio n. 4
0
def test_run_psi4(tmp_path):
    """Tests qcengine run with psi4 and JSON input"""

    def check_result(stdout):
        output = json.loads(stdout)
        assert output["provenance"]["creator"].lower() == "psi4"
        assert output["success"] is True

    inp = AtomicInput(molecule=get_molecule("hydrogen"), driver="energy", model={"method": "hf", "basis": "6-31G"})

    args = ["run", "psi4", inp.json()]
    check_result(run_qcengine_cli(args))

    args = ["run", "psi4", os.path.join(tmp_path, "input.json")]
    with util.disk_files({"input.json": inp.json()}, {}, cwd=tmp_path):
        check_result(run_qcengine_cli(args))

    args = ["run", "psi4", "-"]
    check_result(run_qcengine_cli(args, stdin=inp.json()))