Skip to content

Commit

Permalink
Merge branch 'main' into fix-resources-step
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresOrtegaGuerrero authored Dec 2, 2024
2 parents 888d042 + 329e198 commit 00a3e05
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/aiidalab_qe/app/configuration/advanced/pseudos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def update_family_parameters(self):
return
if self.spin_orbit == "soc":
if self.protocol in ["fast", "moderate"]:
pseudo_family_string = "PseudoDojo/0.4/PBE/FR/standard/upf"
pseudo_family_string = "PseudoDojo/0.4/PBEsol/FR/standard/upf"
else:
pseudo_family_string = "PseudoDojo/0.4/PBE/FR/stringent/upf"
pseudo_family_string = "PseudoDojo/0.4/PBEsol/FR/stringent/upf"
else:
pseudo_family_string = PwBaseWorkChain.get_protocol_inputs(self.protocol)[
"pseudo_family"
Expand Down
17 changes: 16 additions & 1 deletion src/aiidalab_qe/app/submission/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ def update_process_label(self):
"workchain",
{"properties": []},
)

soc_parameters = self.input_parameters["advanced"]["pw"]["parameters"][
"SYSTEM"
].get("lspinorb", False)

soc_info = "spin-orbit coupling" if soc_parameters else ""

properties = [p for p in workchain_data["properties"] if p != "relax"]
relax_type = workchain_data.get("relax_type", "none")
relax_info = "unrelaxed"
Expand All @@ -102,7 +109,15 @@ def update_process_label(self):
if workchain_data["spin_type"] != "none":
protocol_and_magnetic_info += ", magnetic"
properties_info = f"→ {', '.join(properties)}" if properties else ""
label = f"{structure_label} [{relax_info}, {protocol_and_magnetic_info}] {properties_info}".strip()

label_details = [
relax_info,
protocol_and_magnetic_info,
soc_info,
]
filtered_label_details = [detail for detail in label_details if detail]
label = f"{structure_label} [{', '.join(filtered_label_details)}] {properties_info}".strip()

self.process_label = label

def update_plugin_inclusion(self):
Expand Down
46 changes: 37 additions & 9 deletions src/aiidalab_qe/common/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,11 @@ def __init__(self, title="", **kwargs):

self._status_message = StatusHTML()
self.atom_selection = ipw.Text(
description="Index of atoms", value="", layout={"width": "initial"}
placeholder="e.g. 1..5 8 10",
description="Index of atoms",
value="",
style={"description_width": "100px"},
layout={"width": "initial"},
)
self.from_selection = ipw.Button(description="From selection")
self.from_selection.on_click(self._from_selection)
Expand Down Expand Up @@ -478,6 +482,10 @@ def __init__(self, title="", **kwargs):
button_style="primary",
layout={"width": "100px"},
)
self.scroll_note = ipw.HTML(
value="<p style='font-style: italic;'>Note: The table is scrollable.</p>",
layout={"visibility": "hidden"},
)
self.tag_display = ipw.Output()
self.add_tags.on_click(self._add_tags)
self.reset_tags.on_click(self._reset_tags)
Expand All @@ -491,7 +499,20 @@ def __init__(self, title="", **kwargs):
super().__init__(
children=[
ipw.HTML(
"<b>Adding a tag to atoms</b>",
"<b>Set custom tags for atoms</b>",
),
ipw.HTML(
"""
<p>
These are used to distinguish atoms of the same chemical element. <br>
For example, they can be used to assign different initial magnetization values for antiferromagnetic systems.
</p>
<p style="font-weight: bold; color: #1f77b4;">NOTE:</p>
<ul style="padding-left: 2em; list-style-type: disc;">
<li>Atom indices start from 1, not 0. This means that the first atom in the list is numbered 1, the second atom is numbered 2, and so on.</li>
</ul>
</p>
"""
),
ipw.HBox(
[
Expand All @@ -501,10 +522,11 @@ def __init__(self, title="", **kwargs):
]
),
self.tag_display,
self.scroll_note,
ipw.HBox([self.add_tags, self.reset_tags, self.reset_all_tags]),
self._status_message,
ipw.HTML(
"<b>Define periodicity</b>",
'<div style="margin-top: 20px;"><b>Set structure periodicity</b></div>'
),
ipw.HTML("""
<p>Select the periodicity of your system.</p>
Expand All @@ -530,14 +552,18 @@ def _display_table(self, _=None):
current_tags = self.structure.get_tags()
chemichal_symbols = self.structure.get_chemical_symbols()

if selection and (max(selection) <= (len(self.structure) - 1)):
if (
selection
and (min(selection) >= 0)
and (max(selection) <= (len(self.structure) - 1))
):
table_data = []
for index in selection:
tag = current_tags[index]
symbol = chemichal_symbols[index]
if tag == 0:
tag = ""
table_data.append([f"{index}", f"{symbol}", f"{tag}"])
table_data.append([f"{index+ 1}", f"{symbol}", f"{tag}"])

# Create an HTML table
table_html = "<table>"
Expand All @@ -558,10 +584,12 @@ def _display_table(self, _=None):
with self.tag_display:
clear_output()
display(HTML(table_html))
self.scroll_note.layout = {"visibility": "visible"}
else:
self.tag_display.layout = {}
with self.tag_display:
clear_output()
self.scroll_note.layout = {"visibility": "hidden"}

def _from_selection(self, _=None):
"""Set the atom selection from the current selection."""
Expand Down Expand Up @@ -621,10 +649,10 @@ def _reset_all_tags(self, _=None):
def _select_periodicity(self, _=None):
"""Select periodicity."""
periodicity_options = {
"3D": (True, True, True),
"2D": (True, True, False),
"1D": (True, False, False),
"Molecule": (False, False, False),
"xyz": (True, True, True),
"xy": (True, True, False),
"x": (True, False, False),
"molecule": (False, False, False),
}
new_structure = deepcopy(self.structure)
new_structure.set_pbc(periodicity_options[self.periodicity.value])
Expand Down
1 change: 1 addition & 0 deletions src/aiidalab_qe/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def get_builder_from_protocol(
"base_final_scf": parameters["advanced"],
}
protocol = parameters["workchain"]["protocol"]

relax_builder = PwRelaxWorkChain.get_builder_from_protocol(
code=codes["global"]["codes"].get("quantumespresso.pw")["code"],
structure=structure,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pseudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_pseudos_settings(generate_structure_data, generate_upf_data):
# Test spin-orbit-dependent family change
model.spin_orbit = "soc"
model.protocol = "moderate"
assert model.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/FR/standard/upf"
assert model.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBEsol/FR/standard/upf"

# Reset the external dependencies of the model
model.spin_orbit = "wo_soc"
Expand Down

0 comments on commit 00a3e05

Please sign in to comment.