diff --git a/docs/source/_config.yml b/docs/source/_config.yml index ec023ace..01dfb110 100644 --- a/docs/source/_config.yml +++ b/docs/source/_config.yml @@ -10,7 +10,7 @@ exclude_patterns : [_build, Thumbs.db, .DS_Store, "**.ipynb_checkpoin # Cache re-execution of notebooks on each build. # See https://jupyterbook.org/content/execute.html execute: - execute_notebooks: cache + execute_notebooks: auto # Define the name of the latex output file for PDF builds latex: diff --git a/docs/source/_templates/autosummary/base.rst b/docs/source/_templates/autosummary/base.rst deleted file mode 100644 index 5536fa10..00000000 --- a/docs/source/_templates/autosummary/base.rst +++ /dev/null @@ -1,5 +0,0 @@ -{{ name | escape | underline}} - -.. currentmodule:: {{ module }} - -.. auto{{ objtype }}:: {{ objname }} diff --git a/docs/source/_templates/autosummary/class.rst b/docs/source/_templates/autosummary/class.rst deleted file mode 100644 index df3dbb3a..00000000 --- a/docs/source/_templates/autosummary/class.rst +++ /dev/null @@ -1,7 +0,0 @@ -{{ name | escape | underline}} - -.. currentmodule:: {{ module }} - -.. autoclass:: {{ objname }} - :show-inheritance: - :members: diff --git a/docs/source/_templates/autosummary/function.rst b/docs/source/_templates/autosummary/function.rst deleted file mode 100644 index 5ffed09e..00000000 --- a/docs/source/_templates/autosummary/function.rst +++ /dev/null @@ -1,5 +0,0 @@ -{{ name | escape | underline}} - -.. currentmodule:: {{ module }} - -.. autofunction:: {{ objname }} diff --git a/docs/source/_templates/autosummary/module.rst b/docs/source/_templates/autosummary/module.rst deleted file mode 100644 index 3535c8de..00000000 --- a/docs/source/_templates/autosummary/module.rst +++ /dev/null @@ -1,53 +0,0 @@ -{% extends "!autosummary/module.rst" %} - -{# This file is almost the same as the default, but adds :toctree: and :nosignatures: to - the autosummary directives. The original can be found at - ``sphinx/ext/autosummary/templates/autosummary/module.rst``. #} - -{% block attributes %} -{% if attributes %} - .. rubric:: Module Attributes - - .. autosummary:: - :toctree: - :nosignatures: - {% for item in attributes %} - {{ item }} - {%- endfor %} -{% endif %} -{% endblock %} - -{% block functions %} -{% if functions %} - .. rubric:: Functions - - .. autosummary:: - :toctree: - :nosignatures: - {% for item in functions %} - {{ item }} - {%- endfor %} -{% endif %} -{% endblock %} - -{% block classes %} - -{% set types = [] %} -{% for item in members %} - {% if not item.startswith('_') and not (item in functions or item in attributes or item in exceptions) %} - {% set _ = types.append(item) %} - {% endif %} -{%- endfor %} - -{% if types %} - .. rubric:: Classes - - .. autosummary:: - :toctree: - :nosignatures: - {% for item in types %} - {{ item }} - {%- endfor %} - -{% endif %} -{% endblock %} diff --git a/docs/source/content/formation-energy.ipynb b/docs/source/content/formation-energy.ipynb index ba79e833..72ed385b 100644 --- a/docs/source/content/formation-energy.ipynb +++ b/docs/source/content/formation-energy.ipynb @@ -164,7 +164,7 @@ "outputs": [], "source": [ "from pymatgen.analysis.defects.corrections.freysoldt import plot_plnr_avg\n", - "plot_data = fed.defect_entries[1].correction_metadata\n", + "plot_data = fed.defect_entries[1].correction_metadata[\"freysoldt\"]\n", "plot_plnr_avg(plot_data[0], title=\"Lattice Direction 1\")\n", "plot_plnr_avg(plot_data[1], title=\"Lattice Direction 2\")\n", "plot_plnr_avg(plot_data[2], title=\"Lattice Direction 3\")\n" diff --git a/docs/source/content/nonradiative.ipynb b/docs/source/content/nonradiative.ipynb index 40aa1820..cb0206d4 100644 --- a/docs/source/content/nonradiative.ipynb +++ b/docs/source/content/nonradiative.ipynb @@ -269,7 +269,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:38:29) [Clang 13.0.1 ]" + "version": "3.10.6" }, "vscode": { "interpreter": { diff --git a/pymatgen/analysis/defects/ccd.py b/pymatgen/analysis/defects/ccd.py index 394f5527..db4a9441 100644 --- a/pymatgen/analysis/defects/ccd.py +++ b/pymatgen/analysis/defects/ccd.py @@ -66,7 +66,7 @@ class HarmonicDefect(MSONable): defect_band: Optional[Sequence[tuple]] = None relaxed_index: Optional[int] = None relaxed_bandstructure: Optional[BandStructure] = None - wswqs: Optional[dict[float, WSWQ]] = None + wswqs: Optional[list[dict]] = None waveder: Optional[Waveder] = None def __repr__(self) -> str: @@ -326,9 +326,11 @@ def read_wswqs( raise ValueError( f"Number of WSWQ files ({len(wswq_files)}) does not match number of distortions ({len(distortions)})." ) - self.wswqs = {d: WSWQ.from_file(f) for d, f in zip(distortions, wswq_files)} + self.wswqs = [ + {"Q": d, "wswq": WSWQ.from_file(f)} for d, f in zip(distortions, wswq_files) + ] - def get_elph_me(self, defect_state: tuple[int, int, int]) -> npt.ArrayLike: + def get_elph_me(self, defect_state: tuple) -> npt.ArrayLike: """Calculate the electron phonon matrix elements. Combine the data from the WSWQs to calculate the electron phonon matrix elements. @@ -350,8 +352,8 @@ def get_elph_me(self, defect_state: tuple[int, int, int]) -> npt.ArrayLike: """ if self.wswqs is None: raise RuntimeError("WSWQs have not been read. Use `read_wswqs` first.") - distortions = list(self.wswqs.keys()) - wswqs = list(self.wswqs.values()) + distortions = [wswq["Q"] for wswq in self.wswqs] + wswqs = [wswq["wswq"] for wswq in self.wswqs] band_index, kpoint_index, spin_index = defect_state # The second band index is associated with the defect state # since we are usually interested in capture @@ -378,10 +380,6 @@ def _get_ediff(self, output_order="skb") -> npt.NDArray: The eigenvalue difference to the defect band in the order specified by output_order. """ - if self.defect_band_index is None: - raise ValueError( # pragma: no cover - "The ``defect_band_index`` must be set before ``ediff`` can be computed." - ) if self.relaxed_bandstructure is None: raise ValueError( # pragma: no cover "The ``relaxed_bandstructure`` must be set before ``ediff`` can be computed. " @@ -390,7 +388,7 @@ def _get_ediff(self, output_order="skb") -> npt.NDArray: ediffs_ = _get_ks_ediff( bandstructure=self.relaxed_bandstructure, - defect_band_index=self.defect_band_index, + defect_band=self.defect_band, ) ediffs_stack = [ ediffs_[Spin.up].T, @@ -735,7 +733,7 @@ def _get_wswq_slope(distortions: list[float], wswqs: list[WSWQ]) -> npt.NDArray: def _get_ks_ediff( bandstructure: BandStructure, - defect_band_index: int, + defect_band: Sequence[tuple], ) -> dict[Spin, npt.NDArray]: """Calculate the Kohn-Sham energy between the defect state. @@ -744,15 +742,23 @@ def _get_ks_ediff( Args: bandstructure: A BandStructure object. - defect_band_index: The index of the defect band. + defect_band: The defect band given as a list of tuples (band_index, kpoint_index, spin_index). Returns: npt.NDArray: The Kohn-Sham energy difference between the defect state and other states. Indexed the same way as ``bandstructure.bands``. """ res = dict() - for k, kpt_bands in bandstructure.bands.items(): - e_at_def_band = kpt_bands[defect_band_index, :] - e_diff = kpt_bands - e_at_def_band - res[k] = e_diff + b_at_kpt_and_spin = {(k, s): b for b, k, s in defect_band} + for ispin, eigs in bandstructure.bands.items(): + spin_index = 0 if ispin == Spin.up else 1 + res[ispin] = np.zeros_like(eigs) + for ikpt, kpt in enumerate(bandstructure.kpoints): + iband = b_at_kpt_and_spin.get((ikpt, spin_index), None) + # import ipdb; ipdb.set_trace() + if iband is None: + continue + e_at_def_band = eigs[iband, ikpt] + e_diff = eigs[:, ikpt] - e_at_def_band + res[ispin][:, ikpt] = e_diff return res diff --git a/pymatgen/analysis/defects/corrections/kumagai.py b/pymatgen/analysis/defects/corrections/kumagai.py index d9f5787f..07b97fbc 100644 --- a/pymatgen/analysis/defects/corrections/kumagai.py +++ b/pymatgen/analysis/defects/corrections/kumagai.py @@ -14,17 +14,17 @@ # check that pydefect is installed try: - pass -except ImportError: - raise ImportError("pydefect is not installed. Please install it first.") + from pydefect.analyzer.calc_results import CalcResults + from pydefect.cli.vasp.make_efnv_correction import make_efnv_correction + from vise import user_settings +except ImportError: # pragma: no cover + raise ModuleNotFoundError( + "vise/pydefect is not installed. Please install it first." + ) # Disable messages from pydefect import -from vise import user_settings - user_settings.logger.setLevel(logging.CRITICAL) -from pydefect.analyzer.calc_results import CalcResults -from pydefect.cli.vasp.make_efnv_correction import make_efnv_correction from pymatgen.core import Structure from pymatgen.io.vasp import Outcar, Vasprun