Skip to content

Commit

Permalink
Dependencies: update to aiida-pseudo==0.4.0
Browse files Browse the repository at this point in the history
This new minor version comes with some significant changes:

 * All format specific pseudopotential family subclasses have been
   removed, for example, `UpfFamily` no longer exists. The format of
   the pseudos in a family are now stored as an extra and can be
   retrieved through the `pseudo_type` property. The command line
   option param type `PseudoFamilyType` was updated to reflect these
   changes.

 * The recommended cutoffs for families are now always stored in
   electronvolt. They therefore have to be converted explicitly to
   Rydberg before they are passed to the calculations.
  • Loading branch information
sphuber committed Dec 9, 2020
1 parent 2c6d02f commit 5c9cd08
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 18 deletions.
6 changes: 4 additions & 2 deletions aiida_quantumespresso/cli/calculations/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def launch_calculation(code, structure, pseudo_family, max_num_machines, max_wal
"""Run a CpCalculation."""
from aiida.orm import Dict
from aiida.plugins import CalculationFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.utils.resources import get_default_options

cutoff_wfc, cutoff_rho = pseudo_family.get_recommended_cutoffs(structure=structure)
Expand All @@ -38,8 +40,8 @@ def launch_calculation(code, structure, pseudo_family, max_num_machines, max_wal
'nstep': 10,
},
'SYSTEM': {
'ecutwfc': cutoff_wfc,
'ecutrho': cutoff_rho,
'ecutwfc': cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': cutoff_rho / CONSTANTS.ry_to_ev,
'nr1b': 24,
'nr2b': 24,
'nr3b': 24,
Expand Down
6 changes: 4 additions & 2 deletions aiida_quantumespresso/cli/calculations/neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def launch_calculation(
"""
from aiida.orm import Dict
from aiida.plugins import CalculationFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.utils.resources import get_default_options

cutoff_wfc, cutoff_rho = pseudo_family.get_recommended_cutoffs(structure=structures[0])
Expand All @@ -68,8 +70,8 @@ def launch_calculation(
'calculation': 'relax',
},
'SYSTEM': {
'ecutwfc': ecutwfc or cutoff_wfc,
'ecutrho': ecutrho or cutoff_rho,
'ecutwfc': ecutwfc or cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': ecutrho or cutoff_rho / CONSTANTS.ry_to_ev,
}
}

Expand Down
6 changes: 4 additions & 2 deletions aiida_quantumespresso/cli/calculations/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def launch_calculation(
"""Run a PwCalculation."""
from aiida.orm import Dict, KpointsData
from aiida.plugins import CalculationFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.utils.resources import get_default_options

cutoff_wfc, cutoff_rho = pseudo_family.get_recommended_cutoffs(structure=structure)
Expand All @@ -67,8 +69,8 @@ def launch_calculation(
'calculation': mode,
},
'SYSTEM': {
'ecutwfc': ecutwfc or cutoff_wfc,
'ecutrho': ecutrho or cutoff_rho,
'ecutwfc': ecutwfc or cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': ecutrho or cutoff_rho / CONSTANTS.ry_to_ev,
}
}

Expand Down
16 changes: 14 additions & 2 deletions aiida_quantumespresso/cli/utils/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
class PseudoFamilyType(types.GroupParamType):
"""Subclass of `GroupParamType` in order to be able to print warning with instructions."""

def __init__(self, pseudo_types=None, **kwargs):
"""Construct a new instance."""
super().__init__(**kwargs)
self._pseudo_types = pseudo_types

@decorators.with_dbenv()
def convert(self, value, param, ctx):
"""Convert the value to actual pseudo family instance."""
Expand All @@ -28,16 +33,23 @@ def convert(self, value, param, ctx):
raise click.BadParameter( # pylint: disable=raise-missing-from
f'`{value}` is not of a supported pseudopotential family type.\nTo install a supported '
'pseudofamily, use the `aiida-pseudo` plugin. See the following link for detailed instructions:\n\n'
' https://github.com/aiidateam/aiida-quantumespresso#pseudo-potentials'
' https://github.com/aiidateam/aiida-quantumespresso#pseudopotentials'
)

if self._pseudo_types is not None and group.pseudo_type not in self._pseudo_types:
pseudo_types = ', '.join(self._pseudo_types)
raise click.BadParameter(
f'family `{group.label}` contains pseudopotentials of the wrong type `{group.pseudo_type}`.\nOnly the '
f'following types are supported: {pseudo_types}'
)

return group


PSEUDO_FAMILY = OverridableOption(
'-F',
'--pseudo-family',
type=PseudoFamilyType(sub_classes=('aiida.groups:pseudo.family.upf', 'aiida.groups:pseudo.family.sssp')),
type=PseudoFamilyType(sub_classes=('aiida.groups:pseudo.family',), pseudo_types=('pseudo.upf',)),
required=True,
help='Select a pseudopotential family.'
)
Expand Down
6 changes: 4 additions & 2 deletions aiida_quantumespresso/cli/workflows/pw/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def launch_workflow(
# pylint: disable=too-many-statements
from aiida.orm import Bool, Float, Dict
from aiida.plugins import WorkflowFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.utils.resources import get_default_options, get_automatic_parallelization_options

builder = WorkflowFactory('quantumespresso.pw.bands').get_builder()
Expand All @@ -48,8 +50,8 @@ def launch_workflow(

parameters = {
'SYSTEM': {
'ecutwfc': ecutwfc or cutoff_wfc,
'ecutrho': ecutrho or cutoff_rho,
'ecutwfc': ecutwfc or cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': ecutrho or cutoff_rho / CONSTANTS.ry_to_ev,
},
}

Expand Down
6 changes: 4 additions & 2 deletions aiida_quantumespresso/cli/workflows/pw/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def launch_workflow(
"""Run a `PwBaseWorkChain`."""
from aiida.orm import Bool, Float, Dict
from aiida.plugins import WorkflowFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.utils.resources import get_default_options, get_automatic_parallelization_options

builder = WorkflowFactory('quantumespresso.pw.base').get_builder()
Expand All @@ -48,8 +50,8 @@ def launch_workflow(

parameters = {
'SYSTEM': {
'ecutwfc': ecutwfc or cutoff_wfc,
'ecutrho': ecutrho or cutoff_rho,
'ecutwfc': ecutwfc or cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': ecutrho or cutoff_rho / CONSTANTS.ry_to_ev,
},
}

Expand Down
5 changes: 3 additions & 2 deletions aiida_quantumespresso/cli/workflows/pw/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def launch_workflow(
"""Run a `PwRelaxWorkChain`."""
from aiida.orm import Bool, Float, Dict, Str
from aiida.plugins import WorkflowFactory
from qe_tools import CONSTANTS

from aiida_quantumespresso.common.types import RelaxType
from aiida_quantumespresso.utils.resources import get_default_options, get_automatic_parallelization_options
Expand All @@ -57,8 +58,8 @@ def launch_workflow(

parameters = {
'SYSTEM': {
'ecutwfc': ecutwfc or cutoff_wfc,
'ecutrho': ecutrho or cutoff_rho,
'ecutwfc': ecutwfc or cutoff_wfc / CONSTANTS.ry_to_ev,
'ecutrho': ecutrho or cutoff_rho / CONSTANTS.ry_to_ev,
},
}

Expand Down
4 changes: 2 additions & 2 deletions setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
]
},
"install_requires": [
"aiida_core[atomic_tools]~=1.4,>=1.4.2",
"aiida-pseudo~=0.3",
"aiida_core[atomic_tools]~=1.4,>=1.4.4",
"aiida-pseudo~=0.4",
"packaging",
"qe-tools~=2.0rc1",
"xmlschema~=1.2,>=1.2.5",
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def _generate_upf_family(label='family', elements=('Si',)):
:param elements: optional list of elements to include instead of all the available ones
:return: the pseudo family
"""
from aiida_pseudo.groups.family import UpfFamily
from aiida_pseudo.groups.family import SsspFamily

cutoffs = {}

Expand All @@ -272,7 +272,7 @@ def _generate_upf_family(label='family', elements=('Si',)):
handle.write(source.read())
cutoffs[element] = {'cutoff_wfc': 1.0, 'cutoff_rho': 2.0}

family = UpfFamily.create_from_folder(str(tmp_path), label)
family = SsspFamily.create_from_folder(str(tmp_path), label)
family.set_cutoffs({'standard': cutoffs})

return family
Expand Down

0 comments on commit 5c9cd08

Please sign in to comment.