From fbb1e1ef0b606ac4598b64ad15cec6e4df6aafe6 Mon Sep 17 00:00:00 2001 From: Bonan Zhu Date: Mon, 26 Aug 2024 21:51:53 +0800 Subject: [PATCH 1/3] Improve handling of discontinues paths Combine kpoint labels when plotting the unfolded effective band structure. --- easyunfold/__init__.py | 2 +- easyunfold/plotting.py | 2 +- easyunfold/unfold.py | 26 +++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/easyunfold/__init__.py b/easyunfold/__init__.py index 64637c2..add4e56 100644 --- a/easyunfold/__init__.py +++ b/easyunfold/__init__.py @@ -2,4 +2,4 @@ Collection of code for band unfolding """ -__version__ = '0.3.6' +__version__ = '0.3.7' diff --git a/easyunfold/plotting.py b/easyunfold/plotting.py index 1c2817a..93c1f0b 100644 --- a/easyunfold/plotting.py +++ b/easyunfold/plotting.py @@ -372,7 +372,7 @@ def _plot_spectral_function_rgba( def _add_kpoint_labels(self, ax: plt.Axes, x_is_kidx=False): """Add labels to the k-points for a given axes""" # Label the kpoints - labels = self.unfold.kpoint_labels + labels = self.unfold.get_combined_kpoint_labels() kdist = self.unfold.get_kpoint_distances() # Explicit label indices diff --git a/easyunfold/unfold.py b/easyunfold/unfold.py index eb24db8..f664d63 100644 --- a/easyunfold/unfold.py +++ b/easyunfold/unfold.py @@ -615,7 +615,7 @@ def as_dict(self) -> dict: output[key] = getattr(self, key) return output - def get_kpoint_distances(self): + def get_kpoint_distances(self, hide_discontinuities=True): """ Distances between the kpoints along the path in the reciprocal space. This does not take account of the breaking of the path. @@ -623,14 +623,38 @@ def get_kpoint_distances(self): The reciprocal lattice vectors includes the $2\\pi$ factor, e.g. `np.linalg.inv(L).T * 2 * np.pi`. ::: """ + # Check for kpts = self.kpts_pc pc_latt = self.pc_latt kpts_path = kpts @ np.linalg.inv(pc_latt).T * np.pi * 2 # Kpoint path in the reciprocal space dists = np.cumsum(np.linalg.norm(np.diff(kpts_path, axis=0), axis=-1)) dists = np.append([0], dists) + if hide_discontinuities: + last_idx = -2 + for idx, _ in self.kpoint_labels: + if idx - last_idx == 1: + # This label is directly adjacent to the previous one - this is a discontinuity + shift = dists[idx] - dists[idx - 1] + # Shift the distances beyond + dists[idx:] -= shift + last_idx = idx + return dists + def get_combined_kpoint_labels(self): + """Get kpoints label with discontinuities combined into a single label""" + last_entry = [-2, None] + comnbined_labels = [] + for idx, name in self.kpoint_labels: + if idx - last_entry[0] == 1: + comnbined_labels.append([last_entry[0], last_entry[1] + '|' + name]) + else: + comnbined_labels.append([idx, name]) + last_entry = [idx, name] + + return comnbined_labels + def LorentzSmearing(x, x0, sigma=0.02): r""" From 08fbe21663a46fea07d3ebaee41eca7c49c2abc8 Mon Sep 17 00:00:00 2001 From: Bonan Zhu Date: Mon, 26 Aug 2024 21:58:56 +0800 Subject: [PATCH 2/3] Update the doc string --- easyunfold/unfold.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/easyunfold/unfold.py b/easyunfold/unfold.py index f664d63..9adf79a 100644 --- a/easyunfold/unfold.py +++ b/easyunfold/unfold.py @@ -615,10 +615,13 @@ def as_dict(self) -> dict: output[key] = getattr(self, key) return output - def get_kpoint_distances(self, hide_discontinuities=True): + def get_kpoint_distances(self, hide_discontinuities: bool = True): """ Distances between the kpoints along the path in the reciprocal space. This does not take account of the breaking of the path. + + :param hide_discontinuities: Whether to hide the discontinuities in the kpoint path. + :::{note} The reciprocal lattice vectors includes the $2\\pi$ factor, e.g. `np.linalg.inv(L).T * 2 * np.pi`. ::: From 467afdfb40456657bc9265fac4f3012b4894ddfd Mon Sep 17 00:00:00 2001 From: Sean Kavanagh Date: Mon, 26 Aug 2024 11:53:46 -0400 Subject: [PATCH 3/3] Add paper to list --- README.md | 1 + docs/index.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index fa426a1..8f2227d 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ If you use `easyunfold` in your work, please cite: We'll add papers that use `easyunfold` to this list as they come out! - K. Eggestad, B. A. D. Williamson, D. Meier and S. M. Selbach **_Mobile Intrinsic Point Defects for Conductive Neutral Domain Walls in LiNbO3_** [_ChemRxiv_](https://chemrxiv.org/engage/chemrxiv/article-details/6687aa33c9c6a5c07a59a394) 2024 +- L. Zhang et al. **_Study of native point defects in Al0.5Ga0.5N by first principles calculations_** [_Computational Materials Science_](https://doi.org/10.1016/j.commatsci.2024.113312) 2024 - S. M. Liga & S. R. Kavanagh, A. Walsh, D. O. Scanlon and G. Konstantatos **_Mixed-Cation Vacancy-Ordered Perovskites (Cs2Ti1–xSnxX6; X = I or Br): Low-Temperature Miscibility, Additivity, and Tunable Stability_** [_Journal of Physical Chemistry C_](https://doi.org/10.1021/acs.jpcc.3c05204) 2023 - Y. T. Huang & S. R. Kavanagh et al. **_Strong absorption and ultrafast localisation in NaBiS2 nanocrystals with slow charge-carrier recombination_** [_Nature Communications_](https://www.nature.com/articles/s41467-022-32669-3) 2022 - A. T. J. Nicolson et al. **_Interplay of Static and Dynamic Disorder in the Mixed-Metal Chalcohalide Sn2SbS2I3_** [_Journal of the Americal Chemical Society_](https://doi.org/10.1021/jacs.2c13336) 2023 diff --git a/docs/index.md b/docs/index.md index eb61320..65f1aa0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -64,6 +64,7 @@ If you use `easyunfold` in your work, please cite: We'll add papers that use `easyunfold` to this list as they come out! - K. Eggestad, B. A. D. Williamson, D. Meier and S. M. Selbach **_Mobile Intrinsic Point Defects for Conductive Neutral Domain Walls in LiNbO3_** [_ChemRxiv_](https://chemrxiv.org/engage/chemrxiv/article-details/6687aa33c9c6a5c07a59a394) 2024 +- L. Zhang et al. **_Study of native point defects in Al0.5Ga0.5N by first principles calculations_** [_Computational Materials Science_](https://doi.org/10.1016/j.commatsci.2024.113312) 2024 - S. M. Liga & S. R. Kavanagh, A. Walsh, D. O. Scanlon and G. Konstantatos **_Mixed-Cation Vacancy-Ordered Perovskites (Cs2Ti1–xSnxX6; X = I or Br): Low-Temperature Miscibility, Additivity, and Tunable Stability_** [_Journal of Physical Chemistry C_](https://doi.org/10.1021/acs.jpcc.3c05204) 2023 - Y. T. Huang & S. R. Kavanagh et al. **_Strong absorption and ultrafast localisation in NaBiS2 nanocrystals with slow charge-carrier recombination_** [_Nature Communications_](https://www.nature.com/articles/s41467-022-32669-3) 2022 - A. T. J. Nicolson et al. **_Interplay of Static and Dynamic Disorder in the Mixed-Metal Chalcohalide Sn2SbS2I3_** [_Journal of the Americal Chemical Society_](https://doi.org/10.1021/jacs.2c13336) 2023