From c830e09517955c88331e1ee12c07dbaf191c9ad4 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 17:40:55 +0100 Subject: [PATCH 01/12] Fix spglib compatability --- amset/electronic_structure/kpoints.py | 7 ++++++- requirements.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/amset/electronic_structure/kpoints.py b/amset/electronic_structure/kpoints.py index 1c8d0ebaf..f89cbedc2 100644 --- a/amset/electronic_structure/kpoints.py +++ b/amset/electronic_structure/kpoints.py @@ -115,12 +115,17 @@ def get_kpoints_tetrahedral( kpoint_mesh = get_kpoint_mesh(structure, kpoint_mesh) atoms = AseAtomsAdaptor().get_atoms(structure) + cell = ( + np.array(atoms.get_cell().T, dtype="double", order="C"), # lattice + np.array(atoms.get_scaled_positions(), dtype="double", order="C"), # positions + np.array(atoms.get_atomic_numbers(), dtype="intc"), # numbers + ) if not symprec: symprec = 1e-8 grid_mapping, grid_address = spglib.get_ir_reciprocal_mesh( - kpoint_mesh, atoms, symprec=symprec, is_time_reversal=time_reversal_symmetry + kpoint_mesh, cell, symprec=symprec, is_time_reversal=time_reversal_symmetry ) full_kpoints = grid_address / kpoint_mesh diff --git a/requirements.txt b/requirements.txt index 9fd27c6fa..86f2e153c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ BoltzTraP2==24.1.1 tqdm==4.66.4 tabulate==0.9.0 memory_profiler==0.61.0 -spglib==2.2.0 +spglib==2.5.0 click==8.1.7 sumo==2.3.8 h5py==3.11.0 From 589162be325a7c771c2c02304962b44a7f2f2160 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 17:58:22 +0100 Subject: [PATCH 02/12] Fix GHA --- .github/workflows/docs.yml | 4 ++-- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d9bb3a9fc..03b58419d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,14 +14,14 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' cache: pip cache-dependency-path: requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy wheel packaging + pip install numpy==1.25.0 wheel packaging pip install -r requirements.txt pip install -e .[docs] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84749877c..ec2b6e50b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy wheel packaging setuptools setuptools_scm + pip install numpy==1.25.0 wheel packaging setuptools setuptools_scm pip install -r requirements.txt pip install -e .[tests] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 886518b43..be49cddcd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,14 +26,14 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.10' cache: pip cache-dependency-path: requirements.txt - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy wheel packaging + pip install numpy==1.25.0 wheel packaging pip install -r requirements.txt pip install -e .[docs] @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9"] + python-version: ["3.10"] steps: - uses: actions/checkout@v4 From 29384fa7d6e90ae8917e81c735826859c7f27bd1 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 17:59:55 +0100 Subject: [PATCH 03/12] Fix spglib in tests --- tests/electronic_structure/test_symmetry.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/electronic_structure/test_symmetry.py b/tests/electronic_structure/test_symmetry.py index 184cab231..f72377bb1 100644 --- a/tests/electronic_structure/test_symmetry.py +++ b/tests/electronic_structure/test_symmetry.py @@ -277,7 +277,12 @@ def _sort_kpoints(kp): # generate true k-points and IR k-points using spglib atoms = AseAtomsAdaptor.get_atoms(symmetry_structure) - mapping, addresses = get_ir_reciprocal_mesh(mesh, atoms, is_shift=shift) + cell = ( + np.array(atoms.get_cell().T, dtype="double", order="C"), # lattice + np.array(atoms.get_scaled_positions(), dtype="double", order="C"), # positions + np.array(atoms.get_atomic_numbers(), dtype="intc"), # numbers + ) + mapping, addresses = get_ir_reciprocal_mesh(mesh, cell, is_shift=shift) true_kpoints = addresses / mesh + shift / (mesh * 2) true_kpoints = _kpoints_to_first_bz(true_kpoints) true_kpoints_sort = _sort_kpoints(true_kpoints) From c52da4b930401425618b22ff175980d112150c69 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:05:08 +0100 Subject: [PATCH 04/12] Update docs requirement --- setup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 4ed4c579d..969c542d5 100644 --- a/setup.py +++ b/setup.py @@ -51,12 +51,12 @@ ], extras_require={ "docs": [ - "mkdocs==1.5.3", - "mkdocs-material==9.5.16", + "mkdocs==1.6.0", + "mkdocs-material==9.5.30", "mkdocs-minify-plugin==0.8.0", - "mkdocs-macros-plugin==1.0.4", + "mkdocs-macros-plugin==1.0.5", "markdown-include==0.8.1", - "markdown-katex==202112.1034", + "markdown-katex==202406.1035", ], "tests": ["pytest==8.2.1", "pytest-cov==5.0.0"], "all-electron": ["pawpyseed==0.7.1"], From 101b0d46603c9319df27878dbd34390075198d5a Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:12:06 +0100 Subject: [PATCH 05/12] Autoupdate pre-commit --- .pre-commit-config.yaml | 10 +++++----- amset/constants.py | 1 + amset/electronic_structure/dos.py | 1 + amset/scattering/calculate.py | 24 ++++++++++++++---------- amset/tools/cli.py | 1 + amset/util.py | 1 + tests/core/test_run.py | 1 + 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a78fab348..b4943866b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,28 @@ repos: - repo: https://github.com/myint/autoflake - rev: v2.2.1 + rev: v2.3.1 hooks: - id: autoflake args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.1.0 hooks: - id: flake8 files: ^amset/ args: [--max-line-length=125, "--extend-ignore=E203,W503"] language_version: python3 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/isort - rev: 5.13.0 + rev: 5.13.2 hooks: - id: isort name: isort (python) diff --git a/amset/constants.py b/amset/constants.py index 24db8b962..73b51f35a 100644 --- a/amset/constants.py +++ b/amset/constants.py @@ -1,4 +1,5 @@ """Module defining constants and default parameters.""" + import numpy as np from monty.serialization import loadfn from pkg_resources import resource_filename diff --git a/amset/electronic_structure/dos.py b/amset/electronic_structure/dos.py index ecfe37f0a..148e9f6a3 100644 --- a/amset/electronic_structure/dos.py +++ b/amset/electronic_structure/dos.py @@ -1,6 +1,7 @@ """ Customised implementation of FermiDos. Will Move back to pymatgen at some point. """ + import logging from typing import Dict, Optional, Tuple, Union diff --git a/amset/scattering/calculate.py b/amset/scattering/calculate.py index 24cd1cec6..6c2650173 100644 --- a/amset/scattering/calculate.py +++ b/amset/scattering/calculate.py @@ -172,10 +172,10 @@ def __init__( # calculate the coefficients for all bands and k-point simultaneously try: - self._coeffs[ - spin - ] = self.amset_data.overlap_calculator.get_coefficients( - spin, spin_b_idxs, self.amset_data.kpoints[spin_k_idxs] + self._coeffs[spin] = ( + self.amset_data.overlap_calculator.get_coefficients( + spin, spin_b_idxs, self.amset_data.kpoints[spin_k_idxs] + ) ) # because we are only storing the coefficients for the # band/k-points we want, we need a way of mapping from the original @@ -232,9 +232,11 @@ def initialize_workers(self): # deformation potential is a large tensor that should be put into shared memory elastic_scatterers = [ - s.to_reference() - if isinstance(s, AcousticDeformationPotentialScattering) - else s + ( + s.to_reference() + if isinstance(s, AcousticDeformationPotentialScattering) + else s + ) for s in self.elastic_scatterers ] @@ -562,9 +564,11 @@ def scattering_worker( raise ValueError(f"Unrecognised overlap type: {overlap_type}") elastic_scatterers = [ - AcousticDeformationPotentialScattering.from_reference(*s) - if isinstance(s, tuple) - else s + ( + AcousticDeformationPotentialScattering.from_reference(*s) + if isinstance(s, tuple) + else s + ) for s in elastic_scatterers ] diff --git a/amset/tools/cli.py b/amset/tools/cli.py index c3b0b4ce3..7055d24b2 100644 --- a/amset/tools/cli.py +++ b/amset/tools/cli.py @@ -1,6 +1,7 @@ """ This module contains a script for using amset from the command line. """ + import warnings import click diff --git a/amset/util.py b/amset/util.py index fb4ed2915..20e32b800 100644 --- a/amset/util.py +++ b/amset/util.py @@ -1,6 +1,7 @@ """ Module defining utility functions. """ + import collections import copy import logging diff --git a/tests/core/test_run.py b/tests/core/test_run.py index 5ca96bf46..736bb9cac 100644 --- a/tests/core/test_run.py +++ b/tests/core/test_run.py @@ -19,6 +19,7 @@ - don't write mesh, using projections + deformation potential tuple + single elastic constant/piezoelectric for K2ReF6 (tricky spin polarized system) """ + from copy import deepcopy from pathlib import Path from typing import Any, Dict From 23701a273f673ee5a55db2c784eb10ae03805424 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:16:26 +0100 Subject: [PATCH 06/12] Fix failing test --- tests/core/test_run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_run.py b/tests/core/test_run.py index 736bb9cac..f0fd8bc84 100644 --- a/tests/core/test_run.py +++ b/tests/core/test_run.py @@ -191,7 +191,7 @@ def test_run_tricky_spin_polarized(band_structure_data): files = ["transport", "!mesh"] scats = ["ADP"] transport = { - ("mobility", ("overall", (0, 0))): 1.261213643946453, + ("mobility", ("overall", (0, 0))): 1.3902421061518926, ("seebeck", (0, 0)): 1356.1341462605026, } From 87e8d49566d1508eb8d8da14d4dcf408b92ee88b Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:18:56 +0100 Subject: [PATCH 07/12] Update requirements --- requirements.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 86f2e153c..c8c8f77a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -pymatgen==2024.4.13 -scipy==1.13.1 -monty==2024.5.24 -matplotlib==3.9.0 -BoltzTraP2==24.1.1 +pymatgen==2024.7.18 +scipy==1.14.0 +monty==2024.7.12 +matplotlib==3.9.1 +BoltzTraP2==24.7.2 tqdm==4.66.4 tabulate==0.9.0 memory_profiler==0.61.0 @@ -10,6 +10,6 @@ spglib==2.5.0 click==8.1.7 sumo==2.3.8 h5py==3.11.0 -pyFFTW==0.13.1 -interpolation==2.2.4 -numba==0.58.0 +pyFFTW==0.14.0 +interpolation==2.2.7 +numba==0.60.0 From 0fbcd2e350db953559b150e38c61b94e79e9ca18 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:21:10 +0100 Subject: [PATCH 08/12] Add cython --- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec2b6e50b..0e0d161b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 wheel packaging setuptools setuptools_scm + pip install numpy==1.25.0 cython wheel packaging setuptools setuptools_scm pip install -r requirements.txt pip install -e .[tests] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be49cddcd..66a539da3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 wheel packaging + pip install numpy==1.25.0 cython wheel packaging pip install -r requirements.txt pip install -e .[docs] @@ -58,7 +58,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 wheel packaging + pip install numpy==1.25.0 cython wheel packaging pip install -r requirements.txt pip install -e .[tests] From a18c5fba6a2a974c210c1f3d543d4171cd91e72a Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:26:12 +0100 Subject: [PATCH 09/12] Update pytest --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 969c542d5..add17a1e9 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ "markdown-include==0.8.1", "markdown-katex==202406.1035", ], - "tests": ["pytest==8.2.1", "pytest-cov==5.0.0"], + "tests": ["pytest==8.3.1", "pytest-cov==5.0.0"], "all-electron": ["pawpyseed==0.7.1"], "dev": ["pre-commit==3.7.1"], }, From 48baa43a6b710526ee167f982b29afd8c425aba6 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:27:36 +0100 Subject: [PATCH 10/12] Update numpy pin --- .github/workflows/release.yml | 2 +- .github/workflows/tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e0d161b8..b1a498066 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 cython wheel packaging setuptools setuptools_scm + pip install numpy==2.0.1 cython wheel packaging setuptools setuptools_scm pip install -r requirements.txt pip install -e .[tests] diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66a539da3..d4cf9c285 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 cython wheel packaging + pip install numpy==2.0.1 cython wheel packaging pip install -r requirements.txt pip install -e .[docs] @@ -58,7 +58,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==1.25.0 cython wheel packaging + pip install numpy==2.0.1 cython wheel packaging pip install -r requirements.txt pip install -e .[tests] From 3d90f9b27008caf0697d96bde61aa3ec540f854b Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:34:52 +0100 Subject: [PATCH 11/12] Update changelog --- amset/__init__.py | 2 +- docs/src/changelog.md | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/amset/__init__.py b/amset/__init__.py index b4ed79e09..e427a5547 100644 --- a/amset/__init__.py +++ b/amset/__init__.py @@ -1 +1 @@ -__version__ = "0.4.20" +__version__ = "0.4.21" diff --git a/docs/src/changelog.md b/docs/src/changelog.md index ae38dde20..550a978d4 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -1,10 +1,13 @@ # Change log +## v0.4.21 + +Fix compatbility with spglib. + ## v0.4.20 Fix intermittent casting bug. - ## v0.4.19 Fix numpy deprecations. From 24689a321669ae0d56d20ef3280161a144f9b217 Mon Sep 17 00:00:00 2001 From: utf Date: Tue, 23 Jul 2024 18:39:36 +0100 Subject: [PATCH 12/12] Update citation --- CITATION.cff | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 3c2d61bc3..384f11961 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,17 +1,4 @@ cff-version: 1.2.0 -message: | - If you use AMSET in your research, please cite the following: -title: 'Efficient calculation of carrier scattering rates from first principles' -version: 0.4.17 # replace with whatever version you use -doi: 10.1038/s41467-021-22440-5 -date-released: 2021-04-13 -url: https://github.com/hackingmaterials/amset -issn: 2041-1723 -journal: Nature Communications -pages: 2222 -volume: 12 -year: 2021 -type: software authors: - family-names: Ganose given-names: Alex M. @@ -27,3 +14,34 @@ authors: - family-names: Jain given-names: Anubhav orcid: https://orcid.org/0000-0001-5893-9967 +doi: 10.1038/s41467-021-22440-5 +title: 'Efficient calculation of carrier scattering rates from first principles' +message: | + If you use AMSET in your research, please cite the following: +preferred-citation: + authors: + - family-names: Ganose + given-names: Alex M. + orcid: https://orcid.org/0000-0002-4486-3321 + - family-names: Park + given-names: Junsoo + - family-names: Faghaninia + given-names: Alireza + - family-names: Woods-Robinson + given-names: Rachel + - family-names: Persson + given-names: Kristin A. + - family-names: Jain + given-names: Anubhav + orcid: https://orcid.org/0000-0001-5893-9967 + title: 'Efficient calculation of carrier scattering rates from first principles' + version: 0.4.17 # replace with whatever version you use + date-published: 2021-04-13 + doi: 10.1038/s41467-021-22440-5 + url: https://www.nature.com/articles/s41467-021-22440-5 + issn: 2041-1723 + journal: Nature Communications + pages: 2222 + volume: 12 + year: 2021 + type: article