Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve k point labelling when there are discontinuities in the path #51

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 LiNbO<sub>3</sub>_** [_ChemRxiv_](https://chemrxiv.org/engage/chemrxiv/article-details/6687aa33c9c6a5c07a59a394) 2024
- L. Zhang et al. **_Study of native point defects in Al<sub>0.5</sub>Ga<sub>0.5</sub>N 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 (Cs<sub>2</sub>Ti<sub>1–x</sub>Sn<sub>x</sub>X<sub>6</sub>; 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 NaBiS<sub>2</sub> 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 Sn<sub>2</sub>SbS<sub>2</sub>I<sub>3</sub>_** [_Journal of the Americal Chemical Society_](https://doi.org/10.1021/jacs.2c13336) 2023
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 LiNbO<sub>3</sub>_** [_ChemRxiv_](https://chemrxiv.org/engage/chemrxiv/article-details/6687aa33c9c6a5c07a59a394) 2024
- L. Zhang et al. **_Study of native point defects in Al<sub>0.5</sub>Ga<sub>0.5</sub>N 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 (Cs<sub>2</sub>Ti<sub>1–x</sub>Sn<sub>x</sub>X<sub>6</sub>; 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 NaBiS<sub>2</sub> 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 Sn<sub>2</sub>SbS<sub>2</sub>I<sub>3</sub>_** [_Journal of the Americal Chemical Society_](https://doi.org/10.1021/jacs.2c13336) 2023
Expand Down
2 changes: 1 addition & 1 deletion easyunfold/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Collection of code for band unfolding
"""

__version__ = '0.3.6'
__version__ = '0.3.7'
2 changes: 1 addition & 1 deletion easyunfold/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion easyunfold/unfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,22 +615,49 @@
output[key] = getattr(self, key)
return output

def get_kpoint_distances(self):
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`.
:::
"""
# 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]

Check warning on line 641 in easyunfold/unfold.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/unfold.py#L641

Added line #L641 was not covered by tests
# Shift the distances beyond
dists[idx:] -= shift

Check warning on line 643 in easyunfold/unfold.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/unfold.py#L643

Added line #L643 was not covered by tests
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])

Check warning on line 654 in easyunfold/unfold.py

View check run for this annotation

Codecov / codecov/patch

easyunfold/unfold.py#L654

Added line #L654 was not covered by tests
else:
comnbined_labels.append([idx, name])
last_entry = [idx, name]

return comnbined_labels


def LorentzSmearing(x, x0, sigma=0.02):
r"""
Expand Down
Loading