Skip to content

Commit

Permalink
Add imp_BdG test + small bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippRue committed Nov 28, 2024
1 parent d4f6640 commit 3b3652c
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 27 deletions.
6 changes: 3 additions & 3 deletions aiida_kkr/workflows/imp_BdG.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__copyright__ = (u'Copyright (c), 2022, Forschungszentrum Jülich GmbH, '
'IAS-1/PGI-1, Germany. All rights reserved.')
__license__ = 'MIT license, see LICENSE.txt file'
__version__ = '0.1.2'
__version__ = '0.1.3'
__contributors__ = (u'David Antognini Silva, Philipp Rüßmann')

# TODO: add _wf_default parameters and activate get_wf_defaults method
Expand Down Expand Up @@ -474,9 +474,9 @@ def results(self):
return the results nodes of the workchain
"""
if self.inputs.calc_DOS:
if 'dos_data' in self.ctx.DOS_node.outputs.dos_data:
if 'dos_data' in self.ctx.DOS_node.outputs:
self.out('dos_data', self.ctx.DOS_node.outputs.dos_data)
if 'dos_data_interpol' in self.ctx.DOS_node.outputs.dos_data_interpol:
if 'dos_data_interpol' in self.ctx.DOS_node.outputs:
self.out('dos_data_interpol', self.ctx.DOS_node.outputs.dos_data_interpol)
if 'dos_data_lm' in self.ctx.DOS_node.outputs:
self.out('dos_data_lm', self.ctx.DOS_node.outputs.dos_data_lm)
Expand Down
14 changes: 7 additions & 7 deletions aiida_kkr/workflows/kkr_imp_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,18 +737,18 @@ def parse_impdosfiles(folder, natom, nspin, ef, use_lmdos):
name0 = 'out_ldos'
if use_lmdos.value:
name0 = 'out_lmdos'
try:
fname = name0 + '.atom=%0.2i_spin%i.dat' % (iatom, ispin)
if fname in folder.list_object_names():
# old file names with 2 digits for atom index
with folder.open(name0 + '.atom=%0.2i_spin%i.dat' % (iatom, ispin)) as dosfile:
with folder.open(fname) as dosfile:

Check warning on line 743 in aiida_kkr/workflows/kkr_imp_dos.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/workflows/kkr_imp_dos.py#L743

Added line #L743 was not covered by tests
tmp = loadtxt(dosfile)
dos.append(tmp)

with folder.open(name0 + '.interpol.atom=%0.2i_spin%i.dat' % (iatom, ispin)) as dosfile:
tmp = loadtxt(dosfile)
if len(tmp) > 0:
dos_int.append(tmp)

except:
else:
# new file names with 3 digits for atom numbers
with folder.open(name0 + '.atom=%0.3i_spin%i.dat' % (iatom, ispin)) as dosfile:
tmp = loadtxt(dosfile)
Expand All @@ -758,7 +758,7 @@ def parse_impdosfiles(folder, natom, nspin, ef, use_lmdos):
try:
tmp = loadtxt(dosfile)
except:
pass
tmp = []

Check warning on line 761 in aiida_kkr/workflows/kkr_imp_dos.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/workflows/kkr_imp_dos.py#L761

Added line #L761 was not covered by tests
# can happen if there are too few points to interpolate on
if len(tmp) > 0:
dos_int.append(tmp)
Expand Down Expand Up @@ -806,7 +806,7 @@ def parse_impdosfiles(folder, natom, nspin, ef, use_lmdos):
dosnode.set_y(ylists[0], ylists[1], ylists[2])

# node for interpolated DOS
if len(dos_int) > 0:
try:
dosnode2 = XyData()
dosnode2.label = 'dos_interpol_data'
dosnode2.description = 'Array data containing iterpolated DOS (i.e. dos at finite imaginary part of energy). 3D array with (atoms, energy point, l-channel) dimensions.'
Expand All @@ -819,7 +819,7 @@ def parse_impdosfiles(folder, natom, nspin, ef, use_lmdos):
dosnode2.set_y(ylists[0], ylists[1], ylists[2])

output = {'dos_data': dosnode, 'dos_data_interpol': dosnode2}
else:
except:

Check warning on line 822 in aiida_kkr/workflows/kkr_imp_dos.py

View check run for this annotation

Codecov / codecov/patch

aiida_kkr/workflows/kkr_imp_dos.py#L822

Added line #L822 was not covered by tests
output = {'dos_data': dosnode}

return output
Binary file added tests/data_dir/imp_BdG_wc.aiida
Binary file not shown.
1 change: 1 addition & 0 deletions tests/jukkr_installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ else

# build kkrhost code
echo "build kkrhost"
git checkout BdG # use BdG branch to have code ready for imp-BdG workflow test
./install.py --program=kkrhost --compiler=gfortran --parallelization=serial
cd build/ && make -j4 && cp kkr.x ../
cd ..
Expand Down
18 changes: 1 addition & 17 deletions tests/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,8 @@ elif [[ ! -z "$GITHUB_SUITE" ]]; then
./workflows/test_kkrimp_full_wc.py \
./workflows/test_combine_imps.py \
./workflows/test_stm.py \
./workflows/test_kkrimp_BdG_wc.py \
$addopt
# full list, excludes:
# - currently tests for kkrimp_sub, jij and combine_imps are not working
# - tests for imp_BdG and STM are still missing
# pytest --cov-report=$repfmt --cov-append --cov=../ -x \
# ./workflows/test_vorostart_wc.py \
# ./workflows/test_scf_wc_simple.py \
# ./workflows/test_dos_wc.py \
# ./workflows/test_bs_wc.py \
# ./workflows/test_gf_writeout_wc.py \
# ./workflows/test_jij_wc.py \
# ./workflows/test_eos.py \
# ./workflows/test_decimate.py \
# ./workflows/test_kkrimp_sub_wc.py \
# ./workflows/test_kkrimp_dos_wc.py \
# ./workflows/test_kkrimp_full_wc.py \
# ./workflows/test_combine_imps.py \
# $addopt
else
# tests without running actual calculations
if [[ -z "$SKIP_NOWORK" ]] && [[ -z "$NO_RMQ" ]]; then
Expand Down
95 changes: 95 additions & 0 deletions tests/workflows/test_kkrimp_BdG_wc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python

import pytest
from ..dbsetup import *
from ..conftest import voronoi_local_code, kkrhost_local_code, kkrimp_local_code, data_dir, import_with_migration
from aiida.engine import run_get_node
from aiida import orm


@pytest.mark.timeout(900, method='thread')
def test_imp_BdG_wc(
clear_database_before_test, kkrimp_local_code, kkrhost_local_code, voronoi_local_code, enable_archive_cache,
ndarrays_regression
):
"""
simple Cu noSOC host-in-host, use imp_BdG workchain
"""
from aiida_kkr.workflows import kkrimp_BdG_wc

# import host calculation with SOC solver
o = import_with_migration(data_dir / 'jij_soc.aiida')
host_parent_calc = [i for i in orm.load_group(o).nodes if i.label == 'jij_calc_z'][0]

# set up process builder
builder = kkrimp_BdG_wc.get_builder()

# codes and computer options
builder.kkr = kkrhost_local_code
builder.kkrimp = kkrimp_local_code
builder.voronoi = voronoi_local_code

options = orm.Dict({
'queue_name': queuename,
'resources': {
'num_machines': 1
},
'max_wallclock_seconds': 12 * 60,
'withmpi': False,
'custom_scheduler_commands': 'ulimit -s unlimited'
})
builder.options = options

# impurity setup
imp_info = orm.Dict({'Rcut': 3.5, 'ilayer_center': 0, 'Zimp': [47.]})
builder.impurity_info = imp_info

# setting for impurity scf
builder.imp_scf.remote_data_host = host_parent_calc.outputs.remote_folder
builder.imp_scf.wf_parameters = orm.Dict({
'kkr_runmax': 1,
'nsteps': 1,
'retrieve_kkrflex': True,
'do_final_cleanup': False,
'accuracy_params':
{ # lower accuracy to have faster runtime
'RADIUS_LOGPANELS': 0.6,
'NPAN_LOG': 3,
'NPAN_EQ': 7,
'NCHEB': 6
},
})
builder.imp_scf.scf.params_overwrite = orm.Dict({'TOL_ALAT_CHECK': 1e-8})
builder.imp_scf.gf_writeout.params_kkr_overwrite = orm.Dict({'RUNOPT': []})

# activate BdG DOS step
builder.calc_DOS = orm.Bool(True)
builder.dos.wf_parameters = orm.Dict({
'retrieve_kkrflex': True,
'dos_params': {
'nepts': 3,
'tempr': 200.0,
'emin': -1.0,
'emax': 1.0,
'kmesh': [10, 10, 10]
},
'clean_impcalc_retrieved': False
})
# Activate BdG for DOS gf writeout step
builder.dos.gf_writeout.params_kkr_overwrite = orm.Dict({
'RUNOPT': [],
'<USE_BDG>': True,
'<DELTA_BDG>': 1e-2,
'NPAN_LOG': 3,
'NPAN_EQ': 7,
'NCHEB': 6,
})

# now run calculation
with enable_archive_cache(data_dir / 'imp_BdG_wc.aiida'):
out, node = run_get_node(builder)
print(node)
print(out)

check_dict = {'x': node.outputs.dos_data.get_x()[1][0], 'y': node.outputs.dos_data.get_y()[0][1]}
ndarrays_regression.check(check_dict)
Binary file not shown.

0 comments on commit 3b3652c

Please sign in to comment.