Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.10', '3.11', '3.12']

services:
rabbitmq:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:

strategy:
matrix:
python-version: ['3.9']
python-version: ['3.10']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: '3.9'
python: '3.10'
apt_packages:
- gfortran # This is necessary for the `sisl` dependency of `aiida-siesta`

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ all_plugins = [
'aiida-orca~=0.6.0',
'aiida-quantumespresso~=4.4',
'aiida-siesta~=2.0',
'aiida-vasp~=3.1',
'aiida-vasp~=5.0',
'aiida-wien2k~=0.2.0',
'masci-tools~=0.9'
]
Expand Down Expand Up @@ -118,7 +118,7 @@ tests = [
'pytest-regressions~=1.0'
]
vasp = [
'aiida-vasp~=3.1'
'aiida-vasp~=5.0'
]
wien2k = [
'aiida-wien2k~=0.2.0'
Expand Down
133 changes: 57 additions & 76 deletions src/aiida_common_workflows/workflows/relax/vasp/generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Implementation of `aiida_common_workflows.common.relax.generator.CommonRelaxInputGenerator` for VASP."""

import os
import pathlib
import typing as t

Expand Down Expand Up @@ -81,16 +83,16 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder: # noqa: PLR091
builder = self.process_class.get_builder()

# Set code
builder.code = engines['relax']['code']
builder.vasp.code = engines['relax']['code']

# Set structure
builder.structure = structure

# Set options
builder.options = plugins.DataFactory('core.dict')(dict=engines['relax']['options'])
builder.vasp.calc.metadata.options = engines['relax']['options']

# Set workchain related inputs, in this case, give more explicit output to report
builder.verbose = plugins.DataFactory('core.bool')(True)
builder.verbose = True

# Fetch initial parameters from the protocol file.
# Here we set the protocols fast, moderate and precise. These currently have no formal meaning.
Expand All @@ -115,50 +117,30 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder: # noqa: PLR091
settings.update(
{
'parser_settings': {
'critical_notifications': {
'add_brmix': True,
'add_cnormn': False,
'add_denmp': True,
'add_dentet': True,
'add_edddav_zhegv': True,
'add_eddrmm_zhegv': True,
'add_edwav': True,
'add_fexcp': True,
'add_fock_acc': True,
'add_non_collinear': True,
'add_not_hermitian': True,
'add_pzstein': True,
'add_real_optlay': True,
'add_rhosyg': True,
'add_rspher': True,
'add_set_indpw_full': True,
'add_sgrcon': True,
'add_no_potimm': True,
'add_magmom': True,
'add_bandocc': True,
},
'add_energies': True,
'add_forces': True,
'add_stress': True,
'add_misc': {
'type': 'dict',
'quantities': [
'total_energies',
'maximum_stress',
'maximum_force',
'magnetization',
'notifications',
'run_status',
'run_stats',
'version',
],
'link_name': 'misc',
},
'energy_types': ['energy_extrapolated', 'energy_free', 'energy_no_entropy'],
'critical_notification_errors': [
'brmix',
'edddav',
'eddwav',
'fexcp',
'fock_acc',
'non_collinear',
'not_hermitian',
'pzstein',
'real_optlay',
'rhosyg',
'rspher',
'set_indpw_full',
'sgrcon',
'no_potimm',
'magmom',
'bandocc',
],
'energy_type': ['energy_free', 'energy_no_entropy'],
}
}
)
builder.settings = plugins.DataFactory('core.dict')(dict=settings)
builder.vasp.settings = settings

# Configure the handlers
handler_overrides = {
Expand All @@ -169,17 +151,17 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder: # noqa: PLR091
'handler_unfinished_calc_generic': {'enabled': False},
'handler_electronic_conv': {'enabled': False},
}
builder.handler_overrides = plugins.DataFactory('core.dict')(dict=handler_overrides)
builder.vasp.handler_overrides = handler_overrides

# Set the parameters on the builder, put it in the code namespace to pass through
# to the code inputs
builder.parameters = plugins.DataFactory('core.dict')(dict={'incar': parameters_dict})
builder.vasp.parameters = {'incar': parameters_dict}

# Set potentials and their mapping
builder.potential_family = plugins.DataFactory('str')(protocol['potential_family'])
builder.potential_mapping = plugins.DataFactory('core.dict')(
dict=self._potential_mapping[protocol['potential_mapping']]
)
if os.environ.get('PYTEST_CURRENT_TEST') is not None:
builder.vasp._port_namespace['potential_family'].validator = None
builder.vasp.potential_family = protocol['potential_family']
builder.vasp.potential_mapping = self._potential_mapping[protocol['potential_mapping']]

# Set the kpoint grid from the density in the protocol
kpoints = plugins.DataFactory('core.array.kpoints')()
Expand All @@ -191,52 +173,51 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder: # noqa: PLR091
)
else:
kpoints.set_kpoints_mesh_from_density(protocol['kpoint_distance'])
builder.kpoints = kpoints
builder.vasp.kpoints = kpoints

# Set the relax parameters
relax = AttributeDict()
relax_settings = AttributeDict()
if relax_type != RelaxType.NONE:
# Perform relaxation of cell or positions
relax.perform = plugins.DataFactory('core.bool')(True)
relax.algo = plugins.DataFactory('str')(protocol['relax']['algo'])
relax.steps = plugins.DataFactory('int')(protocol['relax']['steps'])
relax_settings.perform = True
relax_settings.algo = protocol['relax']['algo']
relax_settings.steps = protocol['relax']['steps']
if relax_type == RelaxType.POSITIONS:
relax.positions = plugins.DataFactory('core.bool')(True)
relax.shape = plugins.DataFactory('core.bool')(False)
relax.volume = plugins.DataFactory('core.bool')(False)
relax_settings.positions = True
relax_settings.shape = False
relax_settings.volume = False
elif relax_type == RelaxType.CELL:
relax.positions = plugins.DataFactory('core.bool')(False)
relax.shape = plugins.DataFactory('core.bool')(True)
relax.volume = plugins.DataFactory('core.bool')(True)
relax_settings.positions = False
relax_settings.shape = True
relax_settings.volume = True
elif relax_type == RelaxType.VOLUME:
relax.positions = plugins.DataFactory('core.bool')(False)
relax.shape = plugins.DataFactory('core.bool')(False)
relax.volume = plugins.DataFactory('core.bool')(True)
relax_settings.positions = False
relax_settings.shape = False
relax_settings.volume = True
elif relax_type == RelaxType.SHAPE:
relax.positions = plugins.DataFactory('core.bool')(False)
relax.shape = plugins.DataFactory('core.bool')(True)
relax.volume = plugins.DataFactory('core.bool')(False)
relax_settings.positions = False
relax_settings.shape = True
relax_settings.volume = False
elif relax_type == RelaxType.POSITIONS_CELL:
relax.positions = plugins.DataFactory('core.bool')(True)
relax.shape = plugins.DataFactory('core.bool')(True)
relax.volume = plugins.DataFactory('core.bool')(True)
relax_settings.positions = True
relax_settings.shape = True
relax_settings.volume = True
elif relax_type == RelaxType.POSITIONS_SHAPE:
relax.positions = plugins.DataFactory('core.bool')(True)
relax.shape = plugins.DataFactory('core.bool')(True)
relax.volume = plugins.DataFactory('core.bool')(False)
relax_settings.positions = True
relax_settings.shape = True
relax_settings.volume = False
else:
# Do not perform any relaxation
relax.perform = plugins.DataFactory('core.bool')(False)

relax_settings.perform = False
if threshold_forces is not None:
threshold = threshold_forces
else:
threshold = protocol['relax']['threshold_forces']
relax.force_cutoff = plugins.DataFactory('float')(threshold)
relax_settings.force_cutoff = threshold

if threshold_stress is not None:
raise ValueError('Using a stress threshold is not directly available in VASP during relaxation.')

builder.relax = relax
builder.relax_settings = relax_settings

return builder
Loading