Skip to content

Setup qcel.models.Molecule with non-contiguous fragments #298

@awvwgk

Description

@awvwgk

Trying the following example molecule from S22, I notice that there is something odd happening for molecules with fragment information:

import qcelemental as qcel

data = {
    "symbols": [
        "N", "N", "H", "H", "H", "H", "H", "H"
    ],
    "geometry": [
        -2.9833455085754399E+0, -8.8082052767279997E-2,  0.0000000000000000E+0,
         2.9833455085754399E+0,  8.8082052767279997E-2,  0.0000000000000000E+0,
        -4.0792036056518599E+0,  2.5775116682053001E-1,  1.5298565626144400E+0,
        -1.6052680015564000E+0,  1.2438048124313399E+0,  0.0000000000000000E+0,
        -4.0792036056518599E+0,  2.5775116682053001E-1, -1.5298565626144400E+0,
         4.0792036056518599E+0, -2.5775116682053001E-1, -1.5298565626144400E+0,
         1.6052680015564000E+0, -1.2438048124313399E+0,  0.0000000000000000E+0,
         4.0792036056518599E+0, -2.5775116682053001E-1,  1.5298565626144400E+0
    ],
    "fragments": [
        [0, 2, 3, 4],
        [1, 5, 6, 7],
    ],
}

for validate in (True, False):
    try:
        mol = qcel.models.Molecule(**data, validate=validate)
    except qcel.exceptions.ValidationError as e:
        print(f"Fails to setup with validate={validate}\n{str(e)}")

Output from the run is an unexpected validation error when validating the input

Warning: QCElemental is reordering atoms to accommodate non-contiguous fragments
Fails to setup with validate=True
Error: QCElemental would need to reorder atoms to accommodate non-contiguous fragments

Why are non-contiguous fragments a validation error in qcel? The issue is probably that throw_reorder is always true at:

while the default is false at

throw_reorder: bool = False,

but there seems to be no way to toggle throw_reorder other than skipping the validation step.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions