Skip to content

Commit

Permalink
Update VASP part to comply with ACWF study (#303)
Browse files Browse the repository at this point in the history
We add dedicated handler overrides and a dedicated protocol that was used for this study.
Also, a dedicated potential mapping has been created as the VASP developers was in the
process of updating a few potentials, in particular for the lanthanides.
Furthermore, we disable the present default to hard stop on CNORMN warnings for this study.
This goes in hand with the dedicated `v2.2.0` release of the AiiDA-VASP plugin, which is compatible
with `aiida_core<2`. This commit pins the AiiDA-VASP plugin to the `v2.2.0` version.
  • Loading branch information
espenfl authored Jul 7, 2023
1 parent 1aa93c4 commit a17cd87
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 37 deletions.
28 changes: 28 additions & 0 deletions aiida_common_workflows/workflows/relax/vasp/extractors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""
Collects some functions to postprocess a `VaspCommonRelaxWorkChain`.
"""


def get_ts_energy(common_relax_workchain):
"""
Extract and return the energy contribution from the entropy term TS value.
The fictitious temperature is T due to the presence of a smearing and S is the entropy.
"""
from aiida.common import LinkType
from aiida.orm import WorkChainNode
from aiida.plugins import WorkflowFactory

if not isinstance(common_relax_workchain, WorkChainNode):
return ValueError('The input is not a workchain (instance of `WorkChainNode`)')
if common_relax_workchain.process_class != WorkflowFactory('common_workflows.relax.vasp'):
return ValueError('The input workchain is not a `VaspCommonRelaxWorkChain`')

vasp_wc = common_relax_workchain.get_outgoing(link_type=LinkType.CALL_WORK).one().node
energies = vasp_wc.outputs.energies
energy_free = energies.get_array('energy_free_electronic')[0]
energy_no_entropy = energies.get_array('energy_no_entropy')[0]
energy_entropy_contrib = energy_no_entropy - energy_free

return energy_entropy_contrib
93 changes: 71 additions & 22 deletions aiida_common_workflows/workflows/relax/vasp/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ class VaspCommonRelaxInputGenerator(CommonRelaxInputGenerator):
"""Input generator for the `VaspCommonRelaxWorkChain`."""

_default_protocol = 'moderate'
_protocols = {
'fast': {
'description': 'Fast and not so accurate.'
},
'moderate': {
'description': 'Possibly a good compromise for quick checks.'
},
'precise': {
'description': 'Decent level of accuracy with some exceptions.'
},
'verification-PBE-v1': {
'description': 'Used for the ACWF study on unaries and oxides.'
}
}

def __init__(self, *args, **kwargs):
"""Construct an instance of the input generator, validating the class attributes."""
Expand All @@ -29,12 +43,12 @@ def __init__(self, *args, **kwargs):

def _initialize_protocols(self):
"""Initialize the protocols class attribute by parsing them from the protocols configuration file."""
with open(str(pathlib.Path(__file__).parent / 'protocol.yml')) as handle:
with open(str(pathlib.Path(__file__).parent / 'protocol.yml'), encoding='UTF-8') as handle:
self._protocols = yaml.safe_load(handle)

def _initialize_potential_mapping(self):
"""Initialize the potential mapping from the potential_mapping configuration file."""
with open(str(pathlib.Path(__file__).parent / 'potential_mapping.yml')) as handle:
with open(str(pathlib.Path(__file__).parent / 'potential_mapping.yml'), encoding='UTF-8') as handle:
self._potential_mapping = yaml.safe_load(handle)

@classmethod
Expand All @@ -48,6 +62,7 @@ def define(cls, spec):
spec.inputs['relax_type'].valid_type = ChoiceType(tuple(RelaxType))
spec.inputs['electronic_type'].valid_type = ChoiceType((ElectronicType.METAL, ElectronicType.INSULATOR))
spec.inputs['engines']['relax']['code'].valid_type = CodeType('vasp.vasp')
spec.inputs['protocol'].valid_type = ChoiceType(('fast', 'moderate', 'precise', 'verification-PBE-v1'))

def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
"""Construct a process builder based on the provided keyword arguments.
Expand Down Expand Up @@ -82,11 +97,53 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
# Set options
builder.options = plugins.DataFactory('dict')(dict=engines['relax']['options'])

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

# Fetch initial parameters from the protocol file.
# Here we set the protocols fast, moderate and precise. These currently have no formal meaning.
# After a while these will be set in the VASP workchain entrypoints using the convergence workchain etc.
# However, for now we rely on plane wave cutoffs and a set k-point density for the chosen protocol.
# Please consult the protocols.yml file for details.
parameters_dict = protocol['parameters']

# Set spin related parameters
if spin_type == SpinType.NONE:
parameters_dict['ispin'] = 1
elif spin_type == SpinType.COLLINEAR:
parameters_dict['ispin'] = 2

# Set the magnetization
if magnetization_per_site is not None:
parameters_dict['magmom'] = list(magnetization_per_site)

# Set settings
# Make sure the VASP parser is configured for the problem
settings = AttributeDict()
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,
Expand All @@ -99,30 +156,22 @@ def _construct_builder(self, **kwargs) -> engine.ProcessBuilder:
],
'link_name':
'misc'
}
},
'energy_type': ['energy_free', 'energy_no_entropy']
}
})
builder.settings = plugins.DataFactory('dict')(dict=settings)

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

# Fetch initial parameters from the protocol file.
# Here we set the protocols fast, moderate and precise. These currently have no formal meaning.
# After a while these will be set in the VASP workchain entrypoints using the convergence workchain etc.
# However, for now we rely on plane wave cutoffs and a set k-point density for the chosen protocol.
# Please consult the protocols.yml file for details.
parameters_dict = protocol['parameters']

# Set spin related parameters
if spin_type == SpinType.NONE:
parameters_dict['ispin'] = 1
elif spin_type == SpinType.COLLINEAR:
parameters_dict['ispin'] = 2

# Set the magnetization
if magnetization_per_site is not None:
parameters_dict['magmom'] = list(magnetization_per_site)
# Configure the handlers
handler_overrides = {
'handler_unfinished_calc_ionic_alt': True,
'handler_unfinished_calc_generic_alt': True,
'handler_electronic_conv_alt': True,
'handler_unfinished_calc_ionic': False,
'handler_unfinished_calc_generic': False,
'handler_electronic_conv': False
}
builder.handler_overrides = plugins.DataFactory('dict')(dict=handler_overrides)

# Set the parameters on the builder, put it in the code namespace to pass through
# to the code inputs
Expand Down
197 changes: 196 additions & 1 deletion aiida_common_workflows/workflows/relax/vasp/potential_mapping.yml
Original file line number Diff line number Diff line change
@@ -1 +1,196 @@
DEFAULT_PBE: {'Si': 'Si', 'Te': 'Te', 'Ge': 'Ge', 'Fe': 'Fe', 'H': 'H', 'Al': 'Al', 'N': 'N'}
RECOMMENDED_ACWF_LANTH: {
'H': 'H_GW',
'He': 'He_GW',
'Li': 'Li_sv_GW',
'Be': 'Be_sv_GW',
'B': 'B_GW',
'C': 'C_GW',
'N': 'N_GW',
'O': 'O_h_GW',
'F': 'F_GW',
'Ne': 'Ne_GW',
'Na': 'Na_sv_GW',
'Mg': 'Mg_sv_GW',
'Al': 'Al_GW',
'Si': 'Si_GW',
'P': 'P_GW',
'S': 'S_GW',
'Cl': 'Cl_GW',
'Ar': 'Ar_GW',
'K': 'K_sv_GW',
'Ca': 'Ca_sv_GW',
'Sc': 'Sc_sv_GW',
'Ti': 'Ti_sv_GW',
'V': 'V_sv_GW',
'Cr': 'Cr_sv_GW',
'Mn': 'Mn_sv_GW',
'Fe': 'Fe_sv_GW',
'Co': 'Co_sv_GW',
'Ni': 'Ni_sv_GW',
'Cu': 'Cu_sv_GW',
'Zn': 'Zn_sv_GW',
'Ga': 'Ga_d_GW',
'Ge': 'Ge_d_GW',
'As': 'As_GW',
'Se': 'Se_GW',
'Br': 'Br_GW',
'Kr': 'Kr_GW',
'Rb': 'Rb_sv_GW',
'Sr': 'Sr_sv_GW',
'Y': 'Y_sv_GW',
'Zr': 'Zr_sv_GW',
'Nb': 'Nb_sv_GW',
'Mo': 'Mo_sv_GW',
'Tc': 'Tc_sv_GW',
'Ru': 'Ru_sv_GW',
'Rh': 'Rh_sv_GW',
'Pd': 'Pd_sv_GW',
'Ag': 'Ag_sv_GW',
'Cd': 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