-
Notifications
You must be signed in to change notification settings - Fork 860
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replaced SpaceGroup symbol attribute with its Hermann-Mauguin symbol, corrected Schoenflies point group attribute, changed handling of rhombohedral space group type settings by adding a SpaceGroup hexagonal bool attribute, modified and added tests. * Removed crystal class key from symm_ops.json. * Test for correct setting of hexagonal attribute when instantiating from int number. * Noted change and replacement option for SpaceGroup symbol in compatibility.md * Added from_space_group class method to PointGroup, added tests * Added mapping to standard setting in PointGroup.from_space_group(), modified symm_ops.json and symm_data.json (documented in dev_scripts/update_space_group_data.py) to have same notation, added point group and short Hermann Mauguin symbol to symm_ops, fixed some typos, fixed rhombohedral space group type orbit issue. * Updated core/test_surface.py to assign lattice as in SpaceGroup is_compatible(). * Modified databases and SpaceGroup init to ensure compatibility with non-underscore space group notations. * Added tests for issue #3862, modified full_symbol and point_group attribute setting. * Modified PointGroup.from_space_group() to also handle symbols with identity blickrichtungen and missed underscores, added warning to SpaceGroup init if full symbol is not available (for non-standard settings), added tests. * Added test for warning if SpaceGroup.full_symbol is not available. * Removed warning test. * tweak incompat warning * add test_full_symbol_warning * add author + date to dev_scripts/update_spacegroup_data.py * typos * warning occurs only once, move test_full_symbol_warning up as workaround to annoying test pollution from side effects to std lib warnings registry * Updated compatibility.md to also handle old symbol replacement of P2_12_12_1 and I2_12_12_1. * pre-commit auto-fixes * Updated dev script path to new src layout. --------- Signed-off-by: Katharina Ueltzen <94910364+kaueltzen@users.noreply.github.com> Co-authored-by: Janosh Riebesell <janosh.riebesell@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: J. George <JaGeo@users.noreply.github.com>
- Loading branch information
1 parent
35b1f44
commit c2c5ea6
Showing
12 changed files
with
258 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"""Script to update symm_ops.json and symm_data.yaml in symmetry module due to issues #3845 and #3862. | ||
symm_ops.json: | ||
- adds Hermann_mauguin point group key and short Hermann Mauguin space group symbol | ||
- converts screw axis notation to symm_data standard | ||
symm_data.json | ||
- removes mapping of rhombohedral space group types onto symbol + appended H | ||
- replaces I/P2_12_121 key with I/P2_12_12_1 | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
from monty.serialization import dumpfn, loadfn | ||
from pymatgen.symmetry.groups import PointGroup | ||
|
||
__author__ = "Katharina Ueltzen @kaueltzen" | ||
__date__ = "2024-06-06" | ||
|
||
SYMM_OPS = loadfn("../src/pymatgen/symmetry/symm_ops.json") | ||
SYMM_DATA = loadfn("../src/pymatgen/symmetry/symm_data.json") | ||
|
||
|
||
def convert_symmops_to_sg_encoding(symbol: str) -> str: | ||
""" | ||
Utility function to convert SYMMOPS space group type symbol notation | ||
into SYMM_DATA["space_group_encoding"] key notation with underscores before | ||
translational part of screw axes. | ||
Args: | ||
symbol (str): "hermann_mauguin" or "universal_h_m" key of symmops.json | ||
Returns: | ||
symbol in the format of SYMM_DATA["space_group_encoding"] keys | ||
""" | ||
symbol_representation = symbol.split(":") | ||
representation = ":" + "".join(symbol_representation[1].split(" ")) if len(symbol_representation) > 1 else "" | ||
|
||
blickrichtungen = symbol_representation[0].split(" ") | ||
blickrichtungen_new = [] | ||
for br in blickrichtungen: | ||
if len(br) > 1 and br[0].isdigit() and br[1].isdigit(): | ||
blickrichtungen_new.append(br[0] + "_" + br[1:]) | ||
else: | ||
blickrichtungen_new.append(br) | ||
return "".join(blickrichtungen_new) + representation | ||
|
||
|
||
def remove_identity_from_full_hermann_mauguin(symbol: str) -> str: | ||
""" | ||
Utility function to remove identity along blickrichtung (except in P1). | ||
Args: | ||
symbol (str): "hermann_mauguin" key of symmops.json | ||
Returns: | ||
short "hermann_mauguin" key | ||
""" | ||
if symbol in ("P 1", "C 1", "P 1 "): | ||
return symbol | ||
blickrichtungen = symbol.split(" ") | ||
blickrichtungen_new = [] | ||
for br in blickrichtungen: | ||
if br != "1": | ||
blickrichtungen_new.append(br + " ") | ||
return "".join(blickrichtungen_new) | ||
|
||
|
||
new_symm_data = {} | ||
for k, v in SYMM_DATA["space_group_encoding"].items(): | ||
if k.endswith("H"): | ||
new_symm_data[k.removesuffix("H")] = v | ||
elif k == "I2_12_121": | ||
new_symm_data["I2_12_12_1"] = v | ||
elif k == "P2_12_121": | ||
new_symm_data["P2_12_12_1"] = v | ||
else: | ||
new_symm_data[k] = v | ||
|
||
SYMM_DATA["space_group_encoding"] = new_symm_data | ||
|
||
for spg_idx, spg in enumerate(SYMM_OPS): | ||
if "(" in spg["hermann_mauguin"]: | ||
SYMM_OPS[spg_idx]["hermann_mauguin"] = spg["hermann_mauguin"].split("(")[0] | ||
|
||
short_h_m = remove_identity_from_full_hermann_mauguin(SYMM_OPS[spg_idx]["hermann_mauguin"]) | ||
SYMM_OPS[spg_idx]["short_h_m"] = convert_symmops_to_sg_encoding(short_h_m) | ||
SYMM_OPS[spg_idx]["hermann_mauguin_u"] = convert_symmops_to_sg_encoding(spg["hermann_mauguin"]) | ||
|
||
for spg_idx, spg in enumerate(SYMM_OPS): | ||
try: | ||
pg = PointGroup.from_space_group(spg["short_h_m"]) | ||
except AssertionError as e: | ||
print(spg, str(e)) | ||
sys.exit(1) | ||
SYMM_OPS[spg_idx]["point_group"] = pg.symbol | ||
|
||
dumpfn(SYMM_DATA, "../src/pymatgen/symmetry/symm_data.json") | ||
dumpfn(SYMM_OPS, "../src/pymatgen/symmetry/symm_ops.json") |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.