1 0
import pytest
2

3 0
import qcfractal.interface as ptl
4 0
from qcfractal.interface.models import GridOptimizationInput
5 0
from qcfractal.testing import fractal_compute_server, using_geometric, using_rdkit
6

7 0
@using_geometric
8 0
@using_rdkit
9
def test_service_gridoptimization_single_noopt(fractal_compute_server):
10

11 0
    client = ptl.FractalClient(fractal_compute_server)
12

13
    # Add a HOOH
14 0
    hooh = ptl.data.get_molecule("hooh.json")
15 0
    initial_distance = hooh.measure([1, 2])
16

17
    # Options
18 0
    service = GridOptimizationInput(**{
19
        "keywords": {
20
            "preoptimization": False,
21
            "scans": [{
22
                "type": "distance",
23
                "indices": [1, 2],
24
                "steps": [-0.1, 0.0],
25
                "step_type": "relative"
26
            }]
27
        },
28
        "optimization_spec": {
29
            "program": "geometric",
30
            "keywords": {
31
                "coordsys": "tric",
32
            }
33
        },
34
        "qc_spec": {
35
            "driver": "gradient",
36
            "method": "UFF",
37
            "basis": "",
38
            "keywords": None,
39
            "program": "rdkit",
40
        },
41
        "initial_molecule": hooh,
42
    }) # yapf: disable
43

44 0
    ret = client.add_service([service])
45 0
    fractal_compute_server.await_services()
46 0
    assert len(fractal_compute_server.list_current_tasks()) == 0
47

48 0
    result = client.query_procedures(id=ret.ids)[0]
49

50 0
    assert result.status == "COMPLETE"
51 0
    assert result.starting_grid == (1, )
52 0
    assert pytest.approx(result.get_final_energies((0, )), abs=1.e-4) == 0.00032145876568280524
53

54 0
    assert result.starting_molecule == result.initial_molecule
55

56
    # Check initial vs startin molecule
57 0
    assert result.initial_molecule == result.starting_molecule
58

59 0
    mol = client.query_molecules(id=result.starting_molecule)[0]
60 0
    assert pytest.approx(mol.measure([1, 2])) == initial_distance

Read our documentation on viewing source code .

Loading