Skip to content

Commit

Permalink
Support testing convergence on diffirent configuration (#196)
Browse files Browse the repository at this point in the history
- also include run precision verification on Oxygen for oxides configurations.
  • Loading branch information
unkcpz authored May 20, 2023
1 parent edfef32 commit 2cdef21
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
4 changes: 3 additions & 1 deletion aiida_sssp_workflow/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def launch(

computer = pw_code.computer.label
label, _ = os.path.splitext(basename)
label = orm.Str(f"({protocol}-{criteria}-{cutoff_control} at {computer}) {label}")
label = orm.Str(
f"({protocol}-{criteria}-{cutoff_control} at {computer} - {configuration}) {label}"
)

with open(pseudo, "rb") as stream:
pseudo = UpfData(stream)
Expand Down
16 changes: 9 additions & 7 deletions aiida_sssp_workflow/workflows/convergence/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def init_setup(self):
self.ctx.structure = get_standard_structure(self.ctx.element, prop='convergence', configuration=configuration)

# For configuration that contains O, which is the configuration from ACWF set, we need to add O pseudo
if "O" in self.ctx.structure.get_kind_names():
if "O" in self.ctx.structure.get_kind_names() and self.ctx.element != "O":
self.ctx.pseudos["O"] = get_pseudo_O()

def is_magnetic_element(self):
Expand All @@ -251,12 +251,14 @@ def extra_setup_for_magnetic_element(self):
Extra setup for magnetic element, set starting magnetization
and reset pseudos to correspont elements name.
"""
self.ctx.structure, magnetic_extra_parameters = get_magnetic_inputs(self.ctx.structure)
self.ctx.extra_pw_parameters = update_dict(self.ctx.extra_pw_parameters, magnetic_extra_parameters)

# override pseudos setting
# required for O, Mn, Cr where the kind names varies for sites
self.ctx.pseudos = reset_pseudos_for_magnetic(self.inputs.pseudo, self.ctx.structure)
# ! only for typical configuration we set the starting magnetization and reset pseudos
if "configuration" in self.inputs and self.inputs.configuration.value == 'TYPICAL':
self.ctx.structure, magnetic_extra_parameters = get_magnetic_inputs(self.ctx.structure)
self.ctx.extra_pw_parameters = update_dict(self.ctx.extra_pw_parameters, magnetic_extra_parameters)

# override pseudos setting
# required for O, Mn, Cr where the kind names varies for sites
self.ctx.pseudos = reset_pseudos_for_magnetic(self.inputs.pseudo, self.ctx.structure)

def is_rare_earth_element(self):
"""Check if the element is rare earth"""
Expand Down
46 changes: 25 additions & 21 deletions aiida_sssp_workflow/workflows/convergence/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,33 @@ def setup_code_parameters_from_protocol(self):
self.ctx.scale_count = self._SCALE_COUNT = protocol["scale_count"]
self.ctx.scale_increment = self._SCALE_INCREMENT = protocol["scale_increment"]

# configuration for delta convergence read from mapping.json of static
# Instead of hard code the configuration, the configuration is read from mapping.json
import_path = importlib.resources.path(
"aiida_sssp_workflow.statics.structures", f"mapping.json"
)
with import_path as path, open(path, "r") as handle:
mapping = json.load(handle)

dir, fn = mapping[self.ctx.element]["convergence"].split("/")

if str.upper(dir) == "TYPICAL":
self.report(f"Use typical configuration for {self.ctx.element}")
element = fn.split(".")[0]
assert element == self.ctx.element
self.ctx.configuration = "TYPICAL"
# Please check README for what and why we use configuration set 'convergence'
# for convergence verification.
if "configuration" in self.inputs:
self.ctx.configuration = self.inputs.configuration.value
else:
# the convergence configuration is read from ACWF set
element, configuration = fn.replace("-", ".").split(".")[:-1]
self.report(
f"Use ACWF configuration {configuration} for {self.ctx.element}"
# configuration for delta convergence read from mapping.json as default
import_path = importlib.resources.path(
"aiida_sssp_workflow.statics.structures", f"mapping.json"
)
assert element == self.ctx.element
self.ctx.configuration = configuration
with import_path as path, open(path, "r") as handle:
mapping = json.load(handle)

dir, fn = mapping[self.ctx.element]["convergence"].split("/")

if str.upper(dir) == "TYPICAL":
self.report(f"Use typical configuration for {self.ctx.element}")
element = fn.split(".")[0]
assert element == self.ctx.element
self.ctx.configuration = "TYPICAL"
else:
# the convergence configuration is read from ACWF set
element, configuration = fn.replace("-", ".").split(".")[:-1]
self.report(
f"Use ACWF configuration {configuration} for {self.ctx.element}"
)
assert element == self.ctx.element
self.ctx.configuration = configuration

# Set context parameters
self.ctx.kpoints_distance = self._KDISTANCE
Expand Down
8 changes: 6 additions & 2 deletions aiida_sssp_workflow/workflows/measure/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ def init_setup(self):
# keys here are: BCC, FCC, SC, Diamond, XO, XO2, XO3, X2O, X2O3, X2O5, RE
# parentatheses means not supported yet.
if self.ctx.element == "O":
# For oxygen, only unaries are available.
self.ctx.configuration_list = self._UNARIE_CONFIGURATIONS
# For oxygen, still run for oxides but use only the tested pseudo.
self.ctx.pseudos_oxide = {
element: self.inputs.pseudo,
}
elif self.ctx.element in NO_TYPICAL_CONF_ELEMENTS:
# Don't have typical structure for At, Fr, Ra
self.ctx.configuration_list = (
Expand Down Expand Up @@ -143,6 +145,8 @@ def extra_setup_for_magnetic_element(self):
"""
Extra setup for magnetic element, set starting magnetization
and reset pseudos to correspont elements name.
! only for TYPEICAL structure.
"""
(
self.ctx.structures["TYPICAL"],
Expand Down

0 comments on commit 2cdef21

Please sign in to comment.