Skip to content

Commit

Permalink
Merge branch 'main' into full_width_plugin_page
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 authored Jan 13, 2025
2 parents a7b59b6 + 403e5c9 commit 607da6f
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 204 deletions.
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Required
version: 2

sphinx:
configuration: docs/source/conf.py

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
Expand Down
129 changes: 72 additions & 57 deletions src/aiidalab_qe/app/configuration/advanced/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from aiidalab_qe.common.infobox import InAppGuide
from aiidalab_qe.common.panel import ConfigurationSettingsPanel
from aiidalab_qe.common.widgets import HBoxWithUnits

from .hubbard import (
HubbardConfigurationSettingsModel,
Expand Down Expand Up @@ -73,23 +74,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"),
layout=ipw.Layout(width="fit-content", margin="5px 2px"),
)
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 +99,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 +111,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 +126,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 +136,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 +154,8 @@ def render(self):
self.scf_conv_thr = ipw.BoundedFloatText(
min=1e-15,
max=1.0,
description="SCF conv.:",
style={"description_width": "initial"},
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,49 +222,61 @@ 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("<h2>Convergence</h2>"),
ipw.HTML("""
<div style="line-height: 1.4; margin-bottom: 5px;">
Control the convergence criteria of the self-consistent field (SCF)
geometry optimization cycles.
</div>
"""),
ipw.HTML("<h4>Thresholds</h4>"),
ipw.HTML("""
<div style="line-height: 1.4; margin-bottom: 5px;">
Setting thresholds for energy, force, and self-consistency ensures calculation accuracy and stability.
<br>
Lower values increase the accuracy but also the computational cost.
<br>
The default values are set by the <b>protocol</b> are usually a
good starting point.
</div>
"""),
HBoxWithUnits(self.forc_conv_thr, "a.u."),
HBoxWithUnits(self.etot_conv_thr, "a.u."),
self.scf_conv_thr,
ipw.HTML("<h4>Maximum cycle steps</h4>"),
ipw.HTML("""
<div style="line-height: 1.4; margin-bottom: 5px;">
Setting a maximum number of electronic and ionic optimization steps
ensures that the calculation does not run indefinitely.
</div>
"""),
self.electron_maxstep,
self.optimization_maxsteps,
self.smearing,
ipw.HTML("<h2>K-points</h2>"),
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,
HBoxWithUnits(self.kpoints_distance, "Å<sup>-1</sup>"),
self.mesh_grid,
]
],
layout=ipw.Layout(align_items="center"),
),
self.magnetization,
self.hubbard,
self.pseudos,
]
Expand Down
55 changes: 32 additions & 23 deletions src/aiidalab_qe/app/configuration/advanced/hubbard/hubbard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import ipywidgets as ipw

from aiidalab_qe.common.widgets import HBoxWithUnits

from ..subsettings import AdvancedConfigurationSubSettingsPanel
from .model import HubbardConfigurationSettingsModel

Expand Down Expand Up @@ -28,23 +30,24 @@ 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"),
(self.activate_hubbard_checkbox, "value"),
)

self.eigenvalues_help = ipw.HTML(
value="For transition metals and lanthanoids, the starting eigenvalues can be defined (Magnetic calculation).",
layout=ipw.Layout(width="auto"),
)
self.eigenvalues_help = ipw.HTML("""
<div style="line-height: 1.4; margin-bottom: 5px;">
For transition metals and lanthanoids, the starting eigenvalues can be defined (magnetic calculation).
<br>
It is useful to suggest the desired orbital occupations when the default choice takes another path.
</div>
""")
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 +67,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("<h2>Hubbard (DFT+U)</h2>"),
self.activate_hubbard_checkbox,
self.container,
]

Expand Down Expand Up @@ -107,16 +106,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 +126,7 @@ def _build_hubbard_widget(self):
],
)
self.links.append(link)
children.append(float_widget)
children.append(HBoxWithUnits(float_widget, "eV"))

if self._model.needs_eigenvalues_widget:
children.append(self.eigenvalues_container)
Expand All @@ -153,12 +149,19 @@ def update(index, spin, state, symbol, value):
(kind_name, num_states),
) in enumerate(self._model.applicable_kind_names):
label_layout = ipw.Layout(justify_content="flex-start", width="50px")
spin_up_row = ipw.HBox([ipw.Label("Up:", layout=label_layout)])
spin_down_row = ipw.HBox([ipw.Label("Down:", layout=label_layout)])
spin_row_layout = ipw.Layout(grid_gap="5px")
spin_up_row = ipw.HBox(
children=[ipw.Label("Up:", layout=label_layout)],
layout=spin_row_layout,
)
spin_down_row = ipw.HBox(
children=[ipw.Label("Down:", layout=label_layout)],
layout=spin_row_layout,
)

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 +194,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 Expand Up @@ -226,7 +229,13 @@ def update(index, spin, state, symbol, value):
children.append(
ipw.HBox(
[
ipw.Label(kind_name, layout=label_layout),
ipw.Label(
kind_name,
layout=ipw.Layout(
justify_content="flex-start",
width="80px",
),
),
ipw.VBox(
children=[
spin_up_row,
Expand Down
Loading

0 comments on commit 607da6f

Please sign in to comment.