From 1934962ecb5311e17bf6dd7825ed29dac43939e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20R=C3=BC=C3=9Fmann?= <p.ruessmann@fz-juelich.de> Date: Mon, 25 Jul 2022 14:18:01 +0200 Subject: [PATCH] Fix running OPERATORS test --- source/KKRhost/tmat_newsolver.F90 | 48 +++++++++++++++++++--- tests/KKRhost/tools/test_verify_results.py | 14 +++---- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/source/KKRhost/tmat_newsolver.F90 b/source/KKRhost/tmat_newsolver.F90 index febfd4c06..b2f1c1bf2 100644 --- a/source/KKRhost/tmat_newsolver.F90 +++ b/source/KKRhost/tmat_newsolver.F90 @@ -633,10 +633,11 @@ contains !---------------------------------------------------------------------------- ! Calculate the left-hand side solution !---------------------------------------------------------------------------- - if ( t_dtmatjij_at%calculate .or. (t_wavefunctions%isave_wavefun(i1,ie)>0 .and. & - (t_wavefunctions%save_rllleft .or. t_wavefunctions%save_sllleft)) .or. & - ((write_rhoq_input .and. ie==2) .and. (i1==mu0)) .or. & ! rhoqtest - calc_exchange_couplings .or. write_pkkr_operators .or. calc_wronskian ) then ! MdSD: seems to make more sense to check here than below + if ( calculate_left(i1, ie) .or. & + t_dtmatjij_at%calculate .or. & + ((write_rhoq_input .and. ie==2) .and. (i1==mu0)) & ! rhoqtest + ) then ! MdSD: seems to make more sense to check here than below + ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Calculate the left-hand side solution this needs to be done for the ! calculation of t-matrices for Jij tensor or if wavefunctions should be saved @@ -983,7 +984,7 @@ contains sll = czero ! Left regular and irregular wavefunctions (used here only in case of XCPL or saving of left wavefunctions) - if (calc_exchange_couplings .or. (t_wavefunctions%save_rllleft .or. t_wavefunctions%save_sllleft .or. write_rhoq_input) .or. calc_wronskian) then + if (calculate_left(1,1)) then allocate (rllleft(nsra*lmmaxd,lmmaxd,irmdnew,0:nth-1), stat=i_stat) call memocc(i_stat, product(shape(rllleft))*kind(rllleft), 'RLLLEFT', 'allocate_locals_tmat_newsolver') rllleft = czero @@ -1065,7 +1066,7 @@ contains deallocate (sll, stat=i_stat) call memocc(i_stat, -product(shape(sll))*kind(sll), 'SLL', 'allocate_locals_tmat_newsolver') - if (calc_exchange_couplings .or. (t_wavefunctions%save_rllleft .or. t_wavefunctions%save_sllleft .or. write_rhoq_input)) then + if (calculate_left(1,1)) then deallocate (rllleft, stat=i_stat) call memocc(i_stat, -product(shape(rllleft))*kind(rllleft), 'RLLLEFT', 'allocate_locals_tmat_newsolver') deallocate (sllleft, stat=i_stat) @@ -1102,4 +1103,39 @@ contains end subroutine allocate_locals_tmat_newsolver + + !------------------------------------------------------------------------------- + !> Summary: Helper function which tells if the left wave functions are needed + !> calculation + !> Author: Philipp Ruessmann + !> Category: single-site, profiling, KKRhost + !> Deprecated: False + !> + !------------------------------------------------------------------------------- + logical function calculate_left(i1, ie) + + use :: mod_save_wavefun, only: t_wavefunctions + use :: mod_runoptions, only: calc_wronskian, write_pkkr_operators, calc_exchange_couplings, write_rhoq_input + use :: mod_types, only: type_dtmatjijdij + implicit None + integer, intent(in) :: i1, ie + + calculate_left = .false. + if ( calc_exchange_couplings & + .or. & + write_pkkr_operators & + .or. & + calc_wronskian & + ) then + calculate_left = .true. + end if + + if ( (t_wavefunctions%save_rllleft .or. t_wavefunctions%save_sllleft) ) then + if ( t_wavefunctions%isave_wavefun(i1,ie)>0 ) calculate_left = .true. + end if + + return + + end function calculate_left + end module mod_tmatnewsolver diff --git a/tests/KKRhost/tools/test_verify_results.py b/tests/KKRhost/tools/test_verify_results.py index 7c1edf73c..dd042764b 100644 --- a/tests/KKRhost/tools/test_verify_results.py +++ b/tests/KKRhost/tools/test_verify_results.py @@ -72,9 +72,9 @@ class Test_features(): fname = 'TBkkr_rhod.txt' num, text = read_file(path+fname) num_ref, text_ref = read_file(path0+fname) - assert std(abs(num-num_ref))<10**-14 - assert mean(abs(num-num_ref))<10**-14 - assert abs(num-num_ref).max()<5*10**-13 + assert std(abs(num-num_ref))<1e-14 + assert mean(abs(num-num_ref))<1e-14 + assert abs(num-num_ref).max()<1e-12 assert set(text)-set(text_ref)==set() # compare output of OPERATOR for host and for impurity wavefunctions for filename in 'TBkkr_rhod.txt TBkkr_torq.txt TBkkr_spinflux.txt'.split(): @@ -93,10 +93,10 @@ class Test_features(): # flatten arrays and take diff d1 = d1.reshape(-1); d2 = d2.reshape(-1); d01 = d01.reshape(-1); d02 = d02.reshape(-1) diff1 = d01-d1; diff2 = d02-d2 - assert mean(diff1) < 10**-15 - assert abs(diff1).max() < 10**-15 - assert mean(diff2) < 10**-15 - assert abs(diff2).max() < 10**-15 + assert mean(diff1) < 1e-14 + assert abs(diff1).max() < 1e-12 + assert mean(diff2) < 1e-14 + assert abs(diff2).max() < 1e-12 def test_11_DTM_GMAT(self): path = 'test_run11_mpi_1_8/' -- GitLab