Skip to content

Commit

Permalink
Spruce up advanced panel styling
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 12, 2025
1 parent 5d9ad7e commit a0bcfb4
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 159 deletions.
101 changes: 47 additions & 54 deletions src/aiidalab_qe/app/configuration/advanced/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ def render(self):
if self.rendered:
return

# clean-up workchain settings
self.reset_to_defaults_button = ipw.Button(
description="Reset to defaults",
button_style="primary",
icon="undo",
layout=ipw.Layout(width="fit-content"),
)
self.reset_to_defaults_button.on_click(self._on_reset_to_defaults_button_click)

self.clean_workdir = ipw.Checkbox(
description="Tick to delete the work directory after the calculation is finished",
description="Delete the work directory after the calculation",
indent=False,
layout=ipw.Layout(width="fit-content"),
)
ipw.link(
(self._model, "clean_workdir"),
(self.clean_workdir, "value"),
)
self.reset_to_defaults_button = ipw.Button(
description="Reset to defaults",
button_style="warning",
icon="undo",
layout=ipw.Layout(width="fit-content"),
)
self.reset_to_defaults_button.on_click(self._on_reset_to_defaults_button_click)

# Smearing setting widget
self.smearing.render()
Expand All @@ -98,8 +98,8 @@ def render(self):
self.kpoints_distance = ipw.BoundedFloatText(
min=0.0,
step=0.05,
description="K-points distance (1/Å):",
style={"description_width": "initial"},
description="K-points distance:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "kpoints_distance"),
Expand All @@ -110,7 +110,7 @@ def render(self):
(self.kpoints_distance, "disabled"),
lambda _: not self._model.has_pbc,
)
self.mesh_grid = ipw.HTML()
self.mesh_grid = ipw.HTML(layout=ipw.Layout(margin="0 0 0 10px"))
ipw.dlink(
(self._model, "mesh_grid"),
(self.mesh_grid, "value"),
Expand All @@ -125,7 +125,7 @@ def render(self):
max=3,
step=0.01,
description="Total charge:",
style={"description_width": "initial"},
style={"description_width": "150px"},
)
ipw.link(
(self._model, "total_charge"),
Expand All @@ -135,7 +135,7 @@ def render(self):
# Van der Waals setting widget
self.van_der_waals = ipw.Dropdown(
description="Van der Waals correction:",
style={"description_width": "initial"},
style={"description_width": "150px"},
)
ipw.dlink(
(self._model, "van_der_waals_options"),
Expand All @@ -153,8 +153,9 @@ def render(self):
self.scf_conv_thr = ipw.BoundedFloatText(
min=1e-15,
max=1.0,
description="SCF conv.:",
style={"description_width": "initial"},
format="0.0e",
description="SCF:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "scf_conv_thr"),
Expand All @@ -167,8 +168,9 @@ def render(self):
self.forc_conv_thr = ipw.BoundedFloatText(
min=1e-15,
max=1.0,
description="Force conv.:",
style={"description_width": "initial"},
format="0.0e",
description="Force:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "forc_conv_thr"),
Expand All @@ -181,8 +183,9 @@ def render(self):
self.etot_conv_thr = ipw.BoundedFloatText(
min=1e-15,
max=1.0,
description="Energy conv.:",
style={"description_width": "initial"},
format="0.0e",
description="Energy:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "etot_conv_thr"),
Expand All @@ -196,8 +199,8 @@ def render(self):
min=20,
max=1000,
step=1,
description="Max. electron steps:",
style={"description_width": "initial"},
description="Electronic:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "electron_maxstep"),
Expand All @@ -208,8 +211,8 @@ def render(self):
min=50,
max=1000,
step=1,
description="Max. optimization steps:",
style={"description_width": "initial"},
description="Ionic:",
style={"description_width": "150px"},
)
ipw.link(
(self._model, "optimization_maxsteps"),
Expand All @@ -219,48 +222,38 @@ def render(self):

self.children = [
InAppGuide(identifier="advanced-settings"),
ipw.HBox(
children=[
self.clean_workdir,
self.reset_to_defaults_button,
],
layout=ipw.Layout(
justify_content="space-between",
margin="0 0 10px 0",
),
),
self.reset_to_defaults_button,
self.clean_workdir,
self.total_charge,
self.van_der_waals,
self.magnetization,
ipw.HTML("<b>Convergence thresholds:</b>"),
ipw.HBox(
children=[
self.forc_conv_thr,
self.etot_conv_thr,
self.scf_conv_thr,
],
layout=ipw.Layout(justify_content="space-between"),
),
ipw.HBox(
children=[
self.electron_maxstep,
self.optimization_maxsteps,
],
),
ipw.HTML("<b>Convergence thresholds</b>"),
self.forc_conv_thr,
self.etot_conv_thr,
self.scf_conv_thr,
ipw.HTML("<b>Maximum cycle steps</b>"),
self.electron_maxstep,
self.optimization_maxsteps,
self.smearing,
ipw.HTML("<b>K-points</b>"),
ipw.HTML("""
<div>
<div style="line-height: 1.4; margin-bottom: 5px;">
The k-points mesh density of the SCF calculation is set by the
<b>protocol</b>. The value below represents the maximum distance
between the k-points in each direction of reciprocal space. Smaller
is more accurate and costly.
<b>protocol</b>.
<br>
The value below represents the maximum distance between k-points
in each direction of reciprocal space.
<br>
Smaller is more accurate and costly.
</div>
"""),
ipw.HBox(
children=[
self.kpoints_distance,
ipw.HTML("Å<sup>-1</sup>"),
self.mesh_grid,
]
],
layout=ipw.Layout(align_items="center"),
),
self.hubbard,
self.pseudos,
Expand Down
30 changes: 14 additions & 16 deletions src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ def render(self):
return

self.activate_hubbard_checkbox = ipw.Checkbox(
description="",
description="Define U values",
indent=False,
layout=ipw.Layout(max_width="10%"),
)
ipw.link(
(self._model, "is_active"),
Expand All @@ -44,7 +43,6 @@ def render(self):
self.define_eigenvalues_checkbox = ipw.Checkbox(
description="Define eigenvalues",
indent=False,
layout=ipw.Layout(max_width="30%"),
)
ipw.link(
(self._model, "has_eigenvalues"),
Expand All @@ -64,12 +62,8 @@ def render(self):
self.container = ipw.VBox()

self.children = [
ipw.HBox(
children=[
ipw.HTML("<b>Hubbard (DFT+U)</b>"),
self.activate_hubbard_checkbox,
]
),
ipw.HTML("<b>Hubbard (DFT+U)</b>"),
self.activate_hubbard_checkbox,
self.container,
]

Expand Down Expand Up @@ -107,16 +101,13 @@ def _build_hubbard_widget(self):

children = []

if self._model.input_structure:
children.append(ipw.HTML("Define U value [eV] "))

for label in self._model.orbital_labels:
float_widget = ipw.BoundedFloatText(
description=label,
min=0,
max=20,
step=0.1,
layout={"width": "160px"},
style={"description_width": "150px"},
)
link = ipw.link(
(self._model, "parameters"),
Expand All @@ -130,7 +121,14 @@ def _build_hubbard_widget(self):
],
)
self.links.append(link)
children.append(float_widget)
children.append(
ipw.HBox(
children=[
float_widget,
ipw.HTML("eV"),
],
)
)

if self._model.needs_eigenvalues_widget:
children.append(self.eigenvalues_container)
Expand Down Expand Up @@ -158,7 +156,7 @@ def update(index, spin, state, symbol, value):

for state_index in range(num_states):
eigenvalues_up = ipw.Dropdown(
description=f"{state_index+1}",
description=f"{state_index + 1}",
layout=ipw.Layout(width="65px"),
style={"description_width": "initial"},
)
Expand Down Expand Up @@ -191,7 +189,7 @@ def update(index, spin, state, symbol, value):
spin_up_row.children += (eigenvalues_up,)

eigenvalues_down = ipw.Dropdown(
description=f"{state_index+1}",
description=f"{state_index + 1}",
layout=ipw.Layout(width="65px"),
style={"description_width": "initial"},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ def render(self):
if self.rendered:
return

self.header = ipw.HTML("<b>Magnetization:</b>")
self.header = ipw.HTML("<b>Magnetization</b>")

self.unit = ipw.HTML(
value="µ<sub>B</sub>",
layout=ipw.Layout(margin="2px 2px 5px"),
)
self.unit = ipw.HTML("µ<sub>B</sub>")

self.magnetization_type_help = ipw.HTML()
ipw.dlink(
Expand All @@ -62,11 +59,8 @@ def render(self):
)

self.magnetization_type = ipw.ToggleButtons(
style={
"description_width": "initial",
"button_width": "initial",
},
layout=ipw.Layout(margin="0 0 10px 0"),
style={"button_width": "initial"},
layout=ipw.Layout(margin="0 0 5px"),
)
ipw.dlink(
(self._model, "type_options"),
Expand All @@ -82,7 +76,7 @@ def render(self):
max=100,
step=1,
description="Total magnetization:",
style={"description_width": "initial"},
style={"description_width": "150px"},
)
ipw.link(
(self._model, "total"),
Expand All @@ -94,7 +88,6 @@ def render(self):
self.tot_magnetization,
self.unit,
],
layout=ipw.Layout(align_items="center"),
)

self.kind_moment_widgets = ipw.VBox()
Expand Down Expand Up @@ -161,6 +154,7 @@ def _build_kinds_widget(self):
min=-7,
max=7,
step=0.1,
style={"description_width": "150px"},
)
link = ipw.link(
(self._model, "moments"),
Expand All @@ -180,7 +174,6 @@ def _build_kinds_widget(self):
kind_moment_widget,
self.unit,
],
layout=ipw.Layout(align_items="center"),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def update_type_help(self):
content="""
If a nonzero ground-state magnetization is expected, you
<strong>must</strong> assign a nonzero value to at least one atomic
type (note that the app already provide tentative initial values).
type (the app already provides tentative initial values).
<br>
To simulate an antiferromagnetic state, first, if you have not
done so already, please use the atom tag editor <b>(Select
structure -> Edit structure -> Edit atom tags)</b> to mark atoms of
Expand Down
9 changes: 5 additions & 4 deletions src/aiidalab_qe/app/configuration/advanced/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .smearing import SmearingConfigurationSettingsModel

DEFAULT: dict = DEFAULT_PARAMETERS # type: ignore
SIGFIGS = 5


class AdvancedConfigurationSettingsModel(
Expand Down Expand Up @@ -296,7 +297,7 @@ def _update_thresholds(self, parameters):
self.forc_conv_thr_step = self._defaults["forc_conv_thr_step"]

def _set_value_and_step(self, attribute, value):
self._defaults[attribute] = value
self._defaults[attribute] = round(value, SIGFIGS)
if value != 0:
order_of_magnitude = np.floor(np.log10(abs(value)))
step = 10 ** (order_of_magnitude - 1)
Expand All @@ -309,9 +310,9 @@ def _set_pw_parameters(self, pw_parameters):
control_params = pw_parameters.get("CONTROL", {})
electron_params = pw_parameters.get("ELECTRONS", {})

self.forc_conv_thr = control_params.get("forc_conv_thr", 0.0)
self.etot_conv_thr = control_params.get("etot_conv_thr", 0.0)
self.scf_conv_thr = electron_params.get("conv_thr", 0.0)
self.forc_conv_thr = round(control_params.get("forc_conv_thr", 0.0), SIGFIGS)
self.etot_conv_thr = round(control_params.get("etot_conv_thr", 0.0), SIGFIGS)
self.scf_conv_thr = round(electron_params.get("conv_thr", 0.0), SIGFIGS)
self.electron_maxstep = electron_params.get("electron_maxstep", 80)

self.total_charge = system_params.get("tot_charge", 0)
Expand Down
Loading

0 comments on commit a0bcfb4

Please sign in to comment.