b578679cb85a26b172227a9e3ecfc29432604842,qcengine/programs/torchani.py,,torchani,#Any#Any#,32

Before Change


    if model is False:
        ret_data["error"] = QCEngineError(error_type="input_error",
                                          error_message="run_torchani only accepts the ANI1 method.")
        return Result(**{**input_data.dict(), **ret_data})

    // Build species
    species = "".join(input_data.molecule.symbols)
    unknown_sym = set(species) - {"H", "C", "N", "O"}
    if unknown_sym:
        ret_data["error"] = QCEngineError(error_type="input_error",
                                          error_message="The "{}" model does not support symbols: {}.".format(
                                            input_data.model.method, unknown_sym))
        return Result(**{**input_data.dict(), **ret_data})

    species = builtin.consts.species_to_tensor(species).to(device).unsqueeze(0)

After Change


    if model is False:
        ret_data["error"] = ComputeError(error_type="input_error",
                                         error_message="run_torchani only accepts the ANI1 method.")
        return FailedOperation(input_data=input_data.dict(), **ret_data)

    // Build species
    species = "".join(input_data.molecule.symbols)
    unknown_sym = set(species) - {"H", "C", "N", "O"}
    if unknown_sym:
        ret_data["error"] = ComputeError(error_type="input_error",
                                         error_message="The "{}" model does not support symbols: {}.".format(
                                            input_data.model.method, unknown_sym))
        return FailedOperation(input_data=input_data.dict(), **ret_data)

    species = builtin.consts.species_to_tensor(species).to(device).unsqueeze(0)

    // Build coord array
    geom_array = input_data.molecule.geometry.reshape(1, -1, 3) * ureg.conversion_factor("bohr", "angstrom")
    coordinates = torch.tensor(geom_array.tolist(), requires_grad=True, device=device)

    _, energy = model((species, coordinates))
    ret_data["properties"] = {"return_energy": energy.item()}

    if input_data.driver == "energy":
        ret_data["return_result"] = ret_data["properties"]["return_energy"]
    elif input_data.driver == "gradient":
        derivative = torch.autograd.grad(energy.sum(), coordinates)[0].squeeze()
        ret_data["return_result"] = np.asarray(derivative * ureg.conversion_factor("angstrom", "bohr")).ravel().tolist()
    else:
        ret_data["error"] = ComputeError(error_type="input_error",
                                         error_message="run_torchani did not understand driver method "{}".".format(
                                            input_data.driver))
        return FailedOperation(input_data=input_data.dict(), **ret_data)

    ret_data["provenance"] = Provenance(
        creator="torchani",
        version="unknown",
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: MolSSI/QCEngine
Commit Name: b578679cb85a26b172227a9e3ecfc29432604842
Time: 2019-01-27
Author: lnaden@vt.edu
File Name: qcengine/programs/torchani.py
Class Name:
Method Name: torchani


Project Name: MolSSI/QCEngine
Commit Name: b578679cb85a26b172227a9e3ecfc29432604842
Time: 2019-01-27
Author: lnaden@vt.edu
File Name: qcengine/programs/torchani.py
Class Name:
Method Name: torchani


Project Name: MolSSI/QCEngine
Commit Name: b578679cb85a26b172227a9e3ecfc29432604842
Time: 2019-01-27
Author: lnaden@vt.edu
File Name: qcengine/programs/rdkit.py
Class Name:
Method Name: rdkit


Project Name: MolSSI/QCEngine
Commit Name: b578679cb85a26b172227a9e3ecfc29432604842
Time: 2019-01-27
Author: lnaden@vt.edu
File Name: qcengine/compute.py
Class Name:
Method Name: compute