Skip to content

Commit

Permalink
Bump SSSP to 1.3 (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz authored Dec 18, 2023
1 parent 83bfea6 commit 102f39a
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 29 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
3 changes: 2 additions & 1 deletion post_install
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

# This script is executed after the app installation completes
# triggered by the post install hook implemented in https://github.com/aiidalab/aiidalab/pull/295
# TODO: this script is not yet properly tested. The integration tests are run from the qeapp docker image, this script is executed when the app is installed by `aiidalab install`. Therefore, we need to bring original di test (which removed in https://github.com/aiidalab/aiidalab-qe/pull/449/files#diff-83993fe9ad162677c85ae244400df2469b6d666c2a28d7b8d179785e87beb7f3) back.

echo "Starting installation of QE..."
python -m aiidalab_qe install-qe & disown

echo "Starting installation of pseudo-potentials..."
python -m aiidalab_qe install-sssp & disown
python -m aiidalab_qe install-pseudos & disown
2 changes: 1 addition & 1 deletion qe.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.9.13"
},
"vscode": {
"interpreter": {
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)
# we override it with the value from 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
3 changes: 2 additions & 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 Expand Up @@ -197,6 +197,7 @@ def _protocol_changed(self, _):

def _update_settings_from_protocol(self, protocol):
"""Update the widget values from the given protocol, and trigger the callback."""
# FIXME: this rely on the aiida-quantumespresso, which is not ideal
pseudo_family_string = PwBaseWorkChain.get_protocol_inputs(protocol)[
"pseudo_family"
]
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
2 changes: 1 addition & 1 deletion src/aiidalab_qe/common/setup_pseudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from aiidalab_qe.common.widgets import ProgressBar

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

EXPECTED_PSEUDOS = {
Expand Down
5 changes: 5 additions & 0 deletions src/aiidalab_qe/plugins/bands/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,18 @@ def get_builder(codes, structure, parameters, **kwargs):
pw_code = codes.get("pw")
protocol = parameters["workchain"]["protocol"]
scf_overrides = deepcopy(parameters["advanced"])
relax_overrides = {
"base": deepcopy(parameters["advanced"]),
"base_final_scf": deepcopy(parameters["advanced"]),
}
bands_overrides = deepcopy(parameters["advanced"])
bands_overrides.pop("kpoints_distance", None)
bands_overrides["pw"]["parameters"]["SYSTEM"].pop("smearing", None)
bands_overrides["pw"]["parameters"]["SYSTEM"].pop("degauss", None)
overrides = {
"scf": scf_overrides,
"bands": bands_overrides,
"relax": relax_overrides,
}
bands = PwBandsWorkChain.get_builder_from_protocol(
code=pw_code,
Expand Down
5 changes: 4 additions & 1 deletion src/aiidalab_qe/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def get_builder_from_protocol(
# Set the structure.
builder.structure = structure
# relax
relax_overrides = {"base": parameters["advanced"]}
relax_overrides = {
"base": parameters["advanced"],
"base_final_scf": parameters["advanced"],
}
protocol = parameters["workchain"]["protocol"]
relax_builder = PwRelaxWorkChain.get_builder_from_protocol(
code=codes.get("pw"),
Expand Down
40 changes: 35 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import pytest
from aiida import orm

from aiidalab_qe.common.setup_pseudos import SSSP_VERSION

pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]


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 @@ -423,11 +425,21 @@ def _generate_pdos_workchain(structure, spin_type="none"):
from aiida.orm import Dict, FolderData, RemoteData
from aiida_quantumespresso.workflows.pdos import PdosWorkChain

pseudo_family = f"SSSP/{SSSP_VERSION}/PBEsol/efficiency"

inputs = {
"pw_code": fixture_code("quantumespresso.pw"),
"dos_code": fixture_code("quantumespresso.dos"),
"projwfc_code": fixture_code("quantumespresso.projwfc"),
"structure": structure,
"overrides": {
"scf": {
"pseudo_family": pseudo_family,
},
"nscf": {
"pseudo_family": pseudo_family,
},
},
}
builder = PdosWorkChain.get_builder_from_protocol(**inputs)
inputs = builder._inputs()
Expand Down Expand Up @@ -515,9 +527,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 All @@ -530,9 +540,27 @@ def _generate_bands_workchain(structure):
from aiida.orm import Dict
from aiida_quantumespresso.workflows.pw.bands import PwBandsWorkChain

pseudo_family = f"SSSP/{SSSP_VERSION}/PBEsol/efficiency"

inputs = {
"code": fixture_code("quantumespresso.pw"),
"structure": structure,
"overrides": {
"scf": {
"pseudo_family": pseudo_family,
},
"bands": {
"pseudo_family": pseudo_family,
},
"relax": {
"base": {
"pseudo_family": pseudo_family,
},
"base_final_scf": {
"pseudo_family": pseudo_family,
},
},
},
}
builder = PwBandsWorkChain.get_builder_from_protocol(**inputs)
inputs = builder._inputs()
Expand Down Expand Up @@ -579,6 +607,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 +625,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 @@ -608,7 +638,7 @@ def _generate_qeapp_workchain(
)
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
6 changes: 6 additions & 0 deletions tests/test_submit_qe_workchain.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import pytest


@pytest.mark.usefixtures("sssp")
def test_create_builder_default(
data_regression,
submit_app_generator,
Expand All @@ -19,6 +23,7 @@ def test_create_builder_default(
data_regression.check(got)


@pytest.mark.usefixtures("sssp")
def test_create_builder_insulator(
submit_app_generator,
):
Expand All @@ -41,6 +46,7 @@ def test_create_builder_insulator(
assert "smearing" not in got["bands"]["scf"]["pw"]["parameters"]["SYSTEM"]


@pytest.mark.usefixtures("sssp")
def test_create_builder_advanced_settings(
submit_app_generator,
):
Expand Down

0 comments on commit 102f39a

Please sign in to comment.