From b6d8531583a837a7ce6f5b47db5c11fc686d87fc Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 14 Jul 2015 00:19:45 +0200 Subject: [PATCH] Accelerated S^2 --- plugins/MRCC_CASSD/.gitignore | 2 +- plugins/MRCC_CASSD/README.rst | 4 +- scripts/qp_set_frozen_core.py | 2 +- src/Determinants/README.rst | 10 +++-- src/Determinants/s2.irp.f | 58 +++++++++++++++++++++-------- src/Determinants/slater_rules.irp.f | 5 +-- src/Ezfio_files/README.rst | 8 ++-- 7 files changed, 60 insertions(+), 29 deletions(-) diff --git a/plugins/MRCC_CASSD/.gitignore b/plugins/MRCC_CASSD/.gitignore index 7f33cb9d..d81ca7b8 100644 --- a/plugins/MRCC_CASSD/.gitignore +++ b/plugins/MRCC_CASSD/.gitignore @@ -28,5 +28,5 @@ Utils ezfio_interface.irp.f irpf90.make irpf90_entities -mrcc +mrcc_cassd tags \ No newline at end of file diff --git a/plugins/MRCC_CASSD/README.rst b/plugins/MRCC_CASSD/README.rst index a0367d40..5ef5db62 100644 --- a/plugins/MRCC_CASSD/README.rst +++ b/plugins/MRCC_CASSD/README.rst @@ -24,10 +24,10 @@ Documentation .. Do not edit this section. It was auto-generated from the .. by the `update_README.py` script. -`mrcc `_ +`mrcc `_ Undocumented -`print_cas_coefs `_ +`print_cas_coefs `_ Undocumented diff --git a/scripts/qp_set_frozen_core.py b/scripts/qp_set_frozen_core.py index 843df4b3..3f95a9e6 100755 --- a/scripts/qp_set_frozen_core.py +++ b/scripts/qp_set_frozen_core.py @@ -3,7 +3,7 @@ import os import sys -sys.path = [ os.environ["QP_ROOT"]+"/EZFIO/Python" ] + sys.path +sys.path = [ os.environ["QP_ROOT"]+"/install/EZFIO/Python" ] + sys.path from ezfio import ezfio ezfio.set_filename(sys.argv[1]) diff --git a/src/Determinants/README.rst b/src/Determinants/README.rst index d41291d0..b3e8b7a0 100644 --- a/src/Determinants/README.rst +++ b/src/Determinants/README.rst @@ -217,7 +217,7 @@ Documentation det_coef -`det_connections `_ +`det_connections `_ Build connection proxy between determinants @@ -391,7 +391,11 @@ Documentation Returns -`get_s2_u0 `_ +`get_s2_u0 `_ + Undocumented + + +`get_s2_u0_old `_ Undocumented @@ -508,7 +512,7 @@ Documentation Energy of the reference bitmask used in Slater rules -`n_con_int `_ +`n_con_int `_ Number of integers to represent the connections between determinants diff --git a/src/Determinants/s2.irp.f b/src/Determinants/s2.irp.f index fd42fe51..72c1b9aa 100644 --- a/src/Determinants/s2.irp.f +++ b/src/Determinants/s2.irp.f @@ -79,7 +79,7 @@ BEGIN_PROVIDER [ double precision, s2_values, (N_states) ] END_PROVIDER -subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2) +subroutine get_s2_u0_old(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2) implicit none use bitmasks integer(bit_kind), intent(in) :: psi_keys_tmp(N_int,2,nmax) @@ -89,32 +89,60 @@ subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2) integer :: i,j,l double precision :: s2_tmp s2 = 0.d0 -!print*,'IN get_s2_u0' -!print*,'n,nmax = ',n,nmax - double precision :: accu - accu = 0.d0 - do i = 1,n - accu += psi_coefs_tmp(i) * psi_coefs_tmp(i) -! print*,'psi_coef = ',psi_coefs_tmp(i) - enddo -!print*,'accu = ',accu -!print*,'' !$OMP PARALLEL DO DEFAULT(NONE) & !$OMP PRIVATE(i,j,s2_tmp) SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int) REDUCTION(+:s2) SCHEDULE(dynamic) do i=1,n do j=i+1,n call get_s2(psi_keys_tmp(1,1,i),psi_keys_tmp(1,1,j),s2_tmp,N_int) - s2 += (psi_coefs_tmp(i)+psi_coefs_tmp(i))*psi_coefs_tmp(j)*s2_tmp -! s2 = s2 + 2.d0 * psi_coefs_tmp(i)*psi_coefs_tmp(j)*s2_tmp + s2 += psi_coefs_tmp(i)*psi_coefs_tmp(j)*s2_tmp enddo enddo !$OMP END PARALLEL DO + s2 = s2+s2 do i=1,n call get_s2(psi_keys_tmp(1,1,i),psi_keys_tmp(1,1,i),s2_tmp,N_int) s2 += psi_coefs_tmp(i)*psi_coefs_tmp(i)*s2_tmp enddo s2 += S_z2_Sz -!print*,'s2 = ',s2 -!print*,'' +end + +subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2) + implicit none + use bitmasks + integer(bit_kind), intent(in) :: psi_keys_tmp(N_int,2,nmax) + integer, intent(in) :: n,nmax + double precision, intent(in) :: psi_coefs_tmp(nmax) + double precision, intent(out) :: s2 + double precision :: s2_tmp + integer :: i,j,l,jj + integer, allocatable :: idx(:) + s2 = 0.d0 + !$OMP PARALLEL DEFAULT(NONE) & + !$OMP PRIVATE(i,j,s2_tmp,idx) & + !$OMP SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int,davidson_threshold)& + !$OMP REDUCTION(+:s2) + allocate(idx(0:n)) + !$OMP DO SCHEDULE(dynamic) + do i=1,n + idx(0) = i + call filter_connected_davidson(psi_keys_tmp,psi_keys_tmp(1,1,i),N_int,i-1,idx) + do jj=1,idx(0) + j = idx(jj) + if ( dabs(psi_coefs_tmp(j)) + dabs(psi_coefs_tmp(i)) & + > davidson_threshold ) then + call get_s2(psi_keys_tmp(1,1,i),psi_keys_tmp(1,1,j),s2_tmp,N_int) + s2 = s2 + psi_coefs_tmp(i)*psi_coefs_tmp(j)*s2_tmp + endif + enddo + enddo + !$OMP END DO + deallocate(idx) + !$OMP END PARALLEL + s2 = s2+s2 + do i=1,n + call get_s2(psi_keys_tmp(1,1,i),psi_keys_tmp(1,1,i),s2_tmp,N_int) + s2 = s2 + psi_coefs_tmp(i)*psi_coefs_tmp(i)*s2_tmp + enddo + s2 = s2 + S_z2_Sz end diff --git a/src/Determinants/slater_rules.irp.f b/src/Determinants/slater_rules.irp.f index 7d431879..a8b394d9 100644 --- a/src/Determinants/slater_rules.irp.f +++ b/src/Determinants/slater_rules.irp.f @@ -1092,10 +1092,9 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint) ASSERT (Nint == N_int) ASSERT (n>0) PROVIDE ref_bitmask_energy - integer, parameter :: block_size = 157 !$OMP PARALLEL DEFAULT(NONE) & !$OMP PRIVATE(i,hij,j,k,idx,jj,vt) & - !$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0) + !$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold) !$OMP DO SCHEDULE(static) do i=1,n v_0(i) = H_jj(i) * u_0(i) @@ -1109,7 +1108,7 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint) call filter_connected_davidson(keys_tmp,keys_tmp(1,1,i),Nint,i-1,idx) do jj=1,idx(0) j = idx(jj) - if ( (dabs(u_0(j)) > 1.d-7).or.((dabs(u_0(i)) > 1.d-7)) ) then + if ( dabs(u_0(j)) + dabs(u_0(i)) > davidson_threshold ) then call i_H_j(keys_tmp(1,1,j),keys_tmp(1,1,i),Nint,hij) vt (i) = vt (i) + hij*u_0(j) vt (j) = vt (j) + hij*u_0(i) diff --git a/src/Ezfio_files/README.rst b/src/Ezfio_files/README.rst index ca558850..6a3a1f2b 100644 --- a/src/Ezfio_files/README.rst +++ b/src/Ezfio_files/README.rst @@ -90,12 +90,12 @@ Documentation Output file for MOGuess -`output_mrcc `_ - Output file for MRCC +`output_mrcc_cassd `_ + Output file for MRCC_CASSD -`output_mrcc_general `_ - Output file for MRCC_general +`output_mrcc_utils `_ + Output file for MRCC_Utils `output_nuclei `_