Skip to content

Commit

Permalink
Merge pull request #51 from SMTG-UCL/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
kavanase authored Jun 5, 2023
2 parents 393098c + 8a98ea2 commit b6aae5d
Show file tree
Hide file tree
Showing 28 changed files with 279 additions and 143 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
max-parallel: 5

matrix:
python-version: ['3.8', '3.9'] # Excluding 3.10 for the moment, as hiphive requires Numpy <1.22 which is incompatible with Python 3.10, should be fixed soon...
python-version: ['3.8', '3.9', '3.10']
# hiphive requires numba -> currently incompatible with Python 3.11

name: Python ${{ matrix.python-version }} Test Pop

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
- name: black
run: |
black --version
black --line-length 88 --color shakenbreak
black --line-length 88 --check --diff --color shakenbreak
black --color shakenbreak
black --check --diff --color shakenbreak
- name: flake8
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repos:
rev: 22.6.0
hooks:
- id: black
args: [--line-length, "88", --color]
args: [--color]

# Check code formatting
- repo: https://github.com/PyCQA/flake8
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
==========

v23.06.03
----------
- Make parsing of `DefectEntry`s more robust.
- Update dependencies (now supporting `python=3.10` due to `numba` updates)
- Refactor `CITATION.cff` to `CITATIONS.md`
- Update docs, formatting and cleanup.

v23.04.27
----------
- Update `numpy` requirement to `numpy>=1.21.2` to fix `numpy.typing.NDArray` import error.
Expand Down
44 changes: 0 additions & 44 deletions CITATION.cff

This file was deleted.

55 changes: 55 additions & 0 deletions CITATIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Citing `ShakeNBreak`
Thank you for using `ShakeNBreak`!

If you have used it in your research, we kindly ask that you cite:
- **Code:** Mosquera-Lois, I. & Kavanagh, S. R.; Walsh, A.; Scanlon, D. O. [ShakeNBreak: Navigating the defect configurational landscape](https://doi.org/10.21105/joss.04817). _Journal of Open Source Software_ 7 (80), 4817, **2022**
- **Theory/Method:** Mosquera-Lois, I. & Kavanagh, S. R.; Walsh, A.; Scanlon, D. O. [Identifying the Ground State Structures of Defects in Solids](https://doi.org/10.1038/s41524-023-00973-1) _npj Comput Mater_ 9, 25 **2023**

You may also find this 'Preview' paper useful, which discusses the general problem of defect structure prediction:
- Mosquera-Lois, I.; Kavanagh, S. R. [In Search of Hidden Defects](https://doi.org/10.1016/j.matt.2021.06.003). _Matter_ 4 (8), 2602-2605, **2021**

## BibTeX
Available as a BibTeX file [here](docs/shakenbreak.bib), or copy the following:
```
@article{SnB_code,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R. and Walsh, Aron and Scanlon, David O.},
title = {{ShakeNBreak}: {Navigating} the defect configurational landscape},
journal = {Journal of Open Source Software},
volume = {7},
number = {80},
pages = {4817},
year = {2022},
doi = {10.21105/joss.04817},
url = {https://joss.theoj.org/papers/10.21105/joss.04817},
eprint = {https://joss.theoj.org/papers/10.21105/joss.04817},
abstract = {Mosquera-Lois et al., (2022). ShakeNBreak: Navigating the defect configurational landscape. Journal of Open Source Software, 7(80), 4817, https://doi.org/10.21105/joss.04817},
}
@article{SnB_theory,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R. and Walsh, Aron and Scanlon, David O.},
title = {Identifying the ground state structures of point defects in solids},
journal = {npj Computational Materials},
volume = {9},
number = {1},
pages = {1--11},
year = {2023}
doi = {10.1038/s41524-023-00973-1},
url = {https://www.nature.com/articles/s41524-023-00973-1},
eprint = {https://www.nature.com/articles/s41524-023-00973-1},
abstract = {Point defects are a universal feature of crystals. Their identification is addressed by combining experimental measurements with theoretical models. The standard modelling approach is, however, prone to missing the ground state atomic configurations associated with energy-lowering reconstructions from the idealised crystallographic environment. Missed ground states compromise the accuracy of calculated properties. To address this issue, we report an approach to navigate the defect configurational landscape using targeted bond distortions and rattling. Application of our workflow to eight materials (CdTe, GaAs, Sb2S3, Sb2Se3, CeO2, In2O3, ZnO, anatase-TiO2) reveals symmetry breaking in each host crystal that is not found via conventional local minimisation techniques. The point defect distortions are classified by the associated physico-chemical factors. We demonstrate the impact of these defect distortions on derived properties, including formation energies, concentrations and charge transition levels. Our work presents a step forward for quantitative modelling of imperfect solids.},
}
@article{SnB_preview,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R.},
title = {In search of hidden defects},
journal = {Matter},
volume = {4},
number = {8},
pages = {2602--2605},
year = {2021},
doi = {10.1016/j.matt.2021.06.003},
url = {https://www.cell.com/matter/abstract/S2590-2385(21)00273-3},
eprint = {https://www.cell.com/matter/abstract/S2590-2385(21)00273-3},
}
```
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ If you use it in your research, please cite:
You may also find this Preview paper useful, which discusses the general problem of defect structure prediction:
- Mosquera-Lois, I.; Kavanagh, S. R. [In Search of Hidden Defects](https://doi.org/10.1016/j.matt.2021.06.003). _Matter_ 4 (8), 2602-2605, **2021**

`BibTeX` entries for these papers are provided in the [`CITATIONS.md`](CITATIONS.md) file.

## Requirements
`ShakeNBreak` is compatible with Python 3.8, 3.9 & 3.10 and requires the following open-source python packages:
* [Pymatgen](https://pymatgen.org/)
Expand Down
2 changes: 1 addition & 1 deletion docs/Contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ workflow to do so and follow the `PEP8 <https://peps.python.org/pep-0008/>`_ sty
.. code:: bash
$ isort . --profile black
$ black --line-length 88 --diff --color shakenbreak
$ black --diff --color shakenbreak
Then run `pycodestyle <https://pycodestyle.pycqa.org/en/latest/>`_ to check the docstrings,
followed by `flake8 <https://flake8.pycqa.org/en/latest/>`_, which will identify any remaining issues.
Expand Down
6 changes: 6 additions & 0 deletions docs/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ ShakeNBreak can be installed using ``pip``:
pip install --user shakenbreak
Alternatively if needed, it can also be installed from ``conda`` with:

.. code:: bash
conda install -c conda-forge shakenbreak
If using ``VASP``, in order for ``ShakeNBreak`` to automatically generate the pseudopotential
input files (``POTCARs``), your local ``VASP`` pseudopotential directory must be set in the ``pymatgen``
configuration file ``$HOME/.pmgrc.yaml`` as follows:
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
author = 'Irea Mosquera-Lois, Seán R. Kavanagh'

# The full version, including alpha/beta/rc tags
release = '23.04.27'
release = '23.06.03'


# -- General configuration ---------------------------------------------------
Expand Down Expand Up @@ -111,7 +111,7 @@

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3.6", None),
"python": ("https://docs.python.org/3.8", None),
"numpy": ("http://docs.scipy.org/doc/numpy/", None),
"pymatgen": ("http://pymatgen.org/", None),
"matplotlib": ("http://matplotlib.org", None),
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ You may also find this Preview paper useful, which discusses the general problem

- Mosquera-Lois, I.; Kavanagh, S. R. `In Search of Hidden Defects`_. *Matter* 4 (8), 2602-2605, **2021**

``BibTeX`` entries for these papers are provided in the repository `CITATIONS.md <https://github.com/SMTG-UCL/ShakeNBreak/blob/main/CITATIONS.md>`_ file.

.. _ShakeNBreak\: Navigating the defect configurational landscape: https://doi.org/10.21105/joss.04817
.. _Journal of Open Source Software: https://doi.org/10.21105/joss.04817
.. _Identifying the Ground State Structures of Defects in Solids: https://www.nature.com/articles/s41524-023-00973-1
Expand Down
10 changes: 5 additions & 5 deletions paper.bib → docs/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ @article{pymatgen
author = {S. Ping Ong and W. Davidson Richards and A. Jain and G. Hautier and M. Kocher and S. Cholia and D. Gunter and V.~L. Chevrier and K. A. Persson and G. Ceder},
}
@article{ase,
author = {Hjorth Larsen, A. and J{\o}rgen Mortensen, J. and Blomqvist, J. and Castelli, I.~E. and Christensen, R. and Du{\l}ak, M. and Friis, J. and Groves,
M. N. and Hammer, B. and Hargus, C. and Hermes, E.~D. and Jennings, P.~C. and {Bjerre Jensen}, P. and Kermode, J. and Kitchin, J. R. and Leonhard Kolsbjergs,
E. and Kubal, J. and Kaasbjerg, K. and Lysgaard, S. and {Bergmann Maronsson}, J. and Maxson, T. and Olsen, T. and Pastewka, L. and Peterson,
A. and Rostgaard, C. and Schi{\o}tz, J. and Sch{\"{u}}tt, O. and Strange, M. and Thygesen, K. S. and Vegge, T. and Vilhelmsen, L. and Walter,
author = {Hjorth Larsen, A. and J{\o}rgen Mortensen, J. and Blomqvist, J. and Castelli, I.~E. and Christensen, R. and Du{\l}ak, M. and Friis, J. and Groves,
M. N. and Hammer, B. and Hargus, C. and Hermes, E.~D. and Jennings, P.~C. and {Bjerre Jensen}, P. and Kermode, J. and Kitchin, J. R. and Leonhard Kolsbjergs,
E. and Kubal, J. and Kaasbjerg, K. and Lysgaard, S. and {Bergmann Maronsson}, J. and Maxson, T. and Olsen, T. and Pastewka, L. and Peterson,
A. and Rostgaard, C. and Schi{\o}tz, J. and Sch{\"{u}}tt, O. and Strange, M. and Thygesen, K. S. and Vegge, T. and Vilhelmsen, L. and Walter,
M. and Zeng, Z. and Jacobsen, K. W},
doi = {10.1088/1361-648X/aa680e},
issn = {0953-8984},
Expand Down Expand Up @@ -75,7 +75,7 @@ @article{espresso
url = {https://doi.org/10.1088/0953-8984/21/39/395502},
}
@article{castep,
author = {S. J. Clark and M. D. Segall and C. J. Pickard and P. J. Hasnip and
author = {S. J. Clark and M. D. Segall and C. J. Pickard and P. J. Hasnip and
M. I. J. P. and K. Refson and M. C. Payne},
doi = {10.1524/zkri.220.5.567.65075},
url = {10.1524/zkri.220.5.567.65075},
Expand Down
2 changes: 1 addition & 1 deletion paper.md → docs/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Within its analysis toolbox, `ShakeNBreak` includes methods to quantify structur

The distortion procedure, underlying rationale and its application to a wide range of semiconductors have recently been described [@Mosquera-Lois:2022]. In addition, the package has been employed to identify the defect structures reported in several studies [@Kavanagh:2021; @Kavanagh:2022], with the identified configurations having significant impact on predicted behaviour.

![Example analysis for a cadmium vacancy defect in CdTe: a) plot of final energies versus bond distortion factor, with a colorbar quantifying the structural similarity between configurations b) analysis of site magnetisations for the Unperturbed configuration, c) distances between the defect and its nearest neighbours and d) resemblance of the defect environment to difference structural motifs. \label{fig1}](figures/Figure_joss.png)
![Example analysis for a cadmium vacancy defect in CdTe: a) plot of final energies versus bond distortion factor, with a colorbar quantifying the structural similarity between configurations b) analysis of site magnetisations for the Unperturbed configuration, c) distances between the defect and its nearest neighbours and d) resemblance of the defect environment to difference structural motifs. \label{fig1}](../figures/Figure_joss.png)

# Acknowledgements

Expand Down
40 changes: 40 additions & 0 deletions docs/shakenbreak.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@article{SnB_code,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R. and Walsh, Aron and Scanlon, David O.},
title = {{ShakeNBreak}: {Navigating} the defect configurational landscape},
journal = {Journal of Open Source Software},
volume = {7},
number = {80},
pages = {4817},
year = {2022},
doi = {10.21105/joss.04817},
url = {https://joss.theoj.org/papers/10.21105/joss.04817},
eprint = {https://joss.theoj.org/papers/10.21105/joss.04817},
abstract = {Mosquera-Lois et al., (2022). ShakeNBreak: Navigating the defect configurational landscape. Journal of Open Source Software, 7(80), 4817, https://doi.org/10.21105/joss.04817},
}

@article{SnB_theory,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R. and Walsh, Aron and Scanlon, David O.},
title = {Identifying the ground state structures of point defects in solids},
journal = {npj Computational Materials},
volume = {9},
number = {1},
pages = {1--11},
year = {2023}
doi = {10.1038/s41524-023-00973-1},
url = {https://www.nature.com/articles/s41524-023-00973-1},
eprint = {https://www.nature.com/articles/s41524-023-00973-1},
abstract = {Point defects are a universal feature of crystals. Their identification is addressed by combining experimental measurements with theoretical models. The standard modelling approach is, however, prone to missing the ground state atomic configurations associated with energy-lowering reconstructions from the idealised crystallographic environment. Missed ground states compromise the accuracy of calculated properties. To address this issue, we report an approach to navigate the defect configurational landscape using targeted bond distortions and rattling. Application of our workflow to eight materials (CdTe, GaAs, Sb2S3, Sb2Se3, CeO2, In2O3, ZnO, anatase-TiO2) reveals symmetry breaking in each host crystal that is not found via conventional local minimisation techniques. The point defect distortions are classified by the associated physico-chemical factors. We demonstrate the impact of these defect distortions on derived properties, including formation energies, concentrations and charge transition levels. Our work presents a step forward for quantitative modelling of imperfect solids.},
}

@article{SnB_preview,
author = {Mosquera-Lois, Irea and Kavanagh, Seán R.},
title = {In search of hidden defects},
journal = {Matter},
volume = {4},
number = {8},
pages = {2602--2605},
year = {2021},
doi = {10.1016/j.matt.2021.06.003},
url = {https://www.cell.com/matter/abstract/S2590-2385(21)00273-3},
eprint = {https://www.cell.com/matter/abstract/S2590-2385(21)00273-3},
}
23 changes: 13 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,21 @@ def package_files(directory):
input_files = package_files("SnB_input_files/")
fonts = package_files("fonts/")

with open("README.md", "r", encoding="utf-8") as file:
long_description = file.read()


setup(
name="shakenbreak",
version="23.04.27",
version="23.06.03",
description="Package to generate and analyse distorted defect structures, in order to "
"identify ground-state and metastable defect configurations.",
long_description="Python package to automate the process of defect structure searching. <br>"
"Employs chemically-guided bond distortions to locate ground-state and metastable structures"
" of point defects in solid materials. <br>"
"Read the [docs](https://shakenbreak.readthedocs.io/en/latest/index.html) for more info.",
long_description=long_description,
long_description_content_type="text/markdown",
author="Irea Mosquera-Lois, Seán R. Kavanagh",
author="Irea Mosquera-Lois & Seán R. Kavanagh",
author_email="[email protected], [email protected]",
maintainer="Irea Mosquera-Lois, Seán R. Kavanagh",
maintainer="Irea Mosquera-Lois & Seán R. Kavanagh",
maintainer_email="[email protected], [email protected]",
readme="README.md", # PyPI readme
url="https://shakenbreak.readthedocs.io/en/latest/index.html",
license="MIT",
license_files=("LICENSE",),
Expand All @@ -150,12 +149,16 @@ def package_files(directory):
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Chemistry",
"Topic :: Scientific/Engineering :: Physics",
],
keywords="chemistry pymatgen dft defects structure-searching distortions symmetry-breaking",
packages=find_packages(),
python_requires=">=3.8, <3.11",
install_requires=[
"numpy<1.24,>=1.21.2",
"pymatgen>=2022.10.22",
Expand All @@ -172,7 +175,7 @@ def package_files(directory):
extras_require={
"tests": [
"pytest>=7.1.3",
"pytest-mpl==0.15.1", # New version 0.16.0 has a bug
"pytest-mpl==0.16.1",
],
"docs": [
"sphinx",
Expand Down
6 changes: 4 additions & 2 deletions shakenbreak/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ def get_gs_distortion(defect_energies_dict: dict) -> tuple:
return energy_diff, gs_distortion


def _sort_data(energies_file: str, verbose: bool = True, min_e_diff: float = 0.05) -> tuple:
def _sort_data(
energies_file: str, verbose: bool = True, min_e_diff: float = 0.05
) -> tuple:
"""
Organize bond distortion results in a dictionary, calculate energy
of ground-state defect structure relative to `Unperturbed` structure
Expand Down Expand Up @@ -977,7 +979,7 @@ def get_homoionic_bonds(
if site.species_string == element
]
homoionic_bonds = {}
for (site_index, site) in sites:
for site_index, site in sites:
neighbours = structure.get_neighbors(site, r=radius)
if element in [site.species_string for site in neighbours]:
site_neighbours = [
Expand Down
7 changes: 3 additions & 4 deletions shakenbreak/distortions.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def rattle(

if stdev is None:
stdev = (
0.1 * sorted_distances[len(structure) + 40]
0.1 * sorted_distances[len(structure) + 40]
) # ignoring distorted atoms by ignoring the first 20 non-zero bond lengths (double counted
# in the distance matrix)
if stdev > 0.4 or stdev < 0.02:
Expand Down Expand Up @@ -413,7 +413,6 @@ def scale_stdev(disp, r_min, r):
dist_defect_to_i = atoms.get_distance(site_index, i, mic=True)

for n in range(max_attempts):

# generate displacement
delta_disp = rs.normal(
0.0,
Expand Down Expand Up @@ -610,7 +609,7 @@ def local_mc_rattle(

if stdev is None:
stdev = (
0.1 * sorted_distances[len(structure) + 40]
0.1 * sorted_distances[len(structure) + 40]
) # ignoring distorted atoms by ignoring the first 20 non-zero bond lengths (double counted
# in the distance matrix)
if stdev > 0.4 or stdev < 0.02:
Expand All @@ -624,7 +623,7 @@ def local_mc_rattle(

if d_min is None:
d_min = (
0.8 * sorted_distances[len(structure) + 40]
0.8 * sorted_distances[len(structure) + 40]
) # ignoring distorted atoms by ignoring the first 20 non-zero bond lengths (double counted
# in the distance matrix)
if d_min < 1.0:
Expand Down
1 change: 1 addition & 0 deletions shakenbreak/energy_lowering_distortions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Module to apply energy lowering distortions found for a certain defect
species (charge state) to other charge states of that defect.
"""

import copy
import os
import shutil
Expand Down
Loading

0 comments on commit b6aae5d

Please sign in to comment.