Skip to content

Commit

Permalink
Allow setting the exchange field explicitely
Browse files Browse the repository at this point in the history
  • Loading branch information
janssenhenning committed May 5, 2022
1 parent 94aaed9 commit 39fd5e2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions aiida_fleur/workflows/hubbard1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class FleurHubbard1WorkChain(WorkChain):
'ldahia_dict': None,
'soc': 'auto',
'exchange_constants': None,
'exchange_field': None,
'cf_coefficients': None,
'occupation_converged': 0.01,
'matrix_elements_converged': 0.001,
Expand Down Expand Up @@ -118,6 +119,12 @@ def validate_inputs(self):
self.report(error)
return self.exit_codes.ERROR_INVALID_INPUT_CONFIG

if self.ctx.wf_dict['exchange_constants'] is not None and \
self.ctx.wf_dict['exchange_field'] is not None:
error = 'ERROR: you gave exchange_constants input + exchange_field in wf_parameters'
self.report(error)
return self.exit_codes.ERROR_INVALID_INPUT_CONFIG

def preliminary_calcs_needed(self):
"""
Return whether calculations need to be run before the hubbard 1 calculation
Expand Down Expand Up @@ -220,7 +227,8 @@ def create_hubbard1_input(self):
cf_coefficients = self.ctx.cfcoeff.outputs.output_cfcoeff_wc_para.dict.cf_coefficients_spin_up
if all('/' not in key for key in cf_coefficients):
self.report('WARNING: Crystal field coefficients from multiple atomtypes not supported fully')
_, cf_coefficients = cf_coefficients.popitem() #Just take one (To support multiple we need to split up species)
_, cf_coefficients = cf_coefficients.popitem(
) #Just take one (To support multiple we need to split up species)

#Drop coefficients with negative m
cf_coefficients = {key: coeff for key, coeff in cf_coefficients.items() if '-' not in key}
Expand All @@ -239,15 +247,22 @@ def create_hubbard1_input(self):
for l, exc_dict in exc_constant.items():
exc_constant_tags.append({'l': l, **exc_dict})

addarg_tags = []
if self.ctx.wf_dict['soc'] != 'auto':
addarg_tags.append({'key': 'xiSOC', 'value': self.ctx.wf_dict['soc']})

if self.ctx.wf_dict['exchange_field'] is not None:
addarg_tags.append({'key': 'Exc', 'value': self.ctx.wf_dict['exchange_field']})

for species_name, ldahia_dict in self.ctx.wf_dict['ldahia_dict'].items():
if coefficient_tags:
ldahia_dict = {**ldahia_dict, 'cfCoeff': coefficient_tags}

if exc_constant_tags:
ldahia_dict = {**ldahia_dict, 'exc': exc_constant_tags}

if self.ctx.wf_dict['soc'] != 'auto':
ldahia_dict = {**ldahia_dict, 'addarg': {'key': 'xiSOC', 'value': self.ctx.wf_dict['soc']}}
if addarg_tags:
ldahia_dict.setdefault('addarg', []).extend(addarg_tags)

scf_wf_para['inpxml_changes'].append(('set_species', {
'species_name': species_name,
Expand Down

0 comments on commit 39fd5e2

Please sign in to comment.