diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2f28e9f952e..a058bdaf38a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: '3.x' - name: Install dependencies run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index baa912a8a3d..b6d5930dd17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,11 +35,11 @@ jobs: resolution: highest extras: ci,optional - os: ubuntu-latest - python: "3.12" + python: '>3.9' resolution: lowest-direct extras: ci,optional - os: macos-latest - python: "3.10" + python: '3.10' resolution: lowest-direct extras: ci # test with only required dependencies installed diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34a9dba513a..bba0fa50a46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.0 + rev: v1.10.1 hooks: - id: mypy @@ -33,6 +33,7 @@ repos: stages: [ commit, commit-msg ] exclude_types: [ html ] additional_dependencies: [ tomli ] # needed to read pyproject.toml below py3.11 + exclude: src/pymatgen/analysis/aflow_prototypes.json - repo: https://github.com/MarcoGorelli/cython-lint rev: v0.16.2 @@ -42,7 +43,7 @@ repos: - id: double-quote-cython-strings - repo: https://github.com/adamchainz/blacken-docs - rev: 1.16.0 + rev: 1.18.0 hooks: - id: blacken-docs @@ -64,6 +65,6 @@ repos: args: [ --drop-empty-cells, --keep-output ] - repo: https://github.com/RobertCraigie/pyright-python - rev: v1.1.366 + rev: v1.1.369 hooks: - id: pyright diff --git a/dev_scripts/update_spacegroup_data.py b/dev_scripts/update_spacegroup_data.py new file mode 100644 index 00000000000..a4607cdbee7 --- /dev/null +++ b/dev_scripts/update_spacegroup_data.py @@ -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") diff --git a/docs/CHANGES.md b/docs/CHANGES.md index 6b162785e8e..b080903b763 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -6,6 +6,14 @@ nav_order: 4 # Changelog +## v2024.7.18 +- Fix `setuptools` for packaging (#3934) +- Improve Keep Redundant Spaces algorithm for PatchedPhaseDiagram (#3900) +- Add electronic structure methods for Species (#3902) +- Migrate `spglib` to new `SpglibDataset` format with version 2.5.0 (#3923) +- SpaceGroup changes (#3859) +- Add MD input set to FHI-aims (#3896) + ## v2024.6.10 * Fix bug in `update_charge_from_potcar` (#3866) * Fix bug in VASP parameter parsing (@mkhorton) diff --git a/docs/compatibility.md b/docs/compatibility.md index 61bdee2354c..115ed7ebe7e 100644 --- a/docs/compatibility.md +++ b/docs/compatibility.md @@ -67,6 +67,24 @@ Windows and Linux. ## Recent Breaking Changes +### v2024.?.? + +The `symbol` attribute of `SpaceGroup` now always refers to its Hermann-Mauguin symbol +(see [#3859](https://github.com/materialsproject/pymatgen/pull/3859)). In order to replace +the old symbol, run + +```py +from pymatgen.symmetry.groups import SpaceGroup + +try: + new_symbol = SpaceGroup(old_symbol).symbol +except ValueError: + if old_symbol in ["P2_12_121", "I2_12_121"]: + new_symbol = SpaceGroup(old_symbol[:-1]+"_1").symbol + else: + new_symbol = SpaceGroup(old_symbol[:-1]).symbol +``` + ### v2024.5.31 * Update VASP sets to transition `atomate2` to use `pymatgen` input sets exclusively by @esoteric-ephemera in [#3835](https://github.com/materialsproject/pymatgen/pull/3835) diff --git a/docs/modules.html b/docs/modules.html index 8176ffd9a89..45c32066fbe 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -305,15 +305,7 @@

pymatgen
  • pymatgen.analysis.solar package
  • pymatgen.analysis.structure_prediction package
  • pymatgen.io.aims.outputs module