Skip to content

Commit

Permalink
Customize oxygen pseudo supported (#234)
Browse files Browse the repository at this point in the history
This change allow to pass oxygen pseudopotenital, if not provide, the
default oxygen pseudopotentieal will be used.
  • Loading branch information
unkcpz committed Nov 30, 2023
1 parent 61f1377 commit acf8336
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
34 changes: 34 additions & 0 deletions aiida_sssp_workflow/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -115,6 +133,9 @@ def launch(
walltime,
num_mpiprocs,
pseudo,
oxygen_pseudo,
oxygen_ecutwfc,
oxygen_ecutrho,
clean_workdir,
daemon,
comment,
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions aiida_sssp_workflow/workflows/measure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion aiida_sssp_workflow/workflows/measure/precision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit acf8336

Please sign in to comment.