Skip to content

Commit

Permalink
Add aiida-core==2.X support
Browse files Browse the repository at this point in the history
  • Loading branch information
mpougin committed Aug 27, 2023
1 parent 6bf08fa commit 4800ee8
Show file tree
Hide file tree
Showing 63 changed files with 302 additions and 205 deletions.
3 changes: 0 additions & 3 deletions .style.yapf

This file was deleted.

18 changes: 0 additions & 18 deletions .yamllint

This file was deleted.

2 changes: 1 addition & 1 deletion aiida_lsmo/calcfunctions/oxidation_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ def compute_oxidation_states(cif):
}

results_dict['oximachine_version'] = str(OXIMACHINE_RUNNER)
return Dict(dict=results_dict)
return Dict(results_dict)
2 changes: 1 addition & 1 deletion aiida_lsmo/calcfunctions/selectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def calc_selectivity(isot_dict_a, isot_dict_b):
out_dict['selectivity_dev'] = out_dict['selectivity_average'] * sqrt(
(isot_dict_a['henry_coefficient_dev'] / isot_dict_a['henry_coefficient_average']) +
(isot_dict_b['henry_coefficient_dev'] / isot_dict_b['henry_coefficient_average']))
return Dict(dict=out_dict)
return Dict(out_dict)
6 changes: 3 additions & 3 deletions aiida_lsmo/calcfunctions/working_cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def calc_ch4_working_cap(isot_dict):
'wc_65bar_fraction': wc_65bar_fract,
'wc_65bar_fraction_unit': '-',
})
return Dict(dict=out_dict)
return Dict(out_dict)


@calcfunction
Expand Down Expand Up @@ -112,7 +112,7 @@ def calc_h2_working_cap(isotmt_dict): # pylint: disable=too-many-locals
'case-{}_{}_dev'.format(case, unit): sqrt(load_dev**2 + disc_dev**2) * conv
})

return Dict(dict=out_dict)
return Dict(out_dict)


@calcfunction
Expand Down Expand Up @@ -161,4 +161,4 @@ def calc_o2_working_cap(isot_dict):
'wc_140bar_fraction': wc_140bar_fract,
'wc_140bar_fraction_unit': '-',
})
return Dict(dict=out_dict)
return Dict(out_dict)
4 changes: 2 additions & 2 deletions aiida_lsmo/calcfunctions/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def calc_co2_parasitic_energy(isot_co2, isot_n2, pe_parameters):
from calc_pe import mainPE

if not isot_co2['is_porous'] or not isot_n2['is_porous']:
return Dict(dict={'is_porous': False})
return Dict({'is_porous': False})

bar2pa = 1e5 # convert pressure from bar to Pa
gcm2kgm = 1000 # convert density from g/cm3 to kg/m3
Expand All @@ -53,4 +53,4 @@ def calc_co2_parasitic_energy(isot_co2, isot_n2, pe_parameters):
)
pe_dict['is_porous'] = True

return Dict(dict=pe_dict)
return Dict(pe_dict)
2 changes: 1 addition & 1 deletion aiida_lsmo/utils/multiply_unitcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def angle(vect1, vect2):
'ny': int(ceil(thr / perpwidth[1])),
'nz': int(ceil(thr / perpwidth[2]))
}
return Dict(dict=resize)
return Dict(resize)


@calcfunction
Expand Down
5 changes: 3 additions & 2 deletions aiida_lsmo/utils/other_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aiida.orm import Dict, CifData, StructureData
from aiida.engine import calcfunction

from collections.abc import Mapping

def dict_merge(dct, merge_dct):
""" Taken from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
Expand All @@ -19,7 +20,7 @@ def dict_merge(dct, merge_dct):
:return: None
"""
for k in merge_dct.keys():
if (k in dct and isinstance(dct[k], dict) and isinstance(merge_dct[k], collections.Mapping)):
if (k in dct and isinstance(dct[k], dict) and isinstance(merge_dct[k], Mapping)):
dict_merge(dct[k], merge_dct[k])
else:
dct[k] = merge_dct[k]
Expand All @@ -35,7 +36,7 @@ def aiida_dict_merge(to_dict, from_dict):

dict_merge(to_dict, from_dict)

return Dict(dict=to_dict)
return Dict(to_dict)


def ase_cells_are_similar(ase_a, ase_b, thr=2):
Expand Down
4 changes: 2 additions & 2 deletions aiida_lsmo/workchains/binding_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Cp2kBindingEnergyWorkChain = WorkflowFactory('lsmo.cp2k_binding_energy') # pylint: disable=invalid-name

# import aiida data
StructureData = DataFactory('structure') # pylint: disable=invalid-name
CifData = DataFactory('cif') # pylint: disable=invalid-name
StructureData = DataFactory('core.structure') # pylint: disable=invalid-name
CifData = DataFactory('core.cif') # pylint: disable=invalid-name


class BindingSiteWorkChain(WorkChain):
Expand Down
6 changes: 3 additions & 3 deletions aiida_lsmo/workchains/cp2k_binding_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_output_parameters(**cp2k_out_dict):
if key in cp2k_out_dict['bsse'].get_dict(): # "binding_energy_dispersion" may miss
output_dict[key] = cp2k_out_dict['bsse'][key]

return Dict(dict=output_dict)
return Dict(output_dict)


@calcfunction
Expand Down Expand Up @@ -185,7 +185,7 @@ def run_geo_opt(self):
if 'parameters' in self.exposed_inputs(Cp2kBaseWorkChain, 'cp2k_base')['cp2k']:
dict_merge(self.ctx.cp2k_param,
self.exposed_inputs(Cp2kBaseWorkChain, 'cp2k_base')['cp2k']['parameters'].get_dict())
self.ctx.base_inp['cp2k']['parameters'] = Dict(dict=self.ctx.cp2k_param)
self.ctx.base_inp['cp2k']['parameters'] = Dict(self.ctx.cp2k_param)
self.ctx.base_inp['metadata'].update({'label': 'geo_opt_molecule', 'call_link_label': 'run_geo_opt_molecule'})
self.ctx.base_inp['cp2k']['metadata'].update({'label': 'GEO_OPT'})
self.ctx.base_inp['cp2k']['metadata']['options']['parser_name'] = 'lsmo.cp2k_advanced_parser'
Expand Down Expand Up @@ -250,7 +250,7 @@ def run_bsse(self):
if 'parameters' in self.exposed_inputs(Cp2kBaseWorkChain, 'cp2k_base')['cp2k']:
dict_merge(self.ctx.cp2k_param,
self.exposed_inputs(Cp2kBaseWorkChain, 'cp2k_base')['cp2k']['parameters'].get_dict())
self.ctx.base_inp['cp2k']['parameters'] = Dict(dict=self.ctx.cp2k_param)
self.ctx.base_inp['cp2k']['parameters'] = Dict(self.ctx.cp2k_param)
self.ctx.base_inp['cp2k']['structure'] = self.ctx.stages[-1].outputs.output_structure
self.ctx.base_inp['metadata'].update({'label': 'bsse', 'call_link_label': 'run_bsse'})
self.ctx.base_inp['cp2k']['metadata'].update({'label': 'BSSE'})
Expand Down
4 changes: 2 additions & 2 deletions aiida_lsmo/workchains/cp2k_multistage.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def apply_initial_magnetization(structure, protocol, oxidation_states=None, with
cp2k_param = get_kinds_section(atoms=atoms, protocol=protocol_dict, with_ghost_atoms=bool(with_ghost_atoms))
dict_merge(cp2k_param, get_multiplicity_section(atoms=atoms, protocol=protocol_dict))

return {'structure': StructureData(ase=atoms), 'cp2k_param': Dict(dict=cp2k_param)}
return {'structure': StructureData(ase=atoms), 'cp2k_param': Dict(cp2k_param)}


@calcfunction
Expand Down Expand Up @@ -137,7 +137,7 @@ def extract_results(resize, **kwargs):
output_dict['final_bandgap_spin1_au'] = kwarg['bandgap_spin1_au']
output_dict['final_bandgap_spin2_au'] = kwarg['bandgap_spin2_au']

return Dict(dict=output_dict)
return Dict(output_dict)


class Cp2kMultistageWorkChain(WorkChain):
Expand Down
6 changes: 3 additions & 3 deletions aiida_lsmo/workchains/cp2k_multistage_ddec.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
DdecCalculation = CalculationFactory('ddec') # pylint: disable=invalid-name

# import aiida data
Dict = DataFactory('dict') # pylint: disable=invalid-name
CifData = DataFactory('cif') # pylint: disable=invalid-name
Dict = DataFactory('core.dict') # pylint: disable=invalid-name
CifData = DataFactory('core.cif') # pylint: disable=invalid-name


class Cp2kMultistageDdecWorkChain(WorkChain):
Expand Down Expand Up @@ -50,7 +50,7 @@ def run_cp2kddec(self):
cp2k_ddec_inputs = AttributeDict(self.exposed_inputs(Cp2kDdecWorkChain))
cp2k_ddec_inputs['cp2k_base'] = self.exposed_inputs(Cp2kMultistageWorkChain)['cp2k_base']
cp2k_params_modify = Dict(
dict={
{
'FORCE_EVAL': {
'DFT': {
'WFN_RESTART_FILE_NAME': './parent_calc/aiida-RESTART.wfn',
Expand Down
18 changes: 9 additions & 9 deletions aiida_lsmo/workchains/cp2k_phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
Cp2kBaseWorkChain = WorkflowFactory('cp2k.base') # pylint: disable=invalid-name

# import aiida data
Str = DataFactory('str') # pylint: disable=invalid-name
Int = DataFactory('int') # pylint: disable=invalid-name
List = DataFactory('list') # pylint: disable=invalid-name
Dict = DataFactory('dict') # pylint: disable=invalid-name
CifData = DataFactory('cif') # pylint: disable=invalid-name
StructureData = DataFactory('structure') # pylint: disable=invalid-name
SinglefileData = DataFactory('singlefile') # pylint: disable=invalid-name
Str = DataFactory('core.str') # pylint: disable=invalid-name
Int = DataFactory('core.int') # pylint: disable=invalid-name
List = DataFactory('core.list') # pylint: disable=invalid-name
Dict = DataFactory('core.dict') # pylint: disable=invalid-name
CifData = DataFactory('core.cif') # pylint: disable=invalid-name
StructureData = DataFactory('core.structure') # pylint: disable=invalid-name
SinglefileData = DataFactory('core.singlefile') # pylint: disable=invalid-name


class Cp2kPhonopyWorkChain(WorkChain):
Expand Down Expand Up @@ -92,7 +92,7 @@ def collect_cp2k_inputs(self):

# Collect the other inputs for Cp2kBaseWC from the ref_cp2k_calc to self.ctx.base_inp
self.ctx.base_inp = AttributeDict(self.exposed_inputs(Cp2kBaseWorkChain, 'cp2k_base'))
self.ctx.base_inp['cp2k']['settings'] = Dict(dict={'additional_retrieve_list': ['aiida-forces-1_0.xyz']})
self.ctx.base_inp['cp2k']['settings'] = Dict({'additional_retrieve_list': ['aiida-forces-1_0.xyz']})
self.ctx.base_inp['cp2k']['parent_calc_folder'] = ref_cp2k_calc.outputs.remote_folder
self.ctx.base_inp['cp2k']['file'] = {}
if 'file' in ref_cp2k_calc.inputs:
Expand Down Expand Up @@ -226,7 +226,7 @@ def results(self):
sets_of_forces.append(forces_parsed)

# Output the forces of the initial structure as a List
initial_forces = List(list=sets_of_forces[0])
initial_forces = List(sets_of_forces[0])
initial_forces.store()
self.out('initial_forces', initial_forces)
self.report(f'Forces computed on the input structure: List<{initial_forces.pk}>')
Expand Down
18 changes: 9 additions & 9 deletions aiida_lsmo/workchains/isotherm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FFBuilder = CalculationFactory('lsmo.ff_builder') # pylint: disable=invalid-name

# import aiida data
CifData = DataFactory('cif') # pylint: disable=invalid-name
CifData = DataFactory('core.cif') # pylint: disable=invalid-name
ZeoppParameters = DataFactory('zeopp.parameters') # pylint: disable=invalid-name


Expand All @@ -35,7 +35,7 @@ def get_molecule_dict(molecule_name):
yaml_dict = yaml.safe_load(stream)
ISOTHERM_MOLECULES_SCHEMA(yaml_dict)
molecule_dict = yaml_dict[molecule_name.value]
return Dict(dict=molecule_dict)
return Dict(molecule_dict)


@calcfunction
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_ff_parameters(molecule_dict, isotparam):
ff_params['tail_corrections'] = isotparam['ff_tail_corrections']
ff_params['mixing_rule'] = isotparam['ff_mixing_rule']
ff_params['separate_interactions'] = isotparam['ff_separate_interactions']
return Dict(dict=ff_params)
return Dict(ff_params)


@calcfunction
Expand All @@ -95,7 +95,7 @@ def choose_pressure_points(inp_param, geom, raspa_widom_out):
else:
pressure_points.append(inp_param['pressure_max'])
break
return List(list=pressure_points)
return List(pressure_points)


@calcfunction
Expand All @@ -107,7 +107,7 @@ def get_geometric_dict(zeopp_out, molecule):
'Estimated_saturation_loading_unit': 'mol/kg',
'is_porous': geometric_dict['POAV_A^3'] > 0.000
})
return Dict(dict=geometric_dict)
return Dict(geometric_dict)


@calcfunction
Expand Down Expand Up @@ -172,7 +172,7 @@ def get_output_parameters(geom_out, inp_params, widom_out=None, pressures=None,
'conversion_factor_molec_uc_to_mol_kg': gcmc_out_mol['conversion_factor_molec_uc_to_mol_kg'],
})

return Dict(dict=out_dict)
return Dict(out_dict)


class IsothermWorkChain(WorkChain):
Expand Down Expand Up @@ -283,7 +283,7 @@ def setup(self):
# Get the parameters Dict, merging defaults with user settings
@calcfunction
def get_valid_dict(dict_node):
return Dict(dict=self.parameters_schema(dict_node.get_dict()))
return Dict(self.parameters_schema(dict_node.get_dict()))

self.ctx.parameters = get_valid_dict(self.inputs.parameters)

Expand Down Expand Up @@ -416,7 +416,7 @@ def run_raspa_widom(self):
self.ctx.inp['raspa']['block_pocket'] = {'block_file': self.ctx.zeopp.outputs.block}

self.ctx.raspa_param = self._get_widom_param()
self.ctx.inp['raspa']['parameters'] = Dict(dict=self.ctx.raspa_param)
self.ctx.inp['raspa']['parameters'] = Dict(self.ctx.raspa_param)

# Generate the force field with the ff_builder
ff_params = get_ff_parameters(self.ctx.molecule, self.ctx.parameters)
Expand Down Expand Up @@ -502,7 +502,7 @@ def run_raspa_gcmc(self):
self.ctx.pressures[self.ctx.current_p_index] * 1e5

# Update parameters Dict
self.ctx.inp['raspa']['parameters'] = Dict(dict=self.ctx.raspa_param)
self.ctx.inp['raspa']['parameters'] = Dict(self.ctx.raspa_param)

# Update restart (if present, i.e., if current_p_index>0)
if self.ctx.current_p_index > 0:
Expand Down
16 changes: 8 additions & 8 deletions aiida_lsmo/workchains/isotherm_accurate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FFBuilder = CalculationFactory('lsmo.ff_builder') # pylint: disable=invalid-name

# import aiida data
CifData = DataFactory('cif') # pylint: disable=invalid-name
CifData = DataFactory('core.cif') # pylint: disable=invalid-name
ZeoppParameters = DataFactory('zeopp.parameters') # pylint: disable=invalid-name


Expand All @@ -35,7 +35,7 @@ def get_molecule_dict(molecule_name):
yaml_dict = yaml.safe_load(stream)
ISOTHERM_MOLECULES_SCHEMA(yaml_dict)
molecule_dict = yaml_dict[molecule_name.value]
return Dict(dict=molecule_dict)
return Dict(molecule_dict)


@calcfunction
Expand Down Expand Up @@ -71,7 +71,7 @@ def get_ff_parameters(molecule_dict, isotparam):
ff_params['tail_corrections'] = isotparam['ff_tail_corrections']
ff_params['mixing_rule'] = isotparam['ff_mixing_rule']
ff_params['separate_interactions'] = isotparam['ff_separate_interactions']
return Dict(dict=ff_params)
return Dict(ff_params)


@calcfunction
Expand All @@ -83,7 +83,7 @@ def get_geometric_dict(zeopp_out, molecule):
'Estimated_saturation_loading_unit': 'mol/kg',
'is_porous': geometric_dict['POAV_A^3'] > 0.000
})
return Dict(dict=geometric_dict)
return Dict(geometric_dict)


@calcfunction
Expand Down Expand Up @@ -153,7 +153,7 @@ def get_output_parameters(geom_out, inp_params, widom_out=None, **gcmc_out_dict)
'conversion_factor_molec_uc_to_mol_kg': gcmc_out_mol['conversion_factor_molec_uc_to_mol_kg'],
})

return Dict(dict=out_dict)
return Dict(out_dict)


class IsothermAccurateWorkChain(WorkChain):
Expand Down Expand Up @@ -266,7 +266,7 @@ def setup(self):
# Get the parameters Dict, merging defaults with user settings
@calcfunction
def get_valid_dict(dict_node):
return Dict(dict=self.parameters_schema(dict_node.get_dict()))
return Dict(self.parameters_schema(dict_node.get_dict()))

self.ctx.parameters = get_valid_dict(self.inputs.parameters)

Expand Down Expand Up @@ -405,7 +405,7 @@ def run_raspa_widom(self):
self.ctx.inp['raspa']['block_pocket'] = {'block_file': self.ctx.zeopp.outputs.block}

self.ctx.raspa_param = self._get_widom_param()
self.ctx.inp['raspa']['parameters'] = Dict(dict=self.ctx.raspa_param)
self.ctx.inp['raspa']['parameters'] = Dict(self.ctx.raspa_param)

# Generate the force field with the ff_builder
ff_params = get_ff_parameters(self.ctx.molecule, self.ctx.parameters)
Expand Down Expand Up @@ -557,7 +557,7 @@ def run_raspa_gcmc(self):
self.ctx.raspa_param['System']['framework_1']['ExternalPressure'] = self.ctx.pressure * 1e5

# Update parameters Dict
self.ctx.inp['raspa']['parameters'] = Dict(dict=self.ctx.raspa_param)
self.ctx.inp['raspa']['parameters'] = Dict(self.ctx.raspa_param)

# Update restart (if present, i.e., if current_p_index>0)
if 'raspa_gcmc' in self.ctx:
Expand Down
2 changes: 1 addition & 1 deletion aiida_lsmo/workchains/isotherm_calc_pe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
IsothermWorkChain = WorkflowFactory('lsmo.isotherm') #pylint: disable=invalid-name

# import aiida data
CifData = DataFactory('cif') #pylint: disable=invalid-name
CifData = DataFactory('core.cif') #pylint: disable=invalid-name


class IsothermCalcPEWorkChain(WorkChain):
Expand Down
Loading

0 comments on commit 4800ee8

Please sign in to comment.