Skip to content

Bug: Symmetry group of caffeine #3

Description

@joerivan

ZeroDivisionError when analysing caffeine molecule classified as Cs

I encountered a crash when running pyrrhotite on a caffeine molecule from an .xyz file. I have attached/uploaded the caffeine.xyz file to this issue.

Observed behaviour

The molecule appears to be classified as point group Cs, but the program crashes while labelling reflection planes:

line 123, in __init__ 
    self._label_symmetry_operations()
ine 1087, in _label_symmetry_operations 
    self._label_reflection_planes()
line 1164, in _label_reflection_planes 
    self._label_reflection_planes_cyclic_dihedral()
line 1205, in _label_reflection_planes_cyclic_dihedral 
    divisor = 2.0 * np.pi / pg_label.order
ZeroDivisionError: float division by zero

Expected behaviour

The program should complete normally and report the Cs symmetry operation, for example:

Point group : Cs
Rotor class : AsymmetricTop
Operations  : 1 found
  σ

Possible cause

It looks like Cs is being routed through the cyclic/dihedral reflection-plane labelling code. However, for Cs, the point-group order appears to be 0, so this line fails:

divisor = 2.0 * np.pi / pg_label.order

Since Cs only has a single mirror plane, there may not be a meaningful σh/σv/σd distinction to compute. The mirror plane could simply remain labelled as σ.

Proposed fix

A minimal fix would be to special-case point groups with order == 0 at the start of _label_reflection_planes_cyclic_dihedral():

def _label_reflection_planes_cyclic_dihedral(self) -> None:
     """Label σh, σv, σd, σv' for cyclic and dihedral groups."""
     pg_label = self._point_group.label
 
+    # Special low-symmetry groups such as Cs do not have a finite
+    # principal rotation order.  Their mirror operation should remain
+    # labelled as plain σ; there is no σh/σv/σd distinction to compute.
+    if pg_label.order == 0:
+        return
+
     divisor = 2.0 * np.pi / pg_label.order

Alternatively, Cs could be excluded earlier from the cyclic/dihedral reflection-plane labelling path and handled explicitly as a low-symmetry special case.

caffeine.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions