From bac477cf39c485de513ef6bd7121314ffe3de24e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 14 Jan 2021 23:28:37 +0100 Subject: [PATCH] Added debug_cfg --- src/bitmask/bitmasks_routines.irp.f | 54 +++++++++++++++++++++++ src/determinants/create_excitations.irp.f | 3 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/bitmask/bitmasks_routines.irp.f b/src/bitmask/bitmasks_routines.irp.f index 5c4bf347..c34d54dc 100644 --- a/src/bitmask/bitmasks_routines.irp.f +++ b/src/bitmask/bitmasks_routines.irp.f @@ -125,6 +125,41 @@ subroutine bitstring_to_str( output, string, Nint ) output(ibuf:ibuf) = '|' end +subroutine configuration_to_str( output, string, Nint ) + use bitmasks + implicit none + BEGIN_DOC +! Transform the bit string of a configuration to a string for printing + END_DOC + character*(*), intent(out) :: output + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: string(Nint,2) + + integer :: i, j, ibuf + integer(bit_kind) :: itemp + + ibuf = 1 + output = '' + output(ibuf:ibuf) = '|' + ibuf = ibuf+1 + do i=1,Nint + itemp = 1_bit_kind + do j=1,bit_kind_size + if (iand(itemp,string(i,2)) == itemp) then + output(ibuf:ibuf) = '2' + else if (iand(itemp,string(i,1)) == itemp) then + output(ibuf:ibuf) = '1' + else + output(ibuf:ibuf) = '0' + endif + ibuf = ibuf+1 + itemp = shiftl(itemp,1) + enddo + enddo + output(ibuf:ibuf) = '|' +end + + subroutine bitstring_to_hexa( output, string, Nint ) use bitmasks @@ -166,6 +201,25 @@ subroutine debug_det(string,Nint) end +subroutine debug_cfg(string,Nint) + use bitmasks + implicit none + BEGIN_DOC + ! Subroutine to print the content of a determinant in '+-' notation and + ! hexadecimal representation. + END_DOC + integer, intent(in) :: Nint + integer(bit_kind), intent(in) :: string(Nint,2) + character*(2048) :: output(2) + call bitstring_to_hexa( output(1), string(1,1), Nint ) + call bitstring_to_hexa( output(2), string(1,2), Nint ) + print *, trim(output(1)) , '|', trim(output(2)) + + call configuration_to_str( output(1), string, Nint ) + print *, trim(output(1)) + +end + subroutine print_det(string,Nint) use bitmasks implicit none diff --git a/src/determinants/create_excitations.irp.f b/src/determinants/create_excitations.irp.f index cec87901..6f3ec521 100644 --- a/src/determinants/create_excitations.irp.f +++ b/src/determinants/create_excitations.irp.f @@ -99,7 +99,8 @@ logical function is_spin_flip_possible(key_in,i_flip,ispin) other_spin(1) = 2 other_spin(2) = 1 if(popcnt(iand(key_tmp(k,1),key_in(k,ispin))) == 1 .and. popcnt(iand(key_tmp(k,1),key_in(k,other_spin(ispin)))) == 0 )then - ! There is a spin "ispin" in the orbital i_flip AND There is no electron of opposit spin in the same orbital "i_flip" + ! There is a spin "ispin" in the orbital i_flip AND + ! There is no electron of opposit spin in the same orbital "i_flip" is_spin_flip_possible = .True. return else