Skip to content

Commit

Permalink
Adding a check for emin and emax
Browse files Browse the repository at this point in the history
and a loading spinner for INS data initialization.
  • Loading branch information
mikibonacci committed Oct 2, 2024
1 parent 1b19624 commit 5cbfd91
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/aiidalab_qe_vibroscopy/utils/euphonic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@

###### START for detached app:

# spinner for waiting time (supercell estimations)
spinner_html = """
<style>
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.spinner {
display: inline-block;
width: 15px;
height: 15px;
}
.spinner div {
width: 100%;
height: 100%;
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
}
</style>
<div class="spinner">
<div></div>
</div>
"""


# Upload buttons
class UploadPhonopyYamlWidget(ipw.FileUpload):
Expand Down Expand Up @@ -166,6 +194,11 @@ def __init__(self, mode="aiidalab-qe app plugin", fc=None, q_path=None):
)
self.plot_button.on_click(self._on_first_plot_button_clicked)

self.loading_widget = ipw.HTML(
value=spinner_html,
)
self.loading_widget.layout.display = "none"

if self.mode == "aiidalab-qe app plugin":
self.upload_widget.layout.display = "none"
self.plot_button.disabled = False
Expand All @@ -177,6 +210,7 @@ def __init__(self, mode="aiidalab-qe app plugin", fc=None, q_path=None):
children=[
self.upload_widget,
self.plot_button,
self.loading_widget,
self.tab_widget,
],
)
Expand Down Expand Up @@ -232,6 +266,9 @@ def _generate_force_constants(
def _on_first_plot_button_clicked(self, change=None):
# It creates the widgets
self.plot_button.layout.display = "none"

self.loading_widget.layout.display = "block"

self.fc = self._generate_force_constants()

# I first initialise this widget, to then have the 0K ref for the other two.
Expand All @@ -247,6 +284,8 @@ def _on_first_plot_button_clicked(self, change=None):
),
)

self.loading_widget.layout.display = "none"

self.tab_widget.layout.display = "block"


Expand Down
15 changes: 15 additions & 0 deletions src/aiidalab_qe_vibroscopy/utils/euphonic/intensity_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,21 @@ def produce_bands_weigthed_data(
x_tick_labels = get_qpoint_labels(
modes.qpts, cell=modes.crystal.to_spglib_cell()
)

# duplication from euphonic/cli/utils.py
if args.emin is None:
# Subtract small amount from min frequency - otherwise due to unit
# conversions binning of this frequency can vary with different
# architectures/lib versions, making it difficult to test
emin_room = 1e-5 * ureg("meV").to(modes.frequencies.units).magnitude
args.emin = min(np.min(modes.frequencies.magnitude - emin_room), 0.0)
if args.emax is None:
args.emax = np.max(modes.frequencies.magnitude) * 1.05
if args.emin >= args.emax:
raise ValueError(
"Maximum energy ({args.emax}) should be greater than minimum ({args.emin}). "
)

modes.frequencies_unit = args.energy_unit
ebins = _get_energy_bins(modes, args.ebins + 1, emin=args.e_min, emax=args.e_max)

Expand Down

0 comments on commit 5cbfd91

Please sign in to comment.