Skip to content

Commit

Permalink
Only SCF with relaxType -> None
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Sep 1, 2022
1 parent e98e528 commit 96caa11
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
22 changes: 7 additions & 15 deletions aiidalab_qe/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Carl Simon Adorf <simon.adorf@epfl.ch>
"""
import os
from pickle import NONE

import ipywidgets as ipw
import traitlets
Expand Down Expand Up @@ -404,21 +405,8 @@ def set_input_parameters(self, parameters):
def _update_state(self, _=None):
if self.previous_step_state == self.State.SUCCESS:
self.confirm_button.disabled = False
if not (
self.workchain_settings.relax_type.value != "none"
or self.workchain_settings.bands_run.value
or self.workchain_settings.pdos_run.value
):
self.confirm_button.disabled = True
self.state = self.State.READY
self._submission_blocker_messages.value = """
<div class="alert alert-info">
The configured work chain would not actually compute anything.
Select either a structure relaxation method or at least one of the
the bands or the PDOS calculations or both.</div>"""
else:
self._submission_blocker_messages.value = ""
self.state = self.State.CONFIGURED
self._submission_blocker_messages.value = ""
self.state = self.State.CONFIGURED
elif self.previous_step_state == self.State.FAIL:
self.state = self.State.FAIL
else:
Expand Down Expand Up @@ -856,6 +844,10 @@ def update_builder(buildy, resources, npools):
builder.degauss_override = Float(parameters["degauss_override"])
if "smearing_override" in parameters:
builder.smearing_override = Str(parameters["smearing_override"])

# skip relax sub-worflow only when RelaxType is NONE and has property calculated.
if RelaxType(parameters["relax_type"]) is RelaxType.NONE and (parameters["run_bands"] or parameters["run_pdos"]):
builder.pop("relax")

if not parameters.pop("run_bands"):
builder.pop("bands")
Expand Down
44 changes: 21 additions & 23 deletions src/aiidalab_qe_workchain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,22 @@ def get_builder_from_protocol(
builder = cls.get_builder()
builder.structure = structure

if relax_type is not RelaxType.NONE:
relax_overrides = overrides.get("relax", {})
if pseudo_family is not None:
relax_overrides.setdefault("base", {})["pseudo_family"] = pseudo_family
relax_overrides = overrides.get("relax", {})
if pseudo_family is not None:
relax_overrides.setdefault("base", {})["pseudo_family"] = pseudo_family

relax = PwRelaxWorkChain.get_builder_from_protocol(
code=pw_code,
structure=structure,
protocol=protocol,
overrides=relax_overrides,
relax_type=relax_type,
**kwargs,
)
relax.pop("structure", None)
relax.pop("clean_workdir", None)
relax.pop("base_final_scf", None)
builder.relax = relax
else:
builder.pop("relax", None)
relax = PwRelaxWorkChain.get_builder_from_protocol(
code=pw_code,
structure=structure,
protocol=protocol,
overrides=relax_overrides,
relax_type=relax_type,
**kwargs,
)
relax.pop("structure", None)
relax.pop("clean_workdir", None)
relax.pop("base_final_scf", None)
builder.relax = relax

bands_overrides = overrides.get("bands", {})
if pseudo_family is not None:
Expand Down Expand Up @@ -236,11 +233,12 @@ def inspect_relax(self):
)
return self.exit_codes.ERROR_SUB_PROCESS_FAILED_RELAX

self.ctx.current_structure = workchain.outputs.output_structure
self.ctx.current_number_of_bands = (
workchain.outputs.output_parameters.get_attribute("number_of_bands")
)
self.out("structure", self.ctx.current_structure)
if "output_structure" in workchain.outputs:
self.ctx.current_structure = workchain.outputs.output_structure
self.ctx.current_number_of_bands = (
workchain.outputs.output_parameters.get_attribute("number_of_bands")
)
self.out("structure", self.ctx.current_structure)

def should_run_bands(self):
"""Check if the band structure should be calculated."""
Expand Down

0 comments on commit 96caa11

Please sign in to comment.