Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatch in Angles After Z-matrix to XYZ Conversion in zmat_to_xyz #779

Open
LeenFahoum opened this issue Dec 26, 2024 · 2 comments
Open
Assignees

Comments

@LeenFahoum
Copy link
Contributor

LeenFahoum commented Dec 26, 2024

Describe the bug
When converting a Z-matrix to XYZ coordinates using the zmat_to_xyz function, the angle A_8_2_1 is incorrectly calculated. It is defined as 77.4° in the Z-matrix, but after conversion and visualization in GaussView, it is shown as 51.93824°. All other parameters appear to be converted correctly.
This is just one example, but I’m encountering the same issue with other molecules as well, consistently with the angle A_8_2_1.

How to reproduce

zmat = {
    'symbols': ('C', 'O', 'C', 'O', 'H', 'H', 'H', 'H', 'O', 'H', 'H'),
    'coords': (
        (None, None, None),
        ('R_1_0', None, None),
        ('R_2_1', 'A_2_1_0', None),
        ('R_3_2', 'A_3_2_1', 'D_3_2_1_0'),
        ('R_4_0', 'A_4_0_1', 'D_4_0_1_3'),
        ('R_5|6_0|0', 'A_5|6_0|0_1|1', 'D_5_0_1_4'),
        ('R_5|6_0|0', 'A_5|6_0|0_1|1', 'D_6_0_1_5'),
        ('R_7_2', 'A_7_2_3', 'D_7_2_3_6'),
        ('R_8_2', 'A_8_2_1', 'D_8_2_7_3'),
        ('R_9_8', 'A_9_8_2', 'D_9_8_2_1'),
        ('R_10_8', 'A_10_8_9', 'D_10_8_9_2')
    ),
    'vars': {
        'R_1_0': 1.4279748215793069, 'R_2_1': 1.7627308829567612, 'A_2_1_0': 113.78880933352458,
        'R_3_2': 1.220223245519294, 'A_3_2_1': 126.68953118378808, 'D_3_2_1_0': 6.273929367455621e-06,
        'R_4_0': 1.093536138062114, 'A_4_0_1': 108.0618680369275, 'D_4_0_1_3': 61.484528505772055,
        'R_7_2': 1.1010626883230803, 'A_7_2_3': 124.35232167955662, 'D_7_2_3_6': 199.80067229824692,
        'R_8_2': 1.85, 'A_8_2_1': 77.4, 'D_8_2_7_3': 140,
        'R_9_8': 1.21, 'A_9_8_2': 70, 'D_9_8_2_1': 1.64,
        'R_10_8': 0.97, 'A_10_8_9': 111, 'D_10_8_9_2': 103
    },
    'map': {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10}
}

xyz = zmat_to_xyz(zmat)
print(xyz)

To reproduce the issue, convert the Z-matrix using the zmat_to_xyz function. Next, visualize the resulting XYZ coordinates in GaussView and examine the geometric structure. Compare the angle A_8_2_1 in the XYZ output to its defined value in the Z-matrix (77.4°) and note the discrepancy.

Expected behavior
The angle A_8_2_1 should match its defined value in the Z-matrix (77.4°).

Additional context
Gaussian successfully computes the correct angle using the same Z-matrix, so the discrepancy appears to be specific to ARC’s zmat_to_xyz function.
- Observed XYZ from zmat_to_xyz:

C          -0.25870627  -0.85853197  -1.53345513
O          -0.25870627  -0.85853197  -0.10548031
C          -0.25870627   0.75443460   0.60554643
O          -0.25870638   1.81623563   0.00427832
H           0.65482121  -0.36220752  -1.87249919
H          -0.25870630  -1.88367885  -1.91708716
H          -1.11876827  -0.30066148  -1.91708716
H          -0.29397484   0.66137562   1.70210249
O           0.91829111  -0.63533633   0.93068322
H           0.10796546  -0.96617019   0.09520653
H           0.70717317  -1.02539152   1.79334547

- Observed XYZ from Gaussian:

C                  0.00000000    0.00000000    0.00000000
O                  0.00000000    0.00000000    1.42800000
C                  1.61293842    0.00000000    2.13901402
O                  2.67471880    0.00000000    1.53775661
H                  0.49630837   -0.91349690   -0.33903344
H                 -1.02516826   -0.00000000   -0.38363940
H                  0.55788139    0.86008042   -0.38363940
H                  1.51987759    0.03526445    3.23560752
O                  0.68578419    1.16051832    3.24177521
H                 -0.05359017    0.71661428    2.39302628
H                  0.95208240    2.06894661    3.03024906
@kfir4444
Copy link
Collaborator

Hey Leen,
Thanks for sharing this issue!
I tried to run you code, but I got an error:

>>> zmat = {
'symbols': ('C', 'O', 'C', 'O', 'H', 'H', 'H', 'H', 'O', 'H', 'H'),
    'coords': (
        (None, None, None),
        ('R_1_0', None, None),
        ('R_2_1', 'A_2_1_0', None),
        ('R_3_2', 'A_3_2_1', 'D_3_2_1_0'),
        ('R_4_0', 'A_4_0_1', 'D_4_0_1_3'),
        ('R_5|6_0|0', 'A_5|6_0|0_1|1', 'D_5_0_1_4'),
        ('R_5|6_0|0', 'A_5|6_0|0_1|1', 'D_6_0_1_5'),
        ('R_7_2', 'A_7_2_3', 'D_7_2_3_6'),
        ('R_8_2', 'A_8_2_1', 'D_8_2_7_3'),
        ('R_9_8', 'A_9_8_2', 'D_9_8_2_1'),
        ('R_10_8', 'A_10_8_9', 'D_10_8_9_2')
    ),
    'vars': {
        'R_1_0': 1.4279748215793069, 'R_2_1': 1.7627308829567612, 'A_2_1_0': 113.78880933352458,
        'R_3_2': 1.220223245519294, 'A_3_2_1': 126.68953118378808, 'D_3_2_1_0': 6.273929367455621e-06,
        'R_4_0': 1.093536138062114, 'A_4_0_1': 108.0618680369275, 'D_4_0_1_3': 61.484528505772055,
        'R_7_2': 1.1010626883230803, 'A_7_2_3': 124.35232167955662, 'D_7_2_3_6': 199.80067229824692,
        'R_8_2': 1.85, 'A_8_2_1': 77.4, 'D_8_2_7_3': 140,
        'R_9_8': 1.21, 'A_9_8_2': 70, 'D_9_8_2_1': 1.64,
        'R_10_8': 0.97, 'A_10_8_9': 111, 'D_10_8_9_2': 103
    },
    'map': {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10}
}

>>> xyz = zmat_to_xyz(zmat)
    Traceback (most recent call last): (...)
    arc.exceptions.ZMatError: The parameter R_5|6_0|0 was not found in the "vars" section of the zmat

And indeed, the parameters in the coords section does include R_5|6_0|0 which is not in the vars section of the zmat.
Please check and see if you are getting the same error, fix it and reattach the zmat, so I could recheck it?

@kfir4444 kfir4444 self-assigned this Dec 27, 2024
@LeenFahoum
Copy link
Contributor Author

LeenFahoum commented Dec 29, 2024

Hi Kfir,
Thanks for pointing that out! You're correct that the initial Z-matrix was missing the parameter R_5|6_0|0 in the vars section. I've fixed this in the updated Z-matrix below:

from arc.species.converter import zmat_to_xyz
zmat = {'symbols': ('C', 'O', 'C', 'O', 'H', 'H', 'H', 'H', 'O', 'H', 'H'),
'coords': ((None, None, None), ('R_1_0', None, None), ('R_2_1', 'A_2_1_0', None), ('R_3_2', 'A_3_2_1', 'D_3_2_1_0'),
           ('R_4_0', 'A_4_0_1', 'D_4_0_1_3'), ('R_5|6_0|0', 'A_5|6_0|0_1|1', 'D_5_0_1_4'), ('R_5|6_0|0', 'A_5|6_0|0_1|1',
            'D_6_0_1_5'), ('R_7_2', 'A_7_2_3', 'D_7_2_3_6'), ('R_8_2', 'A_8_2_1', 'D_8_2_7_3'), ('R_9_8', 'A_9_8_2', 'D_9_8_2_1'),
            ('R_10_8', 'A_10_8_9', 'D_10_8_9_2')),
'vars': {'R_1_0': 1.4279748215793069, 'R_2_1': 1.7627308829567612, 'A_2_1_0': 113.78880933352458, 'R_3_2': 1.220223245519294,
         'A_3_2_1': 126.68953118378808, 'D_3_2_1_0': 6.273929367455621e-06, 'R_4_0': 1.093536138062114, 'A_4_0_1': 108.0618680369275,
         'D_4_0_1_3': 61.484528505772055, 'D_5_0_1_4': 118.51547524959838, 'D_6_0_1_5': 122.96904766876776, 'R_7_2': 1.1010626883230803,
         'A_7_2_3': 124.35232167955662, 'D_7_2_3_6': 199.80067229824692, 'R_5|6_0|0': 1.0945773946114277, 'A_5|6_0|0_1|1': 110.51693106746612,
         'R_8_2': 1.85, 'A_8_2_1': 77.4, 'D_8_2_7_3': 140, 'R_9_8': 1.21, 'A_9_8_2': 70, 'D_9_8_2_1': 1.64, 'R_10_8': 0.97, 'A_10_8_9': 111,
         'D_10_8_9_2': 103}, 'map': {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10}}

xyz = zmat_to_xyz(zmat)
print(xyz)

However, the issue I originally raised still occurs even after this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants