diff --git a/aiida_sssp_workflow/cli/run.py b/aiida_sssp_workflow/cli/run.py index 4b436261..49a510aa 100644 --- a/aiida_sssp_workflow/cli/run.py +++ b/aiida_sssp_workflow/cli/run.py @@ -32,6 +32,24 @@ @options.OverridableOption( "--pw-code", "pw_code", type=types.CodeParamType(entry_point="quantumespresso.pw") )(required=True) +@click.option( + "--oxygen-pseudo", + "oxygen_pseudo", + type=click.Path(exists=True), + help="Oxygen pseudo to use for oxides precision measure workflow.", +) +@click.option( + "--oxygen-ecutwfc", + "oxygen_ecutwfc", + type=click.FLOAT, + help="Oxygen ecutwfc to use for oxides precision measure workflow.", +) +@click.option( + "--oxygen-ecutrho", + "oxygen_ecutrho", + type=click.FLOAT, + help="Oxygen ecutrho to use for oxides precision measure workflow.", +) @options.OverridableOption( "--pw-code-large-memory", "pw_code_large_memory", @@ -115,6 +133,9 @@ def launch( walltime, num_mpiprocs, pseudo, + oxygen_pseudo, + oxygen_ecutwfc, + oxygen_ecutrho, clean_workdir, daemon, comment, @@ -240,6 +261,19 @@ def launch( if pw_code_large_memory: inputs["pw_code_large_memory"] = pw_code_large_memory + if oxygen_pseudo: + if not (oxygen_ecutwfc and oxygen_ecutrho): + echo.echo_critical( + "oxygen_ecutwfc and oxygen_ecutrho must be provided if using custmized oxygen pseudo." + ) + + with open(oxygen_pseudo, "rb") as stream: + oxygen_pseudo = UpfData(stream) + + inputs["measure"]["oxygen_pseudo"] = oxygen_pseudo + inputs["measure"]["oxygen_ecutwfc"] = orm.Float(oxygen_ecutwfc) + inputs["measure"]["oxygen_ecutrho"] = orm.Float(oxygen_ecutrho) + if len(configuration) == 0: pass elif len(configuration) == 1: diff --git a/aiida_sssp_workflow/workflows/measure/__init__.py b/aiida_sssp_workflow/workflows/measure/__init__.py index 19a67b4b..95063d7d 100644 --- a/aiida_sssp_workflow/workflows/measure/__init__.py +++ b/aiida_sssp_workflow/workflows/measure/__init__.py @@ -32,6 +32,9 @@ def define(cls, spec): help='The `pw.x` code use for the `PwCalculation`.') spec.input('pseudo', valid_type=UpfData, required=True, help='Pseudopotential to be verified') + spec.input('oxygen_pseudo', valid_type=UpfData, required=False) + spec.input('oxygen_ecutwfc', valid_type=orm.Float, required=False) + spec.input('oxygen_ecutrho', valid_type=orm.Float, required=False) spec.input('protocol', valid_type=orm.Str, required=True, help='The protocol which define input calculation parameters.') spec.input('wavefunction_cutoff', valid_type=orm.Float, required=True, help='The wavefunction cutoff.') @@ -48,10 +51,17 @@ def _get_pw_cutoff( """Get cutoff pair, if strcture contains oxygen or nitrogen, need to use the max between pseudo cutoff and the O/N cutoff. """ + if "oxygen_pseudo" in self.inputs: + o_ecutwfc = self.inputs.oxygen_ecutwfc.value + o_ecutrho = self.inputs.oxygen_ecutrho.value + else: + o_ecutwfc = self._O_ECUTWFC + o_ecutrho = self._O_ECUTRHO + elements = set(structure.get_symbols_set()) if "O" in elements: - ecutwfc = max(ecutwfc, self._O_ECUTWFC) - ecutrho = max(ecutrho, self._O_ECUTRHO) + ecutwfc = max(ecutwfc, o_ecutwfc) + ecutrho = max(ecutrho, o_ecutrho) if "N" in elements: ecutwfc = max(ecutwfc, self._N_ECUTWFC) diff --git a/aiida_sssp_workflow/workflows/measure/precision.py b/aiida_sssp_workflow/workflows/measure/precision.py index 160255ee..f2b391b2 100644 --- a/aiida_sssp_workflow/workflows/measure/precision.py +++ b/aiida_sssp_workflow/workflows/measure/precision.py @@ -83,7 +83,10 @@ def _setup_pseudo_and_configuration(self): # for the oxide, need to pseudo of oxygen, # the pseudo is the one select after the oxygen verification and # store in the `statics/upf/O.**.upf` - pseudo_O = get_pseudo_O() + if "oxygen_pseudo" in self.inputs: + pseudo_O = self.inputs.oxygen_pseudo + else: + pseudo_O = get_pseudo_O() self.ctx.pseudos_oxide = { self.ctx.element: self.inputs.pseudo, "O": pseudo_O,