Skip to content

Commit

Permalink
Merge pull request #898 from hackingmaterials/fix-spglib
Browse files Browse the repository at this point in the history
Fix spglib compatability
  • Loading branch information
utf authored Jul 23, 2024
2 parents 96a7727 + 24689a3 commit b22d0fd
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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==2.0.1 cython wheel packaging setuptools setuptools_scm
pip install -r requirements.txt
pip install -e .[tests]
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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==2.0.1 cython wheel packaging
pip install -r requirements.txt
pip install -e .[docs]
Expand All @@ -44,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4
Expand All @@ -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==2.0.1 cython wheel packaging
pip install -r requirements.txt
pip install -e .[tests]
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
44 changes: 31 additions & 13 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
2 changes: 1 addition & 1 deletion amset/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.20"
__version__ = "0.4.21"
1 change: 1 addition & 0 deletions amset/constants.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions amset/electronic_structure/dos.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 6 additions & 1 deletion amset/electronic_structure/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 14 additions & 10 deletions amset/scattering/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
]

Expand Down Expand Up @@ -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
]

Expand Down
1 change: 1 addition & 0 deletions amset/tools/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This module contains a script for using amset from the command line.
"""

import warnings

import click
Expand Down
1 change: 1 addition & 0 deletions amset/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Module defining utility functions.
"""

import collections
import copy
import logging
Expand Down
5 changes: 4 additions & 1 deletion docs/src/changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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
spglib==2.2.0
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
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
],
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"],
"tests": ["pytest==8.3.1", "pytest-cov==5.0.0"],
"all-electron": ["pawpyseed==0.7.1"],
"dev": ["pre-commit==3.7.1"],
},
Expand Down
3 changes: 2 additions & 1 deletion tests/core/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -190,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,
}

Expand Down
7 changes: 6 additions & 1 deletion tests/electronic_structure/test_symmetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b22d0fd

Please sign in to comment.