Skip to content

Commit

Permalink
Bump SSSP to 1.3 and DOJO version to 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Dec 12, 2023
1 parent 30ffe7a commit 993d688
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/source/development/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The dictionary has the following structure:
},
"pseudos": {"Si": "eaef3352-2b0e-4205-b404-e6565a88aec8"},
},
"pseudo_family": "SSSP/1.2/PBEsol/efficiency",
"pseudo_family": "SSSP/1.3/PBEsol/efficiency",
"kpoints_distance": 0.5,
},
"bands": {"kpath_2d": "hexagonal"},
Expand Down
2 changes: 1 addition & 1 deletion docs/source/development/plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ The `parameters` passed to the `get_builder` function has the following structur
},
"pseudos": {"Si": "eaef3352-2b0e-4205-b404-e6565a88aec8"},
},
"pseudo_family": "SSSP/1.2/PBEsol/efficiency",
"pseudo_family": "SSSP/1.3/PBEsol/efficiency",
"kpoints_distance": 0.5,
},
"bands": {"kpath_2d": "hexagonal"},
Expand Down
9 changes: 5 additions & 4 deletions src/aiidalab_qe/app/configuration/advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def _update_settings_from_protocol(self, protocol):

self.kpoints_distance.value = parameters["kpoints_distance"]

# The pseudo_family read from the protocol (aiida-quantumespresso plugin settings)
# The logic is the same as the pseudo_family_selector widget
parameters["pseudo_family"] = self.pseudo_family_selector.value

def _callback_value_set(self, _=None):
"""Callback function to set the parameters"""
settings = {
Expand Down Expand Up @@ -299,10 +303,7 @@ def reset(self):
self._update_settings_from_protocol(self.protocol)

# reset the pseudo family
pseudo_family_dict = DEFAULT_PARAMETERS["advanced"]["pseudo_family"]
pseudo_family = PseudoFamily(**pseudo_family_dict)

self.pseudo_family_selector.load_from_pseudo_family(pseudo_family)
self.pseudo_family_selector.reset()

# reset total charge
self.total_charge.value = DEFAULT_PARAMETERS["advanced"]["tot_charge"]
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/configuration/pseudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def __init__(self, **kwargs):
self.override = ipw.Checkbox(
description="",
indent=False,
value=False,
layout=ipw.Layout(max_width="10%"),
)
self.set_pseudo_family_box = ipw.HBox(
Expand Down Expand Up @@ -140,6 +139,7 @@ def __init__(self, **kwargs):
# this will trigger the callback to set the value of widgets to the default
self._default_protocol = DEFAULT_PARAMETERS["workchain"]["protocol"]
self.protocol = self._default_protocol
self.override.value = False

def set_value(self, _=None):
"""The callback when the selection of pseudo family or dft functional is changed.
Expand Down
2 changes: 1 addition & 1 deletion src/aiidalab_qe/app/parameters/qeapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workchain:
advanced:
pseudo_family:
library: SSSP
version: 1.2
version: 1.3
functional: PBEsol
accuracy: efficiency
tot_charge: 0
Expand Down
4 changes: 2 additions & 2 deletions src/aiidalab_qe/common/setup_pseudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

from aiidalab_qe.common.widgets import ProgressBar

SSSP_VERSION = "1.2"
PSEUDODOJO_VERSION = "0.4"
SSSP_VERSION = "1.3"
PSEUDODOJO_VERSION = "0.5"

EXPECTED_PSEUDOS = {
f"SSSP/{SSSP_VERSION}/PBE/efficiency",
Expand Down
13 changes: 8 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def sssp(aiida_profile, generate_upf_data):
from aiida.common.constants import elements
from aiida.plugins import GroupFactory

from aiidalab_qe.common.setup_pseudos import SSSP_VERSION

aiida_profile.clear_profile()

SsspFamily = GroupFactory("pseudo.family.sssp")
Expand Down Expand Up @@ -214,7 +216,7 @@ def sssp(aiida_profile, generate_upf_data):
"cutoff_rho": 240.0,
}

label = "SSSP/1.2/PBEsol/efficiency"
label = f"SSSP/{SSSP_VERSION}/PBEsol/efficiency"
family = SsspFamily.create_from_folder(dirpath, label)

family.set_cutoffs(cutoffs, stringency, unit="Ry")
Expand Down Expand Up @@ -515,9 +517,7 @@ def _generate_pdos_workchain(structure, spin_type="none"):

@pytest.fixture
def generate_bands_workchain(
fixture_localhost,
fixture_code,
generate_xy_data,
generate_bands_data,
generate_workchain,
):
Expand Down Expand Up @@ -579,6 +579,8 @@ def _generate_qeapp_workchain(

from aiida.orm.utils.serialize import serialize

from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep
from aiidalab_qe.app.submission import SubmitQeAppWorkChainStep
from aiidalab_qe.workflows import QeAppWorkChain

# Step 1: select structure from example
Expand All @@ -595,7 +597,7 @@ def _generate_qeapp_workchain(
s1.confirm()
structure = s1.confirmed_structure
# step 2 configure
s2 = app.configure_step
s2: ConfigureQeAppWorkChainStep = app.configure_step
s2.workchain_settings.relax_type.value = relax_type
# In order to parepare a complete inputs, I set all the properties to true
# this can be overrided later
Expand All @@ -606,9 +608,10 @@ def _generate_qeapp_workchain(
s2.advanced_settings.magnetization._set_magnetization_values(
initial_magnetic_moments
)
print(s2.advanced_settings.pseudo_family_selector.value)
s2.confirm()
# step 3 setup code and resources
s3 = app.submit_step
s3: SubmitQeAppWorkChainStep = app.submit_step
s3.resources_config.num_cpus.value = 4
builder = s3._create_builder()
inputs = builder._inputs()
Expand Down
9 changes: 7 additions & 2 deletions tests/test_configure.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from aiidalab_qe.common.setup_pseudos import PSEUDODOJO_VERSION, SSSP_VERSION


def test_protocol():
"""Test the protocol.
The protocol from workchain_settings will trigger the
Expand Down Expand Up @@ -31,12 +34,14 @@ def test_set_configuration_parameters():
wg = ConfigureQeAppWorkChainStep()
parameters = wg.get_configuration_parameters()
parameters["workchain"]["relax_type"] = "positions"
parameters["advanced"]["pseudo_family"] = "SSSP/1.2/PBE/efficiency"
parameters["advanced"]["pseudo_family"] = f"SSSP/{SSSP_VERSION}/PBE/efficiency"
wg.set_configuration_parameters(parameters)
new_parameters = wg.get_configuration_parameters()
assert parameters == new_parameters
# test pseudodojo
parameters["advanced"]["pseudo_family"] = "PseudoDojo/0.4/PBEsol/SR/standard/upf"
parameters["advanced"][
"pseudo_family"
] = f"PseudoDojo/{PSEUDODOJO_VERSION}/PBEsol/SR/standard/upf"
wg.set_configuration_parameters(parameters)
new_parameters = wg.get_configuration_parameters()
assert parameters == new_parameters
Expand Down
21 changes: 13 additions & 8 deletions tests/test_pseudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def test_setup_pseudos_cmd(tmp_path):
assert "--from-download" not in cmd

# mock the source file
source_file = tmp_path / "PseudoDojo_0.4_PBEsol_SR_standard_upf.aiida_pseudo"
source_file = (
tmp_path
/ f"PseudoDojo_{PSEUDODOJO_VERSION}_PBEsol_SR_standard_upf.aiida_pseudo"
)
source_file.touch()
cmd = _construct_cmd(pseudo_family, cwd=tmp_path)
assert cmd == [
Expand All @@ -85,15 +88,15 @@ def test_setup_pseudos_cmd(tmp_path):
"--functional",
"PBEsol",
"--version",
"0.4",
f"{PSEUDODOJO_VERSION}",
"-p",
"standard",
"--relativistic",
"SR",
"--pseudo-format",
"upf",
"--from-download",
f"{str(tmp_path)}/PseudoDojo_0.4_PBEsol_SR_standard_upf.aiida_pseudo",
f"{str(tmp_path)}/PseudoDojo_{PSEUDODOJO_VERSION}_PBEsol_SR_standard_upf.aiida_pseudo",
]


Expand Down Expand Up @@ -146,19 +149,19 @@ def test_pseudos_family_selector_widget():
w.override.value = True

# test the default value
assert w.value == "SSSP/1.2/PBEsol/efficiency"
assert w.value == f"SSSP/{SSSP_VERSION}/PBEsol/efficiency"

# Test if the protocol change the value will be updated
w.protocol = "precise"
assert w.value == "SSSP/1.2/PBEsol/precision"
assert w.value == f"SSSP/{SSSP_VERSION}/PBEsol/precision"

# test the functional change will update the value
w.dft_functional.value = "PBE"
assert w.value == "SSSP/1.2/PBE/precision"
assert w.value == f"SSSP/{SSSP_VERSION}/PBE/precision"

# Test if selecet new pseudo library the value will be updated
w.library_selection.value = "PseudoDojo stringent"
assert w.value == "PseudoDojo/0.4/PBE/SR/stringent/upf"
assert w.value == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/SR/stringent/upf"


@pytest.mark.usefixtures("sssp")
Expand All @@ -168,7 +171,9 @@ def test_pseudos_setter_widget(generate_structure_data, generate_upf_data):

# test the widget is set with the elements of the structure
silicon = generate_structure_data("silicon")
w = PseudoSetter(structure=silicon, pseudo_family="SSSP/1.2/PBEsol/efficiency")
w = PseudoSetter(
structure=silicon, pseudo_family=f"SSSP/{SSSP_VERSION}/PBEsol/efficiency"
)

assert "Si" in w.pseudos.keys()
assert w.ecutwfc == 30
Expand Down
4 changes: 2 additions & 2 deletions tests/test_result/test_summary_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ properties:
- pdos
- relax
protocol: fast
pseudo_family: SSSP/1.2/PBEsol/efficiency
pseudo_family: SSSP/1.3/PBEsol/efficiency
pseudo_library: SSSP
pseudo_link: https://www.materialscloud.org/discover/sssp/table/efficiency
pseudo_protocol: efficiency
pseudo_version: '1.2'
pseudo_version: '1.3'
relax_method: positions_cell
relaxed: positions_cell
scf_kpoints_distance: 0.5
Expand Down

0 comments on commit 993d688

Please sign in to comment.