Skip to content

Improve Performance of Symmetry Constraints via Lookup Table #26

@AndrewSazonov

Description

@AndrewSazonov

Problem

Applying symmetry constraints is currently slow, primarily due to the use of the Cryspy method:
get_symop_pcentr_multiplicity_letter_site_symmetry_coords_xyz_2(...),
which probably parses the wyckoff.dat file.

Proposed

We should replace it with a prebuilt lookup table stored as a Python file (e.g. space_group_lookup_table.py) containing a dictionary that maps IT_number and IT_coordinate_system_code to preformatted symmetry data.

This dictionary would store values such as:

  • crystal_system (e.g. "orthorhombic")
  • IT_coordinate_system_code (e.g. "cab")
  • symmetry operations (coords_xyz)
  • multiplicity, letter, site_symmetry, etc.

Where

  • All values except two can be directly extracted from wyckoff.dat or obtained via Cryspy.
  • IT_coordinate_system_code (e.g. cab) is not in wyckoff.dat, but can be obtained via Cryspy.
  • crystal_system is also not present and needs to be fetched from Cryspy.

Implementation

  • Create space_group_lookup_table.py (or similar) under easydiffraction/crystallography/.
  • Import the dictionary into crystallography.py.
  • Replace the call at line 89:
    result = get_symop_pcentr_multiplicity_letter_site_symmetry_coords_xyz_2(it_number, it_coordinate_system_code)

with a direct lookup from our dictionary. Probably, the following code will need to be adapted.

Example of the Suggested Dictionary:

space_groups = {
    (62, "cab"): {
        "IT_number": 62,
        "setting": 3,
        "IT_coordinate_system_code": "cab",
        "name_H-M_alt": "P b n m",
        "crystal_system": "orthorhombic",
        "Wyckoff_positions": {
            "d": {
                "multiplicity": 8,
                "site_symmetry": "1",
                "coords_xyz": [
                    "(x,y,z)", "(x+1/2,-y+1/2,-z)", "(-x,-y,z+1/2)", "(-x+1/2,y+1/2,-z+1/2)",
                    "(-x,-y,-z)", "(-x+1/2,y+1/2,z)", "(x,y,-z+1/2)", "(x+1/2,-y+1/2,z+1/2)"
                ]
            },
            "c": {
                "multiplicity": 4,
                "site_symmetry": ".m.",
                "coords_xyz": [
                    "(x,y,1/4)", "(x+1/2,-y+1/2,3/4)", "(-x,-y,3/4)", "(-x+1/2,y+1/2,1/4)"
                ]
            },
            "b": {
                "multiplicity": 4,
                "site_symmetry": "-1",
                "coords_xyz": [
                    "(1/2,0,0)", "(0,1/2,0)", "(1/2,0,1/2)", "(0,1/2,1/2)"
                ]
            },
            "a": {
                "multiplicity": 4,
                "site_symmetry": "-1",
                "coords_xyz": [
                    "(0,0,0)", "(1/2,1/2,0)", "(0,0,1/2)", "(1/2,1/2,1/2)"
                ]
            }
        }
    },
    (199, "1"): {
        "IT_number": 199,
        "setting": 1,
        "IT_coordinate_system_code": "1",
        "name_H-M_alt": "I 21 3",
        "crystal_system": "cubic",
        "Wyckoff_positions": {
            "c": {
                "multiplicity": 24,
                "site_symmetry": "1",
                "coords_xyz": [
                    "(x,y,z)", "(-x+1/2,-y,z+1/2)", "(-x,y+1/2,-z+1/2)", "(x+1/2,-y+1/2,-z)",
                    "(z,x,y)", "(z+1/2,-x+1/2,-y)", "(-z+1/2,-x,y+1/2)", "(-z,x+1/2,-y+1/2)",
                    "(y,z,x)", "(-y,z+1/2,-x+1/2)", "(y+1/2,-z+1/2,-x)", "(-y+1/2,-z,x+1/2)"
                ]
            },
            "b": {
                "multiplicity": 12,
                "site_symmetry": "2..",
                "coords_xyz": [
                    "(x,0,1/4)", "(-x+1/2,0,3/4)", "(1/4,x,0)",
                    "(3/4,-x+1/2,0)", "(0,1/4,x)", "(0,3/4,-x+1/2)"
                ]
            },
            "a": {
                "multiplicity": 8,
                "site_symmetry": ".3.",
                "coords_xyz": [
                    "(x,x,x)", "(-x+1/2,-x,x+1/2)", "(-x,x+1/2,-x+1/2)", "(x+1/2,-x+1/2,-x)"
                ]
            }
        }
    }
}

Metadata

Metadata

Assignees

Labels

[priority] highShould be prioritized soon[scope] enhancementAdds/improves features (major.MINOR.patch)

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions