|
| 1 | +--- |
| 2 | +title: pymatgen-analysis-defects |
| 3 | +--- |
| 4 | + |
| 5 | +[](https://github.com/materialsproject/pymatgen-analysis-defects/actions/workflows/testing.yml) |
| 6 | +[](https://codecov.io/gh/materialsproject/pymatgen-analysis-defects) |
| 7 | +[](https://zenodo.org/badge/latestdoi/452872799) |
| 8 | +[](https://badge.fury.io/py/pymatgen-analysis-defects) |
| 9 | + |
| 10 | +📄 [Full |
| 11 | +Documentation](https://materialsproject.github.io/pymatgen-analysis-defects/) |
| 12 | + |
| 13 | +This package is an extension to `pymatgen` for performing defect |
| 14 | +analysis. The package is designed to work with VASP inputs and output |
| 15 | +files and is meant to be used as a namespace package extension to the |
| 16 | +main `pymatgen` library. The new module has been redesigned to work |
| 17 | +closely with `atomate2`. |
| 18 | + |
| 19 | +While the `atomate2` automation framework is not required for this code |
| 20 | +to be useful, users are strongly encouraged to to adopt the `atomate2` |
| 21 | +framework as it contains codified \"best practices\" for running defect |
| 22 | +calculations as well as orchestrating the running of calculations and |
| 23 | +storing the results. |
| 24 | + |
| 25 | +The package serves as an object-oriented interface to defect physics and |
| 26 | +is capable of generating a list of non-equivalent defect objects |
| 27 | +directly from the Materials Project API. |
| 28 | + |
| 29 | +``` python |
| 30 | +from pymatgen.analysis.defects.generators import ChargeInterstitialGenerator, generate_all_native_defects |
| 31 | +from pymatgen.ext.matproj import MPRester |
| 32 | +with MPRester() as mpr: |
| 33 | +chgcar = mpr.get_charge_density_from_material_id("mp-804") |
| 34 | +for defect in generate_all_native_defects(chgcar): |
| 35 | + print(defect) |
| 36 | +``` |
| 37 | + |
| 38 | +# Non-exhaustive list of features: |
| 39 | + |
| 40 | +## Reproducible definition of defects |
| 41 | + |
| 42 | +Defects are defined based on the physical concept they represent, |
| 43 | +independent of the calculation details such as simulation cell size. As |
| 44 | +an example, a Vacancy defect is defined by the primitive cell of the |
| 45 | +pristine material plus a single site that represents the vacancy site in |
| 46 | +the unit cell. |
| 47 | + |
| 48 | +## Formation energy calculations |
| 49 | + |
| 50 | +The formation energy diagram is a powerful tool for understanding the |
| 51 | +thermodynamics of defects. This package provides a simple interface for |
| 52 | +calculating the formation energy diagram from first-principles results. |
| 53 | +This package handles the energy accounting of the chemical species for |
| 54 | +the chemical potential calculations, which determines the y-offset of |
| 55 | +the formation energy. This package also performs finite-size corrections |
| 56 | +for the formation energy which is required when studying charged defects |
| 57 | +in periodic simulation cells. |
| 58 | + |
| 59 | +## Defect Position |
| 60 | + |
| 61 | +Identification of the defect positions in a simulation cell after atomic |
| 62 | +relaxation is not trivial since the many atoms can collectively shift in |
| 63 | +response to the creation of the defect. Yet the exact location of the |
| 64 | +defect is required for the calculation of finite-size corrections as |
| 65 | +well as other physical properties. We devised a method based on |
| 66 | +calculating a SOAP-based distortion field that can be used to identify |
| 67 | +the defect position in a simulation cell. Note, this method only |
| 68 | +requires the reference pristine supercell and does not need prior |
| 69 | +knowledge of how the defect was created. |
| 70 | + |
| 71 | +## Defect Complexes |
| 72 | + |
| 73 | +Multiple defects can be composed into defect complexes. The complex is |
| 74 | +can be treated as a normal defect object for subsequent analysis. |
| 75 | + |
| 76 | +## Defect Interactions |
| 77 | + |
| 78 | +Simulation of defect-photon and defect-phonon interactions under the |
| 79 | +independent particle approximation. |
| 80 | + |
| 81 | +# Previous versions of the defects code |
| 82 | + |
| 83 | +This package replaces the older `pymatgen.analysis.defects` modules. The |
| 84 | +previous module was used by `pyCDT` code which will continue to work |
| 85 | +with version `2022.7.8` of `pymatgen`. |
| 86 | + |
| 87 | +# Contributing |
| 88 | + |
| 89 | +The source code can be downloaded from the GitHub repository at |
| 90 | + |
| 91 | +``` bash |
| 92 | +$ git clone https://github.com/materialsproject/pymatgen-analysis-defects.git |
| 93 | +``` |
| 94 | + |
| 95 | +All code contributions are welcome. Please submit a pull request on |
| 96 | +GitHub. To make maintenance easier, please use a workflow similar to the |
| 97 | +automated CI |
| 98 | +[workflow](https://github.com/materialsproject/pymatgen-analysis-defects/blob/main/.github/workflows/testing.yml). |
| 99 | + |
| 100 | +Specifically, please make sure to run the following commands for |
| 101 | +linting: |
| 102 | + |
| 103 | +``` bash |
| 104 | +$ pip install -e .[strict] |
| 105 | +$ pip install -e .[dev] |
| 106 | +$ pre-commit install |
| 107 | +$ pre-commit run --all-files |
| 108 | +``` |
| 109 | + |
| 110 | +And run these commands for testing: |
| 111 | + |
| 112 | +``` bash |
| 113 | +$ pip install -e .[strict] |
| 114 | +$ pip install -e .[tests] |
| 115 | +$ pytest --cov=pymatgen |
| 116 | +$ pytest --nbmake ./docs/source/content |
| 117 | +``` |
| 118 | + |
| 119 | +For more details about what is actually installed with each of the |
| 120 | +`pip install .[arg]` commands, please inspect the `pyproject.toml` file. |
| 121 | + |
| 122 | +# Contributors |
| 123 | + |
| 124 | +- Lead developer: Dr. Jimmy-Xuan Shen |
| 125 | +- This code contains contributions from the original defects analysis |
| 126 | + module of `pymatgen` from Dr. Danny Broberg and Dr. Shyam |
| 127 | + Dwaraknath. |
0 commit comments