Skip to content

Commit

Permalink
update kkrimp workflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippRue committed Nov 21, 2024
1 parent 5f44eb2 commit e5472d4
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 48 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added tests/data_dir/kkrimp_dos.aiida
Binary file not shown.
Binary file added tests/data_dir/kkrimp_full_wc.aiida
Binary file not shown.
Binary file added tests/data_dir/kkrimp_sub_wc.aiida
Binary file not shown.
32 changes: 6 additions & 26 deletions tests/workflows/test_kkrimp_dos_wc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
import pytest
from ..dbsetup import *
from ..conftest import voronoi_local_code, kkrhost_local_code, data_dir, import_with_migration
from aiida.manage.tests.pytest_fixtures import aiida_local_code_factory, aiida_localhost, temp_dir, aiida_profile
from aiida.manage.tests.pytest_fixtures import clear_database, clear_database_after_test, clear_database_before_test
from aiida.engine import run_get_node


@pytest.mark.timeout(300, method='thread')
def test_dos_startpot_wc(clear_database_before_test, kkrimp_local_code, kkrhost_local_code, run_with_cache):
def test_dos_startpot_wc(clear_database_before_test, kkrimp_local_code, kkrhost_local_code, enable_archive_cache):
"""
simple Cu noSOC, FP, lmax2 full example using scf workflow for impurity host-in-host
"""
from numpy import array, loadtxt
from masci_tools.io.kkr_params import kkrparams
from aiida.orm import Code, load_node, Dict, StructureData, load_group
from aiida.orm import Code, load_node, Dict, StructureData, load_group, WorkChainNode
from aiida.orm.querybuilder import QueryBuilder
from aiida.manage.caching import enable_caching
from aiida_kkr.tools import neworder_potential_wf
from aiida_kkr.workflows.kkr_imp_dos import kkr_imp_dos_wc
from aiida_kkr.calculations import KkrCalculation

# import precomputed GF host writeout
o = import_with_migration('data_dir/kkr_flex_wc-nodes-94b44d25a7af0e584343419207f3a7e1.tar.gz')
o = import_with_migration('data_dir/kkrflex_writeout_wc.aiida')
print('import', o)
# gf_workflow = load_node('0adfe62d-05aa-4c79-90ca-86b1753612a2')
gf_workflow = [i for i in load_group(o).nodes if i.label == 'GF_writeout Cu bulk'][0]
Expand Down Expand Up @@ -78,10 +77,10 @@ def test_dos_startpot_wc(clear_database_before_test, kkrimp_local_code, kkrhost_
builder.host_remote = GF_host_calc.outputs.remote_folder

# now run calculation
out, node = run_with_cache(builder, data_dir=data_dir)
with enable_archive_cache(data_dir / 'kkrimp_dos.aiida'):
out, node = run_get_node(builder)
print(node)
print(out)
from aiida.orm import WorkChainNode
for i in node.get_outgoing(node_class=WorkChainNode).all():
print(i.node, list(i.node.outputs))

Expand All @@ -95,27 +94,8 @@ def test_dos_startpot_wc(clear_database_before_test, kkrimp_local_code, kkrhost_
assert len(out['dos_data_interpol'].get_y()[0][0]) == 20


"""
@pytest.mark.timeout(300, method='thread')
def test_dos_reuse_gf_writeout(self):
pass
@pytest.mark.timeout(300, method='thread')
def test_dos_from_kkrimp_sub(self):
pass
@pytest.mark.timeout(300, method='thread')
def test_dos_from_kkrimp_full(self):
pass
"""

#run test manually
if __name__ == '__main__':
from aiida import load_profile
load_profile()
test_dos_startpot_wc()
#test_dos_reuse_gf_writeout()
#test_dos_from_kkrimp_sub()
#test_dos_from_kkrimp_full()
21 changes: 7 additions & 14 deletions tests/workflows/test_kkrimp_full_wc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import pytest
from ..dbsetup import *
if __name__ != '__main__':
from aiida_testing.export_cache._fixtures import run_with_cache, export_cache, load_cache, hash_code_by_entrypoint
from aiida.engine import run_get_node
from ..conftest import voronoi_local_code, kkrhost_local_code, test_dir, data_dir, import_with_migration
from aiida.manage.tests.pytest_fixtures import aiida_local_code_factory, aiida_localhost, temp_dir, aiida_profile
from aiida.manage.tests.pytest_fixtures import clear_database, clear_database_after_test, clear_database_before_test


@pytest.mark.timeout(900, method='thread')
def test_kkrimp_full_wc(
clear_database_before_test, voronoi_local_code, kkrhost_local_code, kkrimp_local_code, run_with_cache
clear_database_before_test, voronoi_local_code, kkrhost_local_code, kkrimp_local_code, enable_archive_cache
):
"""
simple Cu noSOC, FP, lmax2 full example using scf workflow for impurity host-in-host
Expand Down Expand Up @@ -71,16 +69,10 @@ def test_kkrimp_full_wc(
builder.scf.params_overwrite = Dict({'TOL_ALAT_CHECK': 1e-8})

# now run calculation
out, node = run_with_cache(builder, data_dir=data_dir)
with enable_archive_cache(data_dir / 'kkrimp_full_wc.aiida'):
out, node = run_get_node(builder)
print(out)
print(list(node.called))
# c = node.called[-1].called[-1]
# print(c, c.exit_status, c.exit_message)
# print(c.outputs.retrieved.list_object_names())
# for fname in ['out_kkrimp', 'config.cfg']:
# with c.outputs.retrieved.open(fname) as _f:
# txt = _f.readlines()
# print(fname, txt)

# check outcome
n = out['workflow_info']
Expand All @@ -101,7 +93,7 @@ def test_kkrimp_full_wc(

# @pytest.mark.timeout(900, method='thread')
# def test_kkrimp_full_Ag_Cu_onsite(
# clear_database_before_test, voronoi_local_code, kkrhost_local_code, kkrimp_local_code, run_with_cache
# clear_database_before_test, voronoi_local_code, kkrhost_local_code, kkrimp_local_code, enable_archive_cache
# ):
# """
# Simple Ag_Cu (bulk) noSOC, FP, lmax2 example where impurity cluster contains only the impurity atom
Expand Down Expand Up @@ -166,7 +158,8 @@ def test_kkrimp_full_wc(
# builder.scf.params_overwrite = Dict({'TOL_ALAT_CHECK': 1e-8})

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

# # check outcome
Expand Down
15 changes: 7 additions & 8 deletions tests/workflows/test_kkrimp_sub_wc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import pytest
from ..dbsetup import *
from ..conftest import kkrimp_local_code, data_dir, import_with_migration
from aiida_testing.export_cache._fixtures import run_with_cache, export_cache, load_cache, hash_code_by_entrypoint, with_export_cache
from aiida.manage.tests.pytest_fixtures import aiida_local_code_factory, aiida_localhost, temp_dir, aiida_profile
from aiida.manage.tests.pytest_fixtures import clear_database, clear_database_after_test, clear_database_before_test
from aiida.engine import run_get_node


@pytest.mark.timeout(1200, method='thread')
def test_kkrimp_sub_wc(clear_database_before_test, kkrimp_local_code, run_with_cache):
def test_kkrimp_sub_wc(clear_database_before_test, kkrimp_local_code, enable_archive_cache):
"""
simple Cu noSOC, FP, lmax2 full example using scf workflow for impurity host-in-host
"""
Expand All @@ -18,6 +16,9 @@ def test_kkrimp_sub_wc(clear_database_before_test, kkrimp_local_code, run_with_c
from masci_tools.io.kkr_params import kkrparams
from aiida_kkr.workflows.kkr_imp_sub import kkr_imp_sub_wc
from numpy import array
from aiida_kkr.tools import neworder_potential_wf
from numpy import loadtxt
from aiida.manage.caching import enable_caching

wfd = kkr_imp_sub_wc.get_wf_defaults()

Expand All @@ -42,13 +43,10 @@ def test_kkrimp_sub_wc(clear_database_before_test, kkrimp_local_code, run_with_c
GF_host_calc = load_node('baabef05-f418-4475-bba5-ef0ee3fd5ca6')

# now create a SingleFileData node containing the impurity starting potential
from aiida_kkr.tools import neworder_potential_wf
from numpy import loadtxt
with GF_host_calc.outputs.retrieved.open('scoef') as _f:
neworder_pot1 = [int(i) for i in loadtxt(_f, skiprows=1)[:, 3] - 1]
settings_dict = {'pot1': 'out_potential', 'out_pot': 'potential_imp', 'neworder': neworder_pot1}
settings = Dict(settings_dict)
from aiida.manage.caching import enable_caching
with enable_caching():
startpot_imp_sfd = neworder_potential_wf(
settings_node=settings, parent_calc_folder=GF_host_calc.outputs.remote_folder
Expand All @@ -70,7 +68,8 @@ def test_kkrimp_sub_wc(clear_database_before_test, kkrimp_local_code, run_with_c
print('builder', builder)

# now run calculation
out, node = run_with_cache(builder, data_dir=data_dir)
with enable_archive_cache(data_dir / 'kkrimp_sub_wc.aiida'):
out, node = run_get_node(builder)
print('out', out)
print('node', node)
print(node.process_status)
Expand Down

0 comments on commit e5472d4

Please sign in to comment.