mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-12-21 11:03:29 +01:00
Merge branch 'dev-stable-tc-scf' of https://github.com/QuantumPackage/qp2 into dev-stable-tc-scf
This commit is contained in:
commit
eea6758d26
2
external/qp2-dependencies
vendored
2
external/qp2-dependencies
vendored
@ -1 +1 @@
|
||||
Subproject commit ce14f57b50511825a9fedb096749200779d3f4d4
|
||||
Subproject commit 6e23ebac001acae91d1c762ca934e09a9b7d614a
|
43
scripts/Hn.py
Normal file
43
scripts/Hn.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
from math import *
|
||||
arg = sys.argv
|
||||
#f = open('data_dft','r')
|
||||
n = int(sys.argv[1])
|
||||
r = float(sys.argv[2])
|
||||
f = open('H'+str(n)+'_'+str(r)+'.xyz','w')
|
||||
string=str(n)+"\n"
|
||||
f.write(string)
|
||||
string="\n"
|
||||
f.write(string)
|
||||
for i in range(n):
|
||||
x = r * cos(2.* i* pi/n)
|
||||
y = r * sin(2.* i* pi/n)
|
||||
z = 0.
|
||||
string="H "+str(x)+" "+str(y)+" "+str(z)+"\n"
|
||||
f.write(string)
|
||||
|
||||
#lines = f.readlines()
|
||||
#cipsi_dft= []
|
||||
#
|
||||
#dissoc = []
|
||||
#dissoc.append(float(-76.0179223470363))
|
||||
#dissoc.append(float(-76.0592367866993))
|
||||
#dissoc.append(float(-76.0678739715659))
|
||||
#delta_e = []
|
||||
#
|
||||
#for line in lines:
|
||||
# data = line.split()
|
||||
# if(len(data)>0):
|
||||
# dft=float(data[1])
|
||||
# fci=float(data[2])
|
||||
# e=fci+dft
|
||||
# cipsi_dft.append(e)
|
||||
#
|
||||
#print(*cipsi_dft,sep=" & ")
|
||||
#
|
||||
#for i in 0,1,2:
|
||||
# delta_e.append(1000.*(dissoc[i] - cipsi_dft[i]))
|
||||
#
|
||||
#print(*delta_e,sep=" & ")
|
||||
#
|
2
scripts/get_fci_tc_conv.sh
Executable file
2
scripts/get_fci_tc_conv.sh
Executable file
@ -0,0 +1,2 @@
|
||||
file=$1
|
||||
grep "Ndet,E,E+PT2,E+RPT2,|PT2|=" $file | cut -d "=" -f 2 > ${file}.conv_fci_tc
|
@ -38,7 +38,7 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test, (ao_num, ao_n
|
||||
!$OMP expo_gauss_1_erf_x_2, coef_gauss_1_erf_x_2, &
|
||||
!$OMP List_comb_thr_b3_coef, List_comb_thr_b3_expo, &
|
||||
!$OMP List_comb_thr_b3_cent, int2_grad1u2_grad2u2_j1b2_test, ao_abs_comb_b3_j1b, &
|
||||
!$OMP ao_overlap_abs,sq_pi_3_2)
|
||||
!$OMP ao_overlap_abs,sq_pi_3_2,thrsh_cycle_tc)
|
||||
!$OMP DO SCHEDULE(dynamic)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,ipoint)
|
||||
@ -46,7 +46,7 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test, (ao_num, ao_n
|
||||
r(3) = final_grid_points(3,ipoint)
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
if(ao_overlap_abs(j,i) .lt. 1.d-12) then
|
||||
if(ao_overlap_abs(j,i) .lt. thrsh_cycle_tc) then
|
||||
cycle
|
||||
endif
|
||||
|
||||
@ -58,7 +58,7 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test, (ao_num, ao_n
|
||||
do i_fit = 1, ng_fit_jast
|
||||
expo_fit = expo_gauss_1_erf_x_2(i_fit)
|
||||
coef_fit = -0.25d0 * coef_gauss_1_erf_x_2(i_fit)
|
||||
if(dabs(coef_fit*int_j1b*sq_pi_3_2*(expo_fit)**(-1.5d0)).lt.1.d-10)cycle
|
||||
! if(dabs(coef_fit*int_j1b*sq_pi_3_2*(expo_fit)**(-1.5d0)).lt.thrsh_cycle_tc)cycle
|
||||
int_gauss = overlap_gauss_r12_ao(r, expo_fit, i, j)
|
||||
int2_grad1u2_grad2u2_j1b2_test(j,i,ipoint) += coef_fit * int_gauss
|
||||
enddo
|
||||
@ -81,8 +81,7 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test, (ao_num, ao_n
|
||||
!DIR$ FORCEINLINE
|
||||
call gaussian_product(expo_fit,r,beta,B_center,factor_ij_1s,beta_ij,center_ij_1s)
|
||||
coef_fit = -0.25d0 * coef_gauss_1_erf_x_2(i_fit) * coef
|
||||
! if(dabs(coef_fit*factor_ij_1s*int_j1b).lt.1.d-10)cycle ! old version
|
||||
if(dabs(coef_fit*factor_ij_1s*int_j1b*sq_pi_3_2*(beta_ij)**(-1.5d0)).lt.1.d-10)cycle
|
||||
! if(dabs(coef_fit*factor_ij_1s*int_j1b*sq_pi_3_2*(beta_ij)**(-1.5d0)).lt.thrsh_cycle_tc)cycle
|
||||
! call overlap_gauss_r12_ao_with1s_v(B_center, beta, final_grid_points_transp, &
|
||||
! expo_fit, i, j, int_fit_v, n_points_final_grid)
|
||||
int_gauss = overlap_gauss_r12_ao_with1s(B_center, beta, r, expo_fit, i, j)
|
||||
@ -145,14 +144,14 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test_v, (ao_num, ao
|
||||
!$OMP expo_gauss_1_erf_x_2, coef_gauss_1_erf_x_2, &
|
||||
!$OMP List_comb_thr_b3_coef, List_comb_thr_b3_expo, &
|
||||
!$OMP List_comb_thr_b3_cent, big_array,&
|
||||
!$OMP ao_abs_comb_b3_j1b,ao_overlap_abs)
|
||||
!$OMP ao_abs_comb_b3_j1b,ao_overlap_abs,thrsh_cycle_tc)
|
||||
!
|
||||
allocate(int_fit_v(n_points_final_grid))
|
||||
!$OMP DO SCHEDULE(dynamic)
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
|
||||
if(ao_overlap_abs(j,i) .lt. 1.d-12) then
|
||||
if(ao_overlap_abs(j,i) .lt. thrsh_cycle_tc) then
|
||||
cycle
|
||||
endif
|
||||
|
||||
@ -161,7 +160,6 @@ BEGIN_PROVIDER [ double precision, int2_grad1u2_grad2u2_j1b2_test_v, (ao_num, ao
|
||||
coef = List_comb_thr_b3_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b3_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b3_j1b(i_1s,j,i)
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.1.d-15)cycle
|
||||
B_center(1) = List_comb_thr_b3_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b3_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b3_cent(3,i_1s,j,i)
|
||||
@ -243,7 +241,7 @@ BEGIN_PROVIDER [ double precision, int2_u2_j1b2_test, (ao_num, ao_num, n_points_
|
||||
!$OMP final_grid_points, ng_fit_jast, &
|
||||
!$OMP expo_gauss_j_mu_x_2, coef_gauss_j_mu_x_2, &
|
||||
!$OMP List_comb_thr_b3_coef, List_comb_thr_b3_expo,sq_pi_3_2, &
|
||||
!$OMP List_comb_thr_b3_cent, int2_u2_j1b2_test,ao_abs_comb_b3_j1b)
|
||||
!$OMP List_comb_thr_b3_cent, int2_u2_j1b2_test,ao_abs_comb_b3_j1b,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,ipoint)
|
||||
@ -260,11 +258,11 @@ BEGIN_PROVIDER [ double precision, int2_u2_j1b2_test, (ao_num, ao_num, n_points_
|
||||
! --- --- ---
|
||||
|
||||
int_j1b = ao_abs_comb_b3_j1b(1,j,i)
|
||||
if(dabs(int_j1b).lt.1.d-10) cycle
|
||||
if(dabs(int_j1b).lt.thrsh_cycle_tc) cycle
|
||||
do i_fit = 1, ng_fit_jast
|
||||
expo_fit = expo_gauss_j_mu_x_2(i_fit)
|
||||
coef_fit = coef_gauss_j_mu_x_2(i_fit)
|
||||
if(dabs(coef_fit*int_j1b*sq_pi_3_2*(expo_fit)**(-1.5d0)).lt.1.d-10)cycle
|
||||
! if(dabs(coef_fit*int_j1b*sq_pi_3_2*(expo_fit)**(-1.5d0)).lt.thrsh_cycle_tc)cycle
|
||||
int_fit = overlap_gauss_r12_ao(r, expo_fit, i, j)
|
||||
tmp += coef_fit * int_fit
|
||||
enddo
|
||||
@ -278,7 +276,7 @@ BEGIN_PROVIDER [ double precision, int2_u2_j1b2_test, (ao_num, ao_num, n_points_
|
||||
coef = List_comb_thr_b3_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b3_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b3_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b3_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b3_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b3_cent(3,i_1s,j,i)
|
||||
@ -288,8 +286,7 @@ BEGIN_PROVIDER [ double precision, int2_u2_j1b2_test, (ao_num, ao_num, n_points_
|
||||
coef_fit = coef_gauss_j_mu_x_2(i_fit)
|
||||
!DIR$ FORCEINLINE
|
||||
call gaussian_product(expo_fit,r,beta,B_center,factor_ij_1s,beta_ij,center_ij_1s)
|
||||
! if(dabs(coef_fit*coef*factor_ij_1s*int_j1b).lt.1.d-10)cycle ! old version
|
||||
if(dabs(coef_fit*coef*factor_ij_1s*int_j1b*sq_pi_3_2*(beta_ij)**(-1.5d0)).lt.1.d-10)cycle
|
||||
! if(dabs(coef_fit*coef*factor_ij_1s*int_j1b*sq_pi_3_2*(beta_ij)**(-1.5d0)).lt.thrsh_cycle_tc)cycle
|
||||
int_fit = overlap_gauss_r12_ao_with1s(B_center, beta, r, expo_fit, i, j)
|
||||
tmp += coef * coef_fit * int_fit
|
||||
enddo
|
||||
@ -350,7 +347,7 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_x_j1b2_test, (ao_num, ao_num, n
|
||||
!$OMP final_grid_points, ng_fit_jast, &
|
||||
!$OMP expo_gauss_j_mu_1_erf, coef_gauss_j_mu_1_erf, &
|
||||
!$OMP List_comb_thr_b3_coef, List_comb_thr_b3_expo, &
|
||||
!$OMP List_comb_thr_b3_cent, int2_u_grad1u_x_j1b2_test,ao_abs_comb_b3_j1b,sq_pi_3_2)
|
||||
!$OMP List_comb_thr_b3_cent, int2_u_grad1u_x_j1b2_test,ao_abs_comb_b3_j1b,sq_pi_3_2,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -369,7 +366,7 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_x_j1b2_test, (ao_num, ao_num, n
|
||||
coef = List_comb_thr_b3_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b3_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b3_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b3_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b3_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b3_cent(3,i_1s,j,i)
|
||||
@ -392,8 +389,7 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_x_j1b2_test, (ao_num, ao_num, n
|
||||
expo_coef_1s = beta * expo_fit * alpha_1s_inv * dist
|
||||
coef_tmp = coef * coef_fit * dexp(-expo_coef_1s)
|
||||
sq_alpha = alpha_1s_inv * dsqrt(alpha_1s_inv)
|
||||
! if(dabs(coef_tmp*int_j1b) .lt. 1d-10) cycle ! old version
|
||||
if(dabs(coef_tmp*int_j1b*sq_pi_3_2*sq_alpha) .lt. 1d-10) cycle
|
||||
! if(dabs(coef_tmp*int_j1b*sq_pi_3_2*sq_alpha) .lt. thrsh_cycle_tc) cycle
|
||||
|
||||
call NAI_pol_x_mult_erf_ao_with1s(i, j, alpha_1s, centr_1s, 1.d+9, r, int_fit)
|
||||
|
||||
@ -470,13 +466,13 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_j1b2_test, (ao_num, ao_num, n_p
|
||||
!$OMP expo_gauss_j_mu_1_erf, coef_gauss_j_mu_1_erf, &
|
||||
!$OMP ao_prod_dist_grid, ao_prod_sigma, ao_overlap_abs_grid,ao_prod_center,dsqpi_3_2, &
|
||||
!$OMP List_comb_thr_b3_coef, List_comb_thr_b3_expo, ao_abs_comb_b3_j1b, &
|
||||
!$OMP List_comb_thr_b3_cent, int2_u_grad1u_j1b2_test)
|
||||
!$OMP List_comb_thr_b3_cent, int2_u_grad1u_j1b2_test,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.1.d-10) cycle
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.thrsh_cycle_tc) cycle
|
||||
|
||||
r(1) = final_grid_points(1,ipoint)
|
||||
r(2) = final_grid_points(2,ipoint)
|
||||
@ -489,10 +485,10 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_j1b2_test, (ao_num, ao_num, n_p
|
||||
! --- --- ---
|
||||
|
||||
int_j1b = ao_abs_comb_b3_j1b(1,j,i)
|
||||
if(dabs(int_j1b).lt.1.d-10) cycle
|
||||
! if(dabs(int_j1b).lt.thrsh_cycle_tc) cycle
|
||||
do i_fit = 1, ng_fit_jast
|
||||
expo_fit = expo_gauss_j_mu_1_erf(i_fit)
|
||||
if(dabs(int_j1b)*dsqpi_3_2*expo_fit**(-1.5d0).lt.1.d-15) cycle
|
||||
! if(dabs(int_j1b)*dsqpi_3_2*expo_fit**(-1.5d0).lt.thrsh_cycle_tc) cycle
|
||||
coef_fit = coef_gauss_j_mu_1_erf(i_fit)
|
||||
int_fit = NAI_pol_mult_erf_ao_with1s(i, j, expo_fit, r, 1.d+9, r)
|
||||
tmp += coef_fit * int_fit
|
||||
@ -507,7 +503,7 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_j1b2_test, (ao_num, ao_num, n_p
|
||||
coef = List_comb_thr_b3_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b3_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b3_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b3_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b3_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b3_cent(3,i_1s,j,i)
|
||||
@ -517,7 +513,7 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_j1b2_test, (ao_num, ao_num, n_p
|
||||
do i_fit = 1, ng_fit_jast
|
||||
expo_fit = expo_gauss_j_mu_1_erf(i_fit)
|
||||
call gaussian_product(expo_fit,r,beta,B_center,factor_ij_1s,beta_ij,center_ij_1s)
|
||||
if(factor_ij_1s*dabs(coef*int_j1b)*dsqpi_3_2*beta_ij**(-1.5d0).lt.1.d-15)cycle
|
||||
! if(factor_ij_1s*dabs(coef*int_j1b)*dsqpi_3_2*beta_ij**(-1.5d0).lt.thrsh_cycle_tc)cycle
|
||||
coef_fit = coef_gauss_j_mu_1_erf(i_fit)
|
||||
|
||||
alpha_1s = beta + expo_fit
|
||||
@ -527,9 +523,9 @@ BEGIN_PROVIDER [ double precision, int2_u_grad1u_j1b2_test, (ao_num, ao_num, n_p
|
||||
centr_1s(3) = alpha_1s_inv * (beta * B_center(3) + expo_fit * r(3))
|
||||
|
||||
expo_coef_1s = beta * expo_fit * alpha_1s_inv * dist
|
||||
if(expo_coef_1s .gt. 20.d0) cycle
|
||||
! if(expo_coef_1s .gt. 20.d0) cycle
|
||||
coef_tmp = coef * coef_fit * dexp(-expo_coef_1s)
|
||||
if(dabs(coef_tmp) .lt. 1d-08) cycle
|
||||
! if(dabs(coef_tmp) .lt. 1d-08) cycle
|
||||
|
||||
int_fit = NAI_pol_mult_erf_ao_with1s(i, j, alpha_1s, centr_1s, 1.d+9, r)
|
||||
|
||||
|
@ -31,7 +31,7 @@ BEGIN_PROVIDER [ double precision, v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_num,
|
||||
!$OMP SHARED (n_points_final_grid, ao_num, List_comb_thr_b2_size, final_grid_points, &
|
||||
!$OMP List_comb_thr_b2_coef, List_comb_thr_b2_expo, List_comb_thr_b2_cent,ao_abs_comb_b2_j1b, &
|
||||
!$OMP v_ij_erf_rk_cst_mu_j1b_test, mu_erf, &
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2)
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
!do ipoint = 1, 10
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -41,7 +41,7 @@ BEGIN_PROVIDER [ double precision, v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_num,
|
||||
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.1.d-20)cycle
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.thrsh_cycle_tc)cycle
|
||||
|
||||
tmp = 0.d0
|
||||
do i_1s = 1, List_comb_thr_b2_size(j,i)
|
||||
@ -49,7 +49,7 @@ BEGIN_PROVIDER [ double precision, v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_num,
|
||||
coef = List_comb_thr_b2_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b2_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b2_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b2_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b2_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b2_cent(3,i_1s,j,i)
|
||||
@ -110,7 +110,7 @@ BEGIN_PROVIDER [ double precision, x_v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_nu
|
||||
!$OMP SHARED (n_points_final_grid, ao_num, List_comb_thr_b2_size, final_grid_points,&
|
||||
!$OMP List_comb_thr_b2_coef, List_comb_thr_b2_expo, List_comb_thr_b2_cent, &
|
||||
!$OMP x_v_ij_erf_rk_cst_mu_j1b_test, mu_erf,ao_abs_comb_b2_j1b, &
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma)
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,thrsh_cycle_tc)
|
||||
! !$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2,expo_erfc_mu_gauss)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -120,7 +120,7 @@ BEGIN_PROVIDER [ double precision, x_v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_nu
|
||||
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.1.d-10)cycle
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.thrsh_cycle_tc)cycle
|
||||
|
||||
tmp_x = 0.d0
|
||||
tmp_y = 0.d0
|
||||
@ -130,19 +130,11 @@ BEGIN_PROVIDER [ double precision, x_v_ij_erf_rk_cst_mu_j1b_test, (ao_num, ao_nu
|
||||
coef = List_comb_thr_b2_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b2_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b2_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b2_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b2_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b2_cent(3,i_1s,j,i)
|
||||
|
||||
! if(ao_prod_center(1,j,i).ne.10000.d0)then
|
||||
! ! approximate 1 - erf(mu r12) by a gaussian * 10
|
||||
! !DIR$ FORCEINLINE
|
||||
! call gaussian_product(expo_erfc_mu_gauss,r, &
|
||||
! ao_prod_sigma(j,i),ao_prod_center(1,j,i), &
|
||||
! factor_ij_1s,beta_ij,center_ij_1s)
|
||||
! if(dabs(coef * factor_ij_1s*int_j1b*10.d0 * dsqpi_3_2 * beta_ij**(-1.5d0)).lt.1.d-10)cycle
|
||||
! endif
|
||||
call NAI_pol_x_mult_erf_ao_with1s(i, j, beta, B_center, mu_erf, r, ints )
|
||||
call NAI_pol_x_mult_erf_ao_with1s(i, j, beta, B_center, 1.d+9, r, ints_coulomb)
|
||||
|
||||
@ -216,7 +208,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_test, (ao_num, ao_num, n_po
|
||||
!$OMP expo_gauss_j_mu_x, coef_gauss_j_mu_x, &
|
||||
!$OMP List_comb_thr_b2_coef, List_comb_thr_b2_expo,List_comb_thr_b2_size, &
|
||||
!$OMP List_comb_thr_b2_cent, v_ij_u_cst_mu_j1b_test,ao_abs_comb_b2_j1b, &
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2)
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,ipoint)
|
||||
@ -225,7 +217,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_test, (ao_num, ao_num, n_po
|
||||
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.1.d-20)cycle
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.thrsh_cycle_tc)cycle
|
||||
|
||||
tmp = 0.d0
|
||||
|
||||
@ -234,11 +226,11 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_test, (ao_num, ao_num, n_po
|
||||
! --- --- ---
|
||||
|
||||
int_j1b = ao_abs_comb_b2_j1b(1,j,i)
|
||||
if(dabs(int_j1b).lt.1.d-10) cycle
|
||||
! if(dabs(int_j1b).lt.thrsh_cycle_tc) cycle
|
||||
do i_fit = 1, ng_fit_jast
|
||||
expo_fit = expo_gauss_j_mu_x(i_fit)
|
||||
coef_fit = coef_gauss_j_mu_x(i_fit)
|
||||
if(ao_overlap_abs_grid(j,i).lt.1.d-15) cycle
|
||||
! if(ao_overlap_abs_grid(j,i).lt.thrsh_cycle_tc) cycle
|
||||
int_fit = overlap_gauss_r12_ao(r, expo_fit, i, j)
|
||||
tmp += coef_fit * int_fit
|
||||
enddo
|
||||
@ -251,7 +243,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_test, (ao_num, ao_num, n_po
|
||||
coef = List_comb_thr_b2_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b2_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b2_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b2_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b2_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b2_cent(3,i_1s,j,i)
|
||||
@ -259,9 +251,9 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_test, (ao_num, ao_num, n_po
|
||||
expo_fit = expo_gauss_j_mu_x(i_fit)
|
||||
coef_fit = coef_gauss_j_mu_x(i_fit)
|
||||
coeftot = coef * coef_fit
|
||||
if(dabs(coeftot).lt.1.d-15)cycle
|
||||
! if(dabs(coeftot).lt.thrsh_cycle_tc)cycle
|
||||
call gaussian_product(beta,B_center,expo_fit,r,factor_ij_1s_u,beta_ij_u,center_ij_1s_u)
|
||||
if(factor_ij_1s_u*ao_overlap_abs_grid(j,i).lt.1.d-15)cycle
|
||||
! if(factor_ij_1s_u*ao_overlap_abs_grid(j,i).lt.thrsh_cycle_tc)cycle
|
||||
int_fit = overlap_gauss_r12_ao_with1s(B_center, beta, r, expo_fit, i, j)
|
||||
tmp += coef * coef_fit * int_fit
|
||||
enddo
|
||||
@ -325,7 +317,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_ng_1_test, (ao_num, ao_num,
|
||||
!$OMP expo_gauss_j_mu_x, coef_gauss_j_mu_x, &
|
||||
!$OMP List_comb_thr_b2_coef, List_comb_thr_b2_expo,List_comb_thr_b2_size, &
|
||||
!$OMP List_comb_thr_b2_cent, v_ij_u_cst_mu_j1b_ng_1_test,ao_abs_comb_b2_j1b, &
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2)
|
||||
!$OMP ao_overlap_abs_grid,ao_prod_center,ao_prod_sigma,dsqpi_3_2,thrsh_cycle_tc)
|
||||
!$OMP DO
|
||||
do ipoint = 1, n_points_final_grid
|
||||
r(1) = final_grid_points(1,ipoint)
|
||||
@ -334,7 +326,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_ng_1_test, (ao_num, ao_num,
|
||||
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.1.d-20)cycle
|
||||
if(dabs(ao_overlap_abs_grid(j,i)).lt.thrsh_cycle_tc)cycle
|
||||
|
||||
tmp = 0.d0
|
||||
|
||||
@ -343,7 +335,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_ng_1_test, (ao_num, ao_num,
|
||||
! --- --- ---
|
||||
|
||||
int_j1b = ao_abs_comb_b2_j1b(1,j,i)
|
||||
if(dabs(int_j1b).lt.1.d-10) cycle
|
||||
! if(dabs(int_j1b).lt.thrsh_cycle_tc) cycle
|
||||
expo_fit = expo_good_j_mu_1gauss
|
||||
int_fit = overlap_gauss_r12_ao(r, expo_fit, i, j)
|
||||
tmp += int_fit
|
||||
@ -356,7 +348,7 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_ng_1_test, (ao_num, ao_num,
|
||||
coef = List_comb_thr_b2_coef (i_1s,j,i)
|
||||
beta = List_comb_thr_b2_expo (i_1s,j,i)
|
||||
int_j1b = ao_abs_comb_b2_j1b(i_1s,j,i)
|
||||
if(dabs(coef)*dabs(int_j1b).lt.1.d-10)cycle
|
||||
! if(dabs(coef)*dabs(int_j1b).lt.thrsh_cycle_tc)cycle
|
||||
B_center(1) = List_comb_thr_b2_cent(1,i_1s,j,i)
|
||||
B_center(2) = List_comb_thr_b2_cent(2,i_1s,j,i)
|
||||
B_center(3) = List_comb_thr_b2_cent(3,i_1s,j,i)
|
||||
@ -364,9 +356,9 @@ BEGIN_PROVIDER [ double precision, v_ij_u_cst_mu_j1b_ng_1_test, (ao_num, ao_num,
|
||||
expo_fit = expo_good_j_mu_1gauss
|
||||
coef_fit = 1.d0
|
||||
coeftot = coef * coef_fit
|
||||
if(dabs(coeftot).lt.1.d-15)cycle
|
||||
if(dabs(coeftot).lt.thrsh_cycle_tc)cycle
|
||||
call gaussian_product(beta,B_center,expo_fit,r,factor_ij_1s_u,beta_ij_u,center_ij_1s_u)
|
||||
if(factor_ij_1s_u*ao_overlap_abs_grid(j,i).lt.1.d-15)cycle
|
||||
if(factor_ij_1s_u*ao_overlap_abs_grid(j,i).lt.thrsh_cycle_tc)cycle
|
||||
int_fit = overlap_gauss_r12_ao_with1s(B_center, beta, r, expo_fit, i, j)
|
||||
tmp += coef * coef_fit * int_fit
|
||||
! enddo
|
||||
|
@ -3,15 +3,16 @@
|
||||
&BEGIN_PROVIDER [ integer, max_List_comb_thr_b2_size]
|
||||
implicit none
|
||||
integer :: i_1s,i,j,ipoint
|
||||
double precision :: coef,beta,center(3),int_j1b,thr
|
||||
double precision :: coef,beta,center(3),int_j1b
|
||||
double precision :: r(3),weight,dist
|
||||
thr = 1.d-15
|
||||
List_comb_thr_b2_size = 0
|
||||
print*,'List_all_comb_b2_size = ',List_all_comb_b2_size
|
||||
! pause
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
do i_1s = 1, List_all_comb_b2_size
|
||||
coef = List_all_comb_b2_coef (i_1s)
|
||||
if(dabs(coef).lt.1.d-15)cycle
|
||||
if(dabs(coef).lt.thrsh_cycle_tc)cycle
|
||||
beta = List_all_comb_b2_expo (i_1s)
|
||||
beta = max(beta,1.d-12)
|
||||
center(1:3) = List_all_comb_b2_cent(1:3,i_1s)
|
||||
@ -24,7 +25,7 @@
|
||||
dist += ( center(3) - r(3) )*( center(3) - r(3) )
|
||||
int_j1b += dabs(aos_in_r_array_extra_transp(ipoint,i) * aos_in_r_array_extra_transp(ipoint,j))*dexp(-beta*dist) * weight
|
||||
enddo
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thr)then
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thrsh_cycle_tc)then
|
||||
List_comb_thr_b2_size(j,i) += 1
|
||||
endif
|
||||
enddo
|
||||
@ -40,6 +41,7 @@
|
||||
list(i) = maxval(List_comb_thr_b2_size(:,i))
|
||||
enddo
|
||||
max_List_comb_thr_b2_size = maxval(list)
|
||||
print*,'max_List_comb_thr_b2_size = ',max_List_comb_thr_b2_size
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
@ -49,16 +51,15 @@ END_PROVIDER
|
||||
&BEGIN_PROVIDER [ double precision, ao_abs_comb_b2_j1b, ( max_List_comb_thr_b2_size ,ao_num, ao_num)]
|
||||
implicit none
|
||||
integer :: i_1s,i,j,ipoint,icount
|
||||
double precision :: coef,beta,center(3),int_j1b,thr
|
||||
double precision :: coef,beta,center(3),int_j1b
|
||||
double precision :: r(3),weight,dist
|
||||
thr = 1.d-15
|
||||
ao_abs_comb_b2_j1b = 10000000.d0
|
||||
do i = 1, ao_num
|
||||
do j = i, ao_num
|
||||
icount = 0
|
||||
do i_1s = 1, List_all_comb_b2_size
|
||||
coef = List_all_comb_b2_coef (i_1s)
|
||||
if(dabs(coef).lt.1.d-12)cycle
|
||||
if(dabs(coef).lt.thrsh_cycle_tc)cycle
|
||||
beta = List_all_comb_b2_expo (i_1s)
|
||||
center(1:3) = List_all_comb_b2_cent(1:3,i_1s)
|
||||
int_j1b = 0.d0
|
||||
@ -70,7 +71,7 @@ END_PROVIDER
|
||||
dist += ( center(3) - r(3) )*( center(3) - r(3) )
|
||||
int_j1b += dabs(aos_in_r_array_extra_transp(ipoint,i) * aos_in_r_array_extra_transp(ipoint,j))*dexp(-beta*dist) * weight
|
||||
enddo
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thr)then
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thrsh_cycle_tc)then
|
||||
icount += 1
|
||||
List_comb_thr_b2_coef(icount,j,i) = coef
|
||||
List_comb_thr_b2_expo(icount,j,i) = beta
|
||||
@ -98,17 +99,17 @@ END_PROVIDER
|
||||
&BEGIN_PROVIDER [ integer, max_List_comb_thr_b3_size]
|
||||
implicit none
|
||||
integer :: i_1s,i,j,ipoint
|
||||
double precision :: coef,beta,center(3),int_j1b,thr
|
||||
double precision :: coef,beta,center(3),int_j1b
|
||||
double precision :: r(3),weight,dist
|
||||
thr = 1.d-15
|
||||
List_comb_thr_b3_size = 0
|
||||
print*,'List_all_comb_b3_size = ',List_all_comb_b3_size
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do i_1s = 1, List_all_comb_b3_size
|
||||
coef = List_all_comb_b3_coef (i_1s)
|
||||
beta = List_all_comb_b3_expo (i_1s)
|
||||
center(1:3) = List_all_comb_b3_cent(1:3,i_1s)
|
||||
if(dabs(coef).lt.thr)cycle
|
||||
if(dabs(coef).lt.thrsh_cycle_tc)cycle
|
||||
int_j1b = 0.d0
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
r(1:3) = final_grid_points_extra(1:3,ipoint)
|
||||
@ -118,7 +119,7 @@ END_PROVIDER
|
||||
dist += ( center(3) - r(3) )*( center(3) - r(3) )
|
||||
int_j1b += dabs(aos_in_r_array_extra_transp(ipoint,i) * aos_in_r_array_extra_transp(ipoint,j))*dexp(-beta*dist) * weight
|
||||
enddo
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thr)then
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thrsh_cycle_tc)then
|
||||
List_comb_thr_b3_size(j,i) += 1
|
||||
endif
|
||||
enddo
|
||||
@ -144,9 +145,8 @@ END_PROVIDER
|
||||
&BEGIN_PROVIDER [ double precision, ao_abs_comb_b3_j1b, ( max_List_comb_thr_b3_size ,ao_num, ao_num)]
|
||||
implicit none
|
||||
integer :: i_1s,i,j,ipoint,icount
|
||||
double precision :: coef,beta,center(3),int_j1b,thr
|
||||
double precision :: coef,beta,center(3),int_j1b
|
||||
double precision :: r(3),weight,dist
|
||||
thr = 1.d-15
|
||||
ao_abs_comb_b3_j1b = 10000000.d0
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
@ -156,7 +156,7 @@ END_PROVIDER
|
||||
beta = List_all_comb_b3_expo (i_1s)
|
||||
beta = max(beta,1.d-12)
|
||||
center(1:3) = List_all_comb_b3_cent(1:3,i_1s)
|
||||
if(dabs(coef).lt.thr)cycle
|
||||
if(dabs(coef).lt.thrsh_cycle_tc)cycle
|
||||
int_j1b = 0.d0
|
||||
do ipoint = 1, n_points_extra_final_grid
|
||||
r(1:3) = final_grid_points_extra(1:3,ipoint)
|
||||
@ -166,7 +166,7 @@ END_PROVIDER
|
||||
dist += ( center(3) - r(3) )*( center(3) - r(3) )
|
||||
int_j1b += dabs(aos_in_r_array_extra_transp(ipoint,i) * aos_in_r_array_extra_transp(ipoint,j))*dexp(-beta*dist) * weight
|
||||
enddo
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thr)then
|
||||
if(dabs(coef)*dabs(int_j1b).gt.thrsh_cycle_tc)then
|
||||
icount += 1
|
||||
List_comb_thr_b3_coef(icount,j,i) = coef
|
||||
List_comb_thr_b3_expo(icount,j,i) = beta
|
||||
@ -177,15 +177,5 @@ END_PROVIDER
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! do i = 1, ao_num
|
||||
! do j = 1, i-1
|
||||
! do icount = 1, List_comb_thr_b3_size(j,i)
|
||||
! List_comb_thr_b3_coef(icount,j,i) = List_comb_thr_b3_coef(icount,i,j)
|
||||
! List_comb_thr_b3_expo(icount,j,i) = List_comb_thr_b3_expo(icount,i,j)
|
||||
! List_comb_thr_b3_cent(1:3,icount,j,i) = List_comb_thr_b3_cent(1:3,icount,i,j)
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
@ -27,7 +27,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_direct_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_direct_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -74,7 +74,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_cycle_1_bi_ort, (mo_num, mo_num
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_cycle_1_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -121,7 +121,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_cycle_2_bi_ort, (mo_num, mo_num
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_cycle_2_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -168,7 +168,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_exch23_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_exch23_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -214,7 +214,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_exch13_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_exch13_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -261,7 +261,7 @@ BEGIN_PROVIDER [ double precision, three_e_4_idx_exch12_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_4_idx_exch12_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
|
@ -26,7 +26,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_direct_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_direct_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -75,7 +75,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_cycle_1_bi_ort, (mo_num, mo_num
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_cycle_1_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -124,7 +124,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_cycle_2_bi_ort, (mo_num, mo_num
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_cycle_2_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -173,7 +173,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_exch23_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_exch23_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -222,7 +222,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_exch13_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_exch13_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
@ -271,7 +271,7 @@ BEGIN_PROVIDER [ double precision, three_e_5_idx_exch12_bi_ort, (mo_num, mo_num,
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i,j,k,m,l,integral) &
|
||||
!$OMP SHARED (mo_num,three_e_5_idx_exch12_bi_ort)
|
||||
!$OMP DO SCHEDULE (dynamic)
|
||||
!$OMP DO SCHEDULE (dynamic) COLLAPSE(2)
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
|
@ -57,6 +57,7 @@ BEGIN_PROVIDER [double precision, ao_two_e_tc_tot, (ao_num, ao_num, ao_num, ao_n
|
||||
|
||||
PROVIDE ao_tc_sym_two_e_pot_in_map
|
||||
|
||||
!!! TODO :: OPENMP
|
||||
do j = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
|
@ -12,32 +12,27 @@
|
||||
double precision :: accu_d, accu_nd
|
||||
double precision, allocatable :: tmp(:,:)
|
||||
|
||||
! TODO : re do the DEGEMM
|
||||
! overlap_bi_ortho = 0.d0
|
||||
! do i = 1, mo_num
|
||||
! do k = 1, mo_num
|
||||
! do m = 1, ao_num
|
||||
! do n = 1, ao_num
|
||||
! overlap_bi_ortho(k,i) += ao_overlap(n,m) * mo_l_coef(n,k) * mo_r_coef(m,i)
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
|
||||
overlap_bi_ortho = 0.d0
|
||||
do i = 1, mo_num
|
||||
do k = 1, mo_num
|
||||
do m = 1, ao_num
|
||||
do n = 1, ao_num
|
||||
overlap_bi_ortho(k,i) += ao_overlap(n,m) * mo_l_coef(n,k) * mo_r_coef(m,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! allocate( tmp(mo_num,ao_num) )
|
||||
!
|
||||
! ! tmp <-- L.T x S_ao
|
||||
! call dgemm( "T", "N", mo_num, ao_num, ao_num, 1.d0 &
|
||||
! , mo_l_coef, size(mo_l_coef, 1), ao_overlap, size(ao_overlap, 1) &
|
||||
! , 0.d0, tmp, size(tmp, 1) )
|
||||
!
|
||||
! ! S <-- tmp x R
|
||||
! call dgemm( "N", "N", mo_num, mo_num, ao_num, 1.d0 &
|
||||
! , tmp, size(tmp, 1), mo_r_coef, size(mo_r_coef, 1) &
|
||||
! , 0.d0, overlap_bi_ortho, size(overlap_bi_ortho, 1) )
|
||||
!
|
||||
! deallocate( tmp )
|
||||
allocate( tmp(mo_num,ao_num) )
|
||||
! tmp <-- L.T x S_ao
|
||||
call dgemm( "T", "N", mo_num, ao_num, ao_num, 1.d0 &
|
||||
, mo_l_coef(1,1), size(mo_l_coef, 1), ao_overlap(1,1), size(ao_overlap, 1) &
|
||||
, 0.d0, tmp(1,1), size(tmp, 1) )
|
||||
! S <-- tmp x R
|
||||
call dgemm( "N", "N", mo_num, mo_num, ao_num, 1.d0 &
|
||||
, tmp(1,1), size(tmp, 1), mo_r_coef(1,1), size(mo_r_coef, 1) &
|
||||
, 0.d0, overlap_bi_ortho(1,1), size(overlap_bi_ortho, 1) )
|
||||
deallocate(tmp)
|
||||
|
||||
do i = 1, mo_num
|
||||
overlap_diag_bi_ortho(i) = overlap_bi_ortho(i,i)
|
||||
@ -84,20 +79,41 @@ END_PROVIDER
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j, p, q
|
||||
integer :: i, j, p, q
|
||||
double precision, allocatable :: tmp(:,:)
|
||||
|
||||
overlap_mo_r = 0.d0
|
||||
overlap_mo_l = 0.d0
|
||||
do i = 1, mo_num
|
||||
do j = 1, mo_num
|
||||
do p = 1, ao_num
|
||||
do q = 1, ao_num
|
||||
overlap_mo_r(j,i) += mo_r_coef(q,i) * mo_r_coef(p,j) * ao_overlap(q,p)
|
||||
overlap_mo_l(j,i) += mo_l_coef(q,i) * mo_l_coef(p,j) * ao_overlap(q,p)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!overlap_mo_r = 0.d0
|
||||
!overlap_mo_l = 0.d0
|
||||
!do i = 1, mo_num
|
||||
! do j = 1, mo_num
|
||||
! do p = 1, ao_num
|
||||
! do q = 1, ao_num
|
||||
! overlap_mo_r(j,i) += mo_r_coef(q,i) * mo_r_coef(p,j) * ao_overlap(q,p)
|
||||
! overlap_mo_l(j,i) += mo_l_coef(q,i) * mo_l_coef(p,j) * ao_overlap(q,p)
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
!enddo
|
||||
|
||||
allocate( tmp(mo_num,ao_num) )
|
||||
|
||||
tmp = 0.d0
|
||||
call dgemm( "T", "N", mo_num, ao_num, ao_num, 1.d0 &
|
||||
, mo_r_coef(1,1), size(mo_r_coef, 1), ao_overlap(1,1), size(ao_overlap, 1) &
|
||||
, 0.d0, tmp(1,1), size(tmp, 1) )
|
||||
call dgemm( "N", "N", mo_num, mo_num, ao_num, 1.d0 &
|
||||
, tmp(1,1), size(tmp, 1), mo_r_coef(1,1), size(mo_r_coef, 1) &
|
||||
, 0.d0, overlap_mo_r(1,1), size(overlap_mo_r, 1) )
|
||||
|
||||
tmp = 0.d0
|
||||
call dgemm( "T", "N", mo_num, ao_num, ao_num, 1.d0 &
|
||||
, mo_l_coef(1,1), size(mo_l_coef, 1), ao_overlap(1,1), size(ao_overlap, 1) &
|
||||
, 0.d0, tmp(1,1), size(tmp, 1) )
|
||||
call dgemm( "N", "N", mo_num, mo_num, ao_num, 1.d0 &
|
||||
, tmp(1,1), size(tmp, 1), mo_l_coef(1,1), size(mo_l_coef, 1) &
|
||||
, 0.d0, overlap_mo_l(1,1), size(overlap_mo_l, 1) )
|
||||
|
||||
deallocate(tmp)
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
@ -1,71 +1,18 @@
|
||||
[threshold_davidson]
|
||||
type: Threshold
|
||||
doc: Thresholds of Davidson's algorithm if threshold_davidson_from_pt2 is false.
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-10
|
||||
|
||||
[threshold_nonsym_davidson]
|
||||
type: Threshold
|
||||
doc: Thresholds of non-symetric Davidson's algorithm
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-10
|
||||
|
||||
[threshold_davidson_from_pt2]
|
||||
type: logical
|
||||
doc: Thresholds of Davidson's algorithm is set to E(rPT2)*threshold_davidson_from_pt2
|
||||
interface: ezfio,provider,ocaml
|
||||
default: false
|
||||
|
||||
[n_states_diag]
|
||||
type: States_number
|
||||
doc: Controls the number of states to consider during the Davdison diagonalization. The number of states is n_states * n_states_diag
|
||||
default: 4
|
||||
interface: ezfio,ocaml
|
||||
|
||||
[davidson_sze_max]
|
||||
type: Strictly_positive_int
|
||||
doc: Number of micro-iterations before re-contracting
|
||||
default: 15
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[state_following]
|
||||
type: logical
|
||||
doc: If |true|, the states are re-ordered to match the input states
|
||||
default: False
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[disk_based_davidson]
|
||||
type: logical
|
||||
doc: If |true|, a memory-mapped file may be used to store the W and S2 vectors if not enough RAM is available
|
||||
default: True
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[csf_based]
|
||||
type: logical
|
||||
doc: If |true|, use the CSF-based algorithm
|
||||
default: False
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[distributed_davidson]
|
||||
type: logical
|
||||
doc: If |true|, use the distributed algorithm
|
||||
default: True
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[only_expected_s2]
|
||||
type: logical
|
||||
doc: If |true|, use filter out all vectors with bad |S^2| values
|
||||
default: True
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[n_det_max_full]
|
||||
type: Det_number_max
|
||||
doc: Maximum number of determinants where |H| is fully diagonalized
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1000
|
||||
|
||||
[without_diagonal]
|
||||
type: logical
|
||||
doc: If |true|, don't use denominator
|
||||
default: False
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
csf
|
||||
davidson_keywords
|
||||
|
@ -546,21 +546,6 @@ end
|
||||
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer, nthreads_davidson ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Number of threads for Davidson
|
||||
END_DOC
|
||||
nthreads_davidson = nproc
|
||||
character*(32) :: env
|
||||
call getenv('QP_NTHREADS_DAVIDSON',env)
|
||||
if (trim(env) /= '') then
|
||||
read(env,*) nthreads_davidson
|
||||
call write_int(6,nthreads_davidson,'Target number of threads for <Psi|H|Psi>')
|
||||
endif
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
integer function zmq_put_N_states_diag(zmq_to_qp_run_socket,worker_id)
|
||||
use f77_zmq
|
||||
implicit none
|
||||
|
@ -14,15 +14,6 @@ BEGIN_PROVIDER [ character*(64), diag_algorithm ]
|
||||
endif
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [ double precision, threshold_davidson_pt2 ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Threshold of Davidson's algorithm, using PT2 as a guide
|
||||
END_DOC
|
||||
threshold_davidson_pt2 = threshold_davidson
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
|
||||
BEGIN_PROVIDER [ integer, dressed_column_idx, (N_states) ]
|
||||
@ -66,7 +57,7 @@ subroutine davidson_diag_hs2(dets_in,u_in,s2_out,dim_in,energies,sze,N_st,N_st_d
|
||||
double precision, allocatable :: H_jj(:)
|
||||
|
||||
double precision, external :: diag_H_mat_elem, diag_S_mat_elem
|
||||
integer :: i,k
|
||||
integer :: i,k,l
|
||||
ASSERT (N_st > 0)
|
||||
ASSERT (sze > 0)
|
||||
ASSERT (Nint > 0)
|
||||
@ -87,9 +78,14 @@ subroutine davidson_diag_hs2(dets_in,u_in,s2_out,dim_in,energies,sze,N_st,N_st_d
|
||||
|
||||
if (dressing_state > 0) then
|
||||
do k=1,N_st
|
||||
|
||||
do i=1,sze
|
||||
H_jj(i) += u_in(i,k) * dressing_column_h(i,k)
|
||||
H_jj(i) += u_in(i,k) * dressing_column_h(i,k)
|
||||
enddo
|
||||
|
||||
!l = dressed_column_idx(k)
|
||||
!H_jj(l) += u_in(l,k) * dressing_column_h(l,k)
|
||||
|
||||
enddo
|
||||
endif
|
||||
|
||||
@ -465,8 +461,9 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_
|
||||
integer :: lwork, info
|
||||
double precision, allocatable :: work(:)
|
||||
|
||||
! y = h
|
||||
y = h_p
|
||||
|
||||
y = h
|
||||
!y = h_p
|
||||
lwork = -1
|
||||
allocate(work(1))
|
||||
call dsygv(1,'V','U',shift2,y,size(y,1), &
|
||||
|
541
src/davidson/diagonalization_nonsym_h_dressed.irp.f
Normal file
541
src/davidson/diagonalization_nonsym_h_dressed.irp.f
Normal file
@ -0,0 +1,541 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine davidson_diag_nonsym_h(dets_in, u_in, dim_in, energies, sze, N_st, N_st_diag, Nint, dressing_state, converged)
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! non-sym Davidson diagonalization.
|
||||
!
|
||||
! dets_in : bitmasks corresponding to determinants
|
||||
!
|
||||
! u_in : guess coefficients on the various states. Overwritten on exit
|
||||
!
|
||||
! dim_in : leftmost dimension of u_in
|
||||
!
|
||||
! sze : Number of determinants
|
||||
!
|
||||
! N_st : Number of eigenstates
|
||||
!
|
||||
! Initial guess vectors are not necessarily orthonormal
|
||||
!
|
||||
END_DOC
|
||||
|
||||
use bitmasks
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: dim_in, sze, N_st, N_st_diag, Nint
|
||||
integer, intent(in) :: dressing_state
|
||||
integer(bit_kind), intent(in) :: dets_in(Nint,2,sze)
|
||||
logical, intent(out) :: converged
|
||||
double precision, intent(out) :: energies(N_st_diag)
|
||||
double precision, intent(inout) :: u_in(dim_in,N_st_diag)
|
||||
|
||||
integer :: i, k, l
|
||||
double precision :: f
|
||||
double precision, allocatable :: H_jj(:)
|
||||
|
||||
double precision, external :: diag_H_mat_elem
|
||||
|
||||
ASSERT (N_st > 0)
|
||||
ASSERT (sze > 0)
|
||||
ASSERT (Nint > 0)
|
||||
ASSERT (Nint == N_int)
|
||||
PROVIDE mo_two_e_integrals_in_map
|
||||
|
||||
allocate(H_jj(sze))
|
||||
|
||||
H_jj(1) = diag_H_mat_elem(dets_in(1,1,1), Nint)
|
||||
!$OMP PARALLEL DEFAULT(NONE) &
|
||||
!$OMP SHARED(sze, H_jj, dets_in, Nint) &
|
||||
!$OMP PRIVATE(i)
|
||||
!$OMP DO SCHEDULE(static)
|
||||
do i = 2, sze
|
||||
H_jj(i) = diag_H_mat_elem(dets_in(1,1,i), Nint)
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
if(dressing_state > 0) then
|
||||
do k = 1, N_st
|
||||
do l = 1, N_st
|
||||
f = overlap_states_inv(k,l)
|
||||
|
||||
!do i = 1, N_det
|
||||
! H_jj(i) += f * dressing_delta(i,k) * psi_coef(i,l)
|
||||
do i = 1, dim_in
|
||||
H_jj(i) += f * dressing_delta(i,k) * u_in(i,l)
|
||||
enddo
|
||||
|
||||
enddo
|
||||
enddo
|
||||
endif
|
||||
|
||||
call davidson_diag_nonsym_hjj(dets_in, u_in, H_jj, energies, dim_in, sze, N_st, N_st_diag, Nint, dressing_state, converged)
|
||||
|
||||
deallocate(H_jj)
|
||||
|
||||
end subroutine davidson_diag_nonsym_h
|
||||
|
||||
! ---
|
||||
|
||||
subroutine davidson_diag_nonsym_hjj(dets_in, u_in, H_jj, energies, dim_in, sze, N_st, N_st_diag_in, Nint, dressing_state, converged)
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! non-sym Davidson diagonalization with specific diagonal elements of the H matrix
|
||||
!
|
||||
! H_jj : specific diagonal H matrix elements to diagonalize de Davidson
|
||||
!
|
||||
! dets_in : bitmasks corresponding to determinants
|
||||
!
|
||||
! u_in : guess coefficients on the various states. Overwritten on exit
|
||||
!
|
||||
! dim_in : leftmost dimension of u_in
|
||||
!
|
||||
! sze : Number of determinants
|
||||
!
|
||||
! N_st : Number of eigenstates
|
||||
!
|
||||
! N_st_diag_in : Number of states in which H is diagonalized. Assumed > sze
|
||||
!
|
||||
! Initial guess vectors are not necessarily orthonormal
|
||||
!
|
||||
END_DOC
|
||||
|
||||
include 'constants.include.F'
|
||||
|
||||
use bitmasks
|
||||
use mmap_module
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: dim_in, sze, N_st, N_st_diag_in, Nint
|
||||
integer, intent(in) :: dressing_state
|
||||
integer(bit_kind), intent(in) :: dets_in(Nint,2,sze)
|
||||
double precision, intent(in) :: H_jj(sze)
|
||||
double precision, intent(out) :: energies(N_st_diag_in)
|
||||
logical, intent(inout) :: converged
|
||||
double precision, intent(inout) :: u_in(dim_in,N_st_diag_in)
|
||||
|
||||
logical :: disk_based
|
||||
character*(16384) :: write_buffer
|
||||
integer :: i, j, k, l, m
|
||||
integer :: iter, N_st_diag, itertot, shift, shift2, itermax, istate
|
||||
integer :: nproc_target
|
||||
integer :: order(N_st_diag_in)
|
||||
integer :: maxab
|
||||
double precision :: rss
|
||||
double precision :: cmax
|
||||
double precision :: to_print(2,N_st)
|
||||
double precision :: r1, r2
|
||||
double precision :: f
|
||||
double precision, allocatable :: y(:,:), h(:,:), lambda(:)
|
||||
double precision, allocatable :: s_tmp(:,:), u_tmp(:,:)
|
||||
double precision, allocatable :: residual_norm(:)
|
||||
double precision, allocatable :: U(:,:), overlap(:,:)
|
||||
double precision, pointer :: W(:,:)
|
||||
|
||||
double precision, external :: u_dot_u
|
||||
|
||||
|
||||
N_st_diag = N_st_diag_in
|
||||
!DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: U, W, y, h, lambda
|
||||
if(N_st_diag*3 > sze) then
|
||||
print *, 'error in Davidson :'
|
||||
print *, 'Increase n_det_max_full to ', N_st_diag*3
|
||||
stop -1
|
||||
endif
|
||||
|
||||
itermax = max(2, min(davidson_sze_max, sze/N_st_diag)) + 1
|
||||
itertot = 0
|
||||
|
||||
if(state_following) then
|
||||
allocate(overlap(N_st_diag*itermax, N_st_diag*itermax))
|
||||
else
|
||||
allocate(overlap(1,1)) ! avoid 'if' for deallocate
|
||||
endif
|
||||
overlap = 0.d0
|
||||
|
||||
PROVIDE nuclear_repulsion expected_s2 psi_bilinear_matrix_order psi_bilinear_matrix_order_reverse threshold_davidson_pt2 threshold_davidson_from_pt2
|
||||
PROVIDE threshold_nonsym_davidson
|
||||
|
||||
call write_time(6)
|
||||
write(6,'(A)') ''
|
||||
write(6,'(A)') 'Davidson Diagonalization'
|
||||
write(6,'(A)') '------------------------'
|
||||
write(6,'(A)') ''
|
||||
|
||||
! Find max number of cores to fit in memory
|
||||
! -----------------------------------------
|
||||
|
||||
nproc_target = nproc
|
||||
maxab = max(N_det_alpha_unique, N_det_beta_unique) + 1
|
||||
|
||||
m=1
|
||||
disk_based = .False.
|
||||
call resident_memory(rss)
|
||||
do
|
||||
r1 = 8.d0 * &! bytes
|
||||
( dble(sze)*(N_st_diag*itermax) &! U
|
||||
+ 1.0d0*dble(sze*m)*(N_st_diag*itermax) &! W
|
||||
+ 3.0d0*(N_st_diag*itermax)**2 &! h,y,s_tmp
|
||||
+ 1.d0*(N_st_diag*itermax) &! lambda
|
||||
+ 1.d0*(N_st_diag) &! residual_norm
|
||||
! In H_u_0_nstates_zmq
|
||||
+ 2.d0*(N_st_diag*N_det) &! u_t, v_t, on collector
|
||||
+ 2.d0*(N_st_diag*N_det) &! u_t, v_t, on slave
|
||||
+ 0.5d0*maxab &! idx0 in H_u_0_nstates_openmp_work_*
|
||||
+ nproc_target * &! In OMP section
|
||||
( 1.d0*(N_int*maxab) &! buffer
|
||||
+ 3.5d0*(maxab) ) &! singles_a, singles_b, doubles, idx
|
||||
) / 1024.d0**3
|
||||
|
||||
if(nproc_target == 0) then
|
||||
call check_mem(r1, irp_here)
|
||||
nproc_target = 1
|
||||
exit
|
||||
endif
|
||||
|
||||
if(r1+rss < qp_max_mem) then
|
||||
exit
|
||||
endif
|
||||
|
||||
if(itermax > 4) then
|
||||
itermax = itermax - 1
|
||||
else if(m==1 .and. disk_based_davidson) then
|
||||
m = 0
|
||||
disk_based = .True.
|
||||
itermax = 6
|
||||
else
|
||||
nproc_target = nproc_target - 1
|
||||
endif
|
||||
|
||||
enddo
|
||||
|
||||
nthreads_davidson = nproc_target
|
||||
TOUCH nthreads_davidson
|
||||
|
||||
call write_int(6, N_st, 'Number of states')
|
||||
call write_int(6, N_st_diag, 'Number of states in diagonalization')
|
||||
call write_int(6, sze, 'Number of determinants')
|
||||
call write_int(6, nproc_target, 'Number of threads for diagonalization')
|
||||
call write_double(6, r1, 'Memory(Gb)')
|
||||
if(disk_based) then
|
||||
print *, 'Using swap space to reduce RAM'
|
||||
endif
|
||||
|
||||
!---------------
|
||||
|
||||
write(6,'(A)') ''
|
||||
write_buffer = '====='
|
||||
do i = 1, N_st
|
||||
write_buffer = trim(write_buffer)//' ================ ==========='
|
||||
enddo
|
||||
write(6, '(A)') write_buffer(1:6+41*N_st)
|
||||
write_buffer = 'Iter'
|
||||
do i = 1, N_st
|
||||
write_buffer = trim(write_buffer)//' Energy Residual '
|
||||
enddo
|
||||
write(6,'(A)') write_buffer(1:6+41*N_st)
|
||||
write_buffer = '====='
|
||||
do i = 1, N_st
|
||||
write_buffer = trim(write_buffer)//' ================ ==========='
|
||||
enddo
|
||||
write(6,'(A)') write_buffer(1:6+41*N_st)
|
||||
|
||||
|
||||
if(disk_based) then
|
||||
! Create memory-mapped files for W and S
|
||||
type(c_ptr) :: ptr_w, ptr_s
|
||||
integer :: fd_s, fd_w
|
||||
call mmap(trim(ezfio_work_dir)//'davidson_w', (/int(sze,8),int(N_st_diag*itermax,8)/),&
|
||||
8, fd_w, .False., ptr_w)
|
||||
call c_f_pointer(ptr_w, w, (/sze,N_st_diag*itermax/))
|
||||
else
|
||||
allocate(W(sze,N_st_diag*itermax))
|
||||
endif
|
||||
|
||||
allocate( &
|
||||
! Large
|
||||
U(sze,N_st_diag*itermax), &
|
||||
! Small
|
||||
h(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
y(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
s_tmp(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
residual_norm(N_st_diag), &
|
||||
lambda(N_st_diag*itermax), &
|
||||
u_tmp(N_st,N_st_diag))
|
||||
|
||||
h = 0.d0
|
||||
U = 0.d0
|
||||
y = 0.d0
|
||||
s_tmp = 0.d0
|
||||
|
||||
|
||||
ASSERT (N_st > 0)
|
||||
ASSERT (N_st_diag >= N_st)
|
||||
ASSERT (sze > 0)
|
||||
ASSERT (Nint > 0)
|
||||
ASSERT (Nint == N_int)
|
||||
|
||||
! Davidson iterations
|
||||
! ===================
|
||||
|
||||
converged = .False.
|
||||
|
||||
do k = N_st+1, N_st_diag
|
||||
do i = 1, sze
|
||||
call random_number(r1)
|
||||
call random_number(r2)
|
||||
r1 = dsqrt(-2.d0*dlog(r1))
|
||||
r2 = dtwo_pi*r2
|
||||
u_in(i,k) = r1*dcos(r2) * u_in(i,k-N_st)
|
||||
enddo
|
||||
u_in(k,k) = u_in(k,k) + 10.d0
|
||||
enddo
|
||||
do k = 1, N_st_diag
|
||||
call normalize(u_in(1,k), sze)
|
||||
enddo
|
||||
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
do while (.not.converged)
|
||||
itertot = itertot + 1
|
||||
if(itertot == 8) then
|
||||
exit
|
||||
endif
|
||||
|
||||
do iter = 1, itermax-1
|
||||
|
||||
shift = N_st_diag*(iter-1)
|
||||
shift2 = N_st_diag*iter
|
||||
|
||||
! if( (iter > 1) .or. (itertot == 1) ) then
|
||||
|
||||
! Gram-Schmidt to orthogonalize all new guess with the previous vectors
|
||||
call ortho_qr(U, size(U, 1), sze, shift2)
|
||||
call ortho_qr(U, size(U, 1), sze, shift2)
|
||||
|
||||
! Compute |W_k> = \sum_i |i><i|H|u_k>
|
||||
! -----------------------------------
|
||||
|
||||
if( (sze > 100000) .and. distributed_davidson ) then
|
||||
call H_u_0_nstates_zmq (W(1,shift+1), U(1,shift+1), N_st_diag, sze)
|
||||
else
|
||||
call H_u_0_nstates_openmp(W(1,shift+1), U(1,shift+1), N_st_diag, sze)
|
||||
endif
|
||||
! else
|
||||
! ! Already computed in update below
|
||||
! continue
|
||||
! endif
|
||||
|
||||
if(dressing_state > 0) then
|
||||
|
||||
call dgemm( 'T', 'N', N_st, N_st_diag, sze, 1.d0 &
|
||||
, psi_coef, size(psi_coef, 1), U(1, shift+1), size(U, 1) &
|
||||
, 0.d0, u_tmp, size(u_tmp, 1))
|
||||
|
||||
do istate = 1, N_st_diag
|
||||
do k = 1, N_st
|
||||
do l = 1, N_st
|
||||
f = overlap_states_inv(k,l)
|
||||
do i = 1, sze
|
||||
W(i,shift+istate) += f * dressing_delta(i,k) * u_tmp(l,istate)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
endif
|
||||
|
||||
! Compute h_kl = <u_k | W_l> = <u_k| H |u_l>
|
||||
! -------------------------------------------
|
||||
|
||||
call dgemm( 'T', 'N', shift2, shift2, sze, 1.d0 &
|
||||
, U, size(U, 1), W, size(W, 1) &
|
||||
, 0.d0, h, size(h, 1))
|
||||
|
||||
! Diagonalize h
|
||||
! ---------------
|
||||
call diag_nonsym_right(shift2, h(1,1), size(h, 1), y(1,1), size(y, 1), lambda(1), size(lambda, 1))
|
||||
|
||||
|
||||
if (state_following) then
|
||||
|
||||
overlap = -1.d0
|
||||
do k = 1, shift2
|
||||
do i = 1, shift2
|
||||
overlap(k,i) = dabs(y(k,i))
|
||||
enddo
|
||||
enddo
|
||||
do k = 1, N_st
|
||||
cmax = -1.d0
|
||||
do i = 1, N_st
|
||||
if(overlap(i,k) > cmax) then
|
||||
cmax = overlap(i,k)
|
||||
order(k) = i
|
||||
endif
|
||||
enddo
|
||||
do i = 1, N_st_diag
|
||||
overlap(order(k),i) = -1.d0
|
||||
enddo
|
||||
enddo
|
||||
overlap = y
|
||||
do k = 1, N_st
|
||||
l = order(k)
|
||||
if (k /= l) then
|
||||
y(1:shift2,k) = overlap(1:shift2,l)
|
||||
endif
|
||||
enddo
|
||||
do k = 1, N_st
|
||||
overlap(k,1) = lambda(k)
|
||||
enddo
|
||||
|
||||
endif
|
||||
|
||||
! Express eigenvectors of h in the determinant basis
|
||||
! --------------------------------------------------
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, U, size(U, 1), y, size(y, 1) &
|
||||
, 0.d0, U(1,shift2+1), size(U, 1))
|
||||
|
||||
do k = 1, N_st_diag
|
||||
call normalize(U(1,shift2+k), sze)
|
||||
enddo
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, W, size(W, 1), y, size(y, 1) &
|
||||
, 0.d0, W(1,shift2+1), size(W,1))
|
||||
|
||||
! Compute residual vector and davidson step
|
||||
! -----------------------------------------
|
||||
|
||||
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k)
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,shift2+k) = (lambda(k) * U(i,shift2+k) - W(i,shift2+k)) / max(H_jj(i)-lambda(k), 1.d-2)
|
||||
enddo
|
||||
|
||||
if(k <= N_st) then
|
||||
residual_norm(k) = u_dot_u(U(1,shift2+k), sze)
|
||||
to_print(1,k) = lambda(k) + nuclear_repulsion
|
||||
to_print(2,k) = residual_norm(k)
|
||||
endif
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
if((itertot>1).and.(iter == 1)) then
|
||||
!don't print
|
||||
continue
|
||||
else
|
||||
write(*, '(1X, I3, 1X, 100(1X, F16.10, 1X, E11.3))') iter-1, to_print(1:2,1:N_st)
|
||||
endif
|
||||
|
||||
! Check convergence
|
||||
if(iter > 1) then
|
||||
if(threshold_davidson_from_pt2) then
|
||||
converged = dabs(maxval(residual_norm(1:N_st))) < threshold_davidson_pt2
|
||||
else
|
||||
converged = dabs(maxval(residual_norm(1:N_st))) < threshold_nonsym_davidson
|
||||
endif
|
||||
endif
|
||||
|
||||
do k = 1, N_st
|
||||
if(residual_norm(k) > 1.d8) then
|
||||
print *, 'Davidson failed'
|
||||
stop -1
|
||||
endif
|
||||
enddo
|
||||
if(converged) then
|
||||
exit
|
||||
endif
|
||||
|
||||
logical, external :: qp_stop
|
||||
if(qp_stop()) then
|
||||
converged = .True.
|
||||
exit
|
||||
endif
|
||||
|
||||
|
||||
enddo
|
||||
|
||||
! Re-contract U and update W
|
||||
! --------------------------------
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, W, size(W, 1), y, size(y, 1) &
|
||||
, 0.d0, u_in, size(u_in, 1))
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
W(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, U, size(U, 1), y, size(y, 1), 0.d0 &
|
||||
, u_in, size(u_in, 1))
|
||||
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
|
||||
call nullify_small_elements(sze, N_st_diag, U, size(U, 1), threshold_davidson_pt2)
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
u_in(i,k) = U(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do k = 1, N_st_diag
|
||||
energies(k) = lambda(k)
|
||||
enddo
|
||||
write_buffer = '======'
|
||||
do i = 1, N_st
|
||||
write_buffer = trim(write_buffer)//' ================ ==========='
|
||||
enddo
|
||||
write(6,'(A)') trim(write_buffer)
|
||||
write(6,'(A)') ''
|
||||
call write_time(6)
|
||||
|
||||
if(disk_based) then
|
||||
! Remove temp files
|
||||
integer, external :: getUnitAndOpen
|
||||
call munmap( (/int(sze,8),int(N_st_diag*itermax,8)/), 8, fd_w, ptr_w )
|
||||
fd_w = getUnitAndOpen(trim(ezfio_work_dir)//'davidson_w','r')
|
||||
close(fd_w,status='delete')
|
||||
else
|
||||
deallocate(W)
|
||||
endif
|
||||
|
||||
deallocate ( &
|
||||
residual_norm, &
|
||||
U, overlap, &
|
||||
h, y, s_tmp, &
|
||||
lambda, &
|
||||
u_tmp &
|
||||
)
|
||||
FREE nthreads_davidson
|
||||
|
||||
end subroutine davidson_diag_nonsym_hjj
|
||||
|
||||
! ---
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
40
src/davidson/overlap_states.irp.f
Normal file
40
src/davidson/overlap_states.irp.f
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, overlap_states, (N_states,N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, overlap_states_inv, (N_states,N_states) ]
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! S_kl = ck.T x cl
|
||||
! = psi_coef(:,k).T x psi_coef(:,l)
|
||||
!
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i
|
||||
double precision :: o_tmp
|
||||
|
||||
if(N_states == 1) then
|
||||
|
||||
o_tmp = 0.d0
|
||||
do i = 1, N_det
|
||||
o_tmp = o_tmp + psi_coef(i,1) * psi_coef(i,1)
|
||||
enddo
|
||||
overlap_states (1,1) = o_tmp
|
||||
overlap_states_inv(1,1) = 1.d0 / o_tmp
|
||||
|
||||
else
|
||||
|
||||
call dgemm( 'T', 'N', N_states, N_states, N_det, 1.d0 &
|
||||
, psi_coef, size(psi_coef, 1), psi_coef, size(psi_coef, 1) &
|
||||
, 0.d0, overlap_states, size(overlap_states, 1) )
|
||||
|
||||
call get_inverse(overlap_states, N_states, N_states, overlap_states_inv, N_states)
|
||||
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
188
src/davidson_dressed/nonsym_diagonalize_ci.irp.f
Normal file
188
src/davidson_dressed/nonsym_diagonalize_ci.irp.f
Normal file
@ -0,0 +1,188 @@
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, CI_energy_nonsym_dressed, (N_states_diag) ]
|
||||
|
||||
BEGIN_DOC
|
||||
! N_states lowest eigenvalues of the CI matrix
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: j
|
||||
character*(8) :: st
|
||||
|
||||
call write_time(6)
|
||||
do j = 1, min(N_det, N_states_diag)
|
||||
CI_energy_nonsym_dressed(j) = CI_electronic_energy_nonsym_dressed(j) + nuclear_repulsion
|
||||
enddo
|
||||
|
||||
do j = 1, min(N_det, N_states)
|
||||
write(st, '(I4)') j
|
||||
call write_double(6, CI_energy_nonsym_dressed(j), 'Energy of state '//trim(st))
|
||||
enddo
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, CI_electronic_energy_nonsym_dressed, (N_states_diag) ]
|
||||
&BEGIN_PROVIDER [ double precision, CI_eigenvectors_nonsym_dressed, (N_det,N_states_diag) ]
|
||||
|
||||
BEGIN_DOC
|
||||
! Eigenvectors/values of the CI matrix
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
logical :: converged
|
||||
integer :: i, j, k
|
||||
integer :: i_other_state
|
||||
integer :: i_state
|
||||
logical, allocatable :: good_state_array(:)
|
||||
integer, allocatable :: index_good_state_array(:)
|
||||
double precision, allocatable :: eigenvectors(:,:), eigenvalues(:)
|
||||
|
||||
PROVIDE threshold_nonsym_davidson nthreads_davidson
|
||||
|
||||
! Guess values for the "N_states" states of the CI_eigenvectors_nonsym_dressed
|
||||
do j = 1, min(N_states, N_det)
|
||||
do i = 1, N_det
|
||||
CI_eigenvectors_nonsym_dressed(i,j) = psi_coef(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
do j = min(N_states, N_det)+1, N_states_diag
|
||||
do i = 1, N_det
|
||||
CI_eigenvectors_nonsym_dressed(i,j) = 0.d0
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! ---
|
||||
|
||||
if(diag_algorithm == "Davidson") then
|
||||
|
||||
ASSERT(n_states_diag .lt. n_states)
|
||||
|
||||
do j = 1, min(N_states, N_det)
|
||||
do i = 1, N_det
|
||||
CI_eigenvectors_nonsym_dressed(i,j) = psi_coef(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
converged = .False.
|
||||
call davidson_diag_nonsym_h( psi_det, CI_eigenvectors_nonsym_dressed &
|
||||
, size(CI_eigenvectors_nonsym_dressed, 1) &
|
||||
, CI_electronic_energy_nonsym_dressed &
|
||||
, N_det, min(N_det, N_states), min(N_det, N_states_diag), N_int, 1, converged )
|
||||
|
||||
else if(diag_algorithm == "Lapack") then
|
||||
|
||||
allocate(eigenvectors(size(H_matrix_nonsym_dressed, 1),N_det))
|
||||
allocate(eigenvalues(N_det))
|
||||
|
||||
call diag_nonsym_right( N_det, H_matrix_nonsym_dressed, size(H_matrix_nonsym_dressed, 1) &
|
||||
, eigenvectors, size(eigenvectors, 1), eigenvalues, size(eigenvalues, 1) )
|
||||
|
||||
CI_electronic_energy_nonsym_dressed(:) = 0.d0
|
||||
|
||||
! Select the "N_states_diag" states of lowest energy
|
||||
do j = 1, min(N_det, N_states_diag)
|
||||
do i = 1, N_det
|
||||
CI_eigenvectors_nonsym_dressed(i,j) = eigenvectors(i,j)
|
||||
enddo
|
||||
CI_electronic_energy_nonsym_dressed(j) = eigenvalues(j)
|
||||
enddo
|
||||
|
||||
deallocate(eigenvectors, eigenvalues)
|
||||
|
||||
! --- ---
|
||||
|
||||
endif
|
||||
|
||||
! ---
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
subroutine diagonalize_CI_nonsym_dressed()
|
||||
|
||||
BEGIN_DOC
|
||||
! Replace the coefficients of the CI states by the coefficients of the
|
||||
! eigenstates of the CI matrix
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j
|
||||
|
||||
PROVIDE dressing_delta
|
||||
|
||||
do j = 1, N_states
|
||||
do i = 1, N_det
|
||||
psi_coef(i,j) = CI_eigenvectors_nonsym_dressed(i,j)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
SOFT_TOUCH psi_coef
|
||||
|
||||
end subroutine diagonalize_CI_nonsym_dressed
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, H_matrix_nonsym_dressed, (N_det,N_det) ]
|
||||
|
||||
BEGIN_DOC
|
||||
! Dressed H with Delta_ij
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, j, l, k
|
||||
double precision :: f
|
||||
|
||||
H_matrix_nonsym_dressed(1:N_det,1:N_det) = h_matrix_all_dets(1:N_det,1:N_det)
|
||||
|
||||
if(N_states == 1) then
|
||||
|
||||
! !symmetric formula
|
||||
! l = dressed_column_idx(1)
|
||||
! f = 1.0d0/psi_coef(l,1)
|
||||
! do i=1,N_det
|
||||
! h_matrix_nonsym_dressed(i,l) += dressing_column_h(i,1) *f
|
||||
! h_matrix_nonsym_dressed(l,i) += dressing_column_h(i,1) *f
|
||||
! enddo
|
||||
|
||||
! l = dressed_column_idx(1)
|
||||
! f = 1.0d0 / psi_coef(l,1)
|
||||
! do j = 1, N_det
|
||||
! H_matrix_nonsym_dressed(j,l) += f * dressing_delta(j,1)
|
||||
! enddo
|
||||
|
||||
k = 1
|
||||
l = 1
|
||||
f = overlap_states_inv(k,l)
|
||||
do j = 1, N_det
|
||||
do i = 1, N_det
|
||||
H_matrix_nonsym_dressed(i,j) = H_matrix_nonsym_dressed(i,j) + f * dressing_delta(i,k) * psi_coef(j,l)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
else
|
||||
|
||||
do k = 1, N_states
|
||||
do l = 1, N_states
|
||||
f = overlap_states_inv(k,l)
|
||||
|
||||
do j = 1, N_det
|
||||
do i = 1, N_det
|
||||
H_matrix_nonsym_dressed(i,j) = H_matrix_nonsym_dressed(i,j) + f * dressing_delta(i,k) * psi_coef(j,l)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
enddo
|
||||
enddo
|
||||
|
||||
endif
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
54
src/davidson_keywords/EZFIO.cfg
Normal file
54
src/davidson_keywords/EZFIO.cfg
Normal file
@ -0,0 +1,54 @@
|
||||
[threshold_davidson]
|
||||
type: Threshold
|
||||
doc: Thresholds of Davidson's algorithm if threshold_davidson_from_pt2 is false.
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-10
|
||||
|
||||
[threshold_nonsym_davidson]
|
||||
type: Threshold
|
||||
doc: Thresholds of non-symetric Davidson's algorithm
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-10
|
||||
|
||||
[davidson_sze_max]
|
||||
type: Strictly_positive_int
|
||||
doc: Number of micro-iterations before re-contracting
|
||||
default: 15
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[state_following]
|
||||
type: logical
|
||||
doc: If |true|, the states are re-ordered to match the input states
|
||||
default: False
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[disk_based_davidson]
|
||||
type: logical
|
||||
doc: If |true|, a memory-mapped file may be used to store the W and S2 vectors if not enough RAM is availabl
|
||||
default: True
|
||||
interface: ezfio,provider,ocaml
|
||||
|
||||
[n_states_diag]
|
||||
type: States_number
|
||||
doc: Controls the number of states to consider during the Davdison diagonalization. The number of states is n_states * n_states_diag
|
||||
default: 4
|
||||
interface: ezfio,ocaml
|
||||
|
||||
[n_det_max_full]
|
||||
type: Det_number_max
|
||||
doc: Maximum number of determinants where |H| is fully diagonalized
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1000
|
||||
|
||||
[threshold_davidson_from_pt2]
|
||||
type: logical
|
||||
doc: Thresholds of Davidson's algorithm is set to E(rPT2)*threshold_davidson_from_pt2
|
||||
interface: ezfio,provider,ocaml
|
||||
default: false
|
||||
|
||||
[distributed_davidson]
|
||||
type: logical
|
||||
doc: If |true|, use the distributed algorithm
|
||||
default: True
|
||||
interface: ezfio,provider,ocaml
|
||||
|
1
src/davidson_keywords/NEED
Normal file
1
src/davidson_keywords/NEED
Normal file
@ -0,0 +1 @@
|
||||
ezfio_files
|
5
src/davidson_keywords/README.rst
Normal file
5
src/davidson_keywords/README.rst
Normal file
@ -0,0 +1,5 @@
|
||||
=================
|
||||
davidson_keywords
|
||||
=================
|
||||
|
||||
Keywords used for Davidson algorithms.
|
@ -1,3 +1,6 @@
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ integer, n_states_diag ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
@ -8,11 +11,11 @@ BEGIN_PROVIDER [ integer, n_states_diag ]
|
||||
PROVIDE ezfio_filename
|
||||
if (mpi_master) then
|
||||
|
||||
call ezfio_has_davidson_n_states_diag(has)
|
||||
call ezfio_has_davidson_keywords_n_states_diag(has)
|
||||
if (has) then
|
||||
call ezfio_get_davidson_n_states_diag(n_states_diag)
|
||||
call ezfio_get_davidson_keywords_n_states_diag(n_states_diag)
|
||||
else
|
||||
print *, 'davidson/n_states_diag not found in EZFIO file'
|
||||
print *, 'davidson_keywords/n_states_diag not found in EZFIO file'
|
||||
stop 1
|
||||
endif
|
||||
n_states_diag = max(2,N_states * N_states_diag)
|
||||
@ -32,3 +35,4 @@ BEGIN_PROVIDER [ integer, n_states_diag ]
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
33
src/davidson_keywords/usef.irp.f
Normal file
33
src/davidson_keywords/usef.irp.f
Normal file
@ -0,0 +1,33 @@
|
||||
use bitmasks
|
||||
use f77_zmq
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ integer, nthreads_davidson ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Number of threads for Davidson
|
||||
END_DOC
|
||||
nthreads_davidson = nproc
|
||||
character*(32) :: env
|
||||
call getenv('QP_NTHREADS_DAVIDSON',env)
|
||||
if (trim(env) /= '') then
|
||||
read(env,*) nthreads_davidson
|
||||
call write_int(6,nthreads_davidson,'Target number of threads for <Psi|H|Psi>')
|
||||
endif
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, threshold_davidson_pt2 ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Threshold of Davidson's algorithm, using PT2 as a guide
|
||||
END_DOC
|
||||
threshold_davidson_pt2 = threshold_davidson
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -1,10 +1,12 @@
|
||||
BEGIN_PROVIDER [ double precision, dressing_column_h, (N_det,N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, dressing_column_s, (N_det,N_states) ]
|
||||
&BEGIN_PROVIDER [ double precision, dressing_delta , (N_det,N_states) ]
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Null dressing vectors
|
||||
END_DOC
|
||||
dressing_column_h(:,:) = 0.d0
|
||||
dressing_column_s(:,:) = 0.d0
|
||||
dressing_delta (:,:) = 0.d0
|
||||
END_PROVIDER
|
||||
|
||||
|
@ -9,8 +9,11 @@ spindeterminants
|
||||
psi_det_beta integer*8 (spindeterminants_n_int*spindeterminants_bit_kind/8,spindeterminants_n_det_beta)
|
||||
psi_coef_matrix_rows integer (spindeterminants_n_det)
|
||||
psi_coef_matrix_columns integer (spindeterminants_n_det)
|
||||
psi_coef_matrix_values double precision (spindeterminants_n_det,spindeterminants_n_states)
|
||||
psi_coef_matrix_values double precision (spindeterminants_n_det,spindeterminants_n_states)
|
||||
psi_left_coef_matrix_values double precision (spindeterminants_n_det,spindeterminants_n_states)
|
||||
n_svd_coefs integer
|
||||
n_svd_alpha integer
|
||||
n_svd_beta integer
|
||||
psi_svd_alpha double precision (spindeterminants_n_det_alpha,spindeterminants_n_svd_coefs,spindeterminants_n_states)
|
||||
psi_svd_beta double precision (spindeterminants_n_det_beta,spindeterminants_n_svd_coefs,spindeterminants_n_states)
|
||||
psi_svd_coefs double precision (spindeterminants_n_svd_coefs,spindeterminants_n_states)
|
||||
|
30
src/kohn_sham/print_mos.irp.f
Normal file
30
src/kohn_sham/print_mos.irp.f
Normal file
@ -0,0 +1,30 @@
|
||||
program print_mos
|
||||
implicit none
|
||||
integer :: i,nx
|
||||
double precision :: r(3), xmax, dx, accu
|
||||
double precision, allocatable :: mos_array(:)
|
||||
double precision:: alpha,envelop
|
||||
allocate(mos_array(mo_num))
|
||||
xmax = 5.d0
|
||||
nx = 1000
|
||||
dx=xmax/dble(nx)
|
||||
r = 0.d0
|
||||
alpha = 0.5d0
|
||||
do i = 1, nx
|
||||
call give_all_mos_at_r(r,mos_array)
|
||||
accu = mos_array(3)**2+mos_array(4)**2+mos_array(5)**2
|
||||
accu = dsqrt(accu)
|
||||
envelop = (1.d0 - dexp(-alpha * r(3)**2))
|
||||
write(33,'(100(F16.10,X))')r(3), mos_array(1), mos_array(2), accu, envelop
|
||||
r(3) += dx
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
double precision function f_mu(x)
|
||||
implicit none
|
||||
double precision, intent(in) :: x
|
||||
|
||||
|
||||
|
||||
end
|
@ -2,7 +2,7 @@
|
||||
! ---
|
||||
|
||||
! TODO : strong optmization : write the loops in a different way
|
||||
! : for each couple of AO, the gaussian product are done once for all
|
||||
! : for each couple of AO, the gaussian product are done once for all
|
||||
|
||||
BEGIN_PROVIDER [ double precision, gradu_squared_u_ij_mu, (ao_num, ao_num, n_points_final_grid) ]
|
||||
|
||||
@ -20,14 +20,14 @@ BEGIN_PROVIDER [ double precision, gradu_squared_u_ij_mu, (ao_num, ao_num, n_poi
|
||||
! gradu_squared_u_ij_mu = -0.50 x \int r2 \phi_i(2) \phi_j(2) [ v1^2 v2^2 ((grad_1 u12)^2 + (grad_2 u12^2)]) + u12^2 v2^2 (grad_1 v1)^2 + 2 u12 v1 v2^2 (grad_1 u12) . (grad_1 v1) ]
|
||||
! = -0.25 x v1^2 \int r2 \phi_i(2) \phi_j(2) [1 - erf(mu r12)]^2 v2^2
|
||||
! + -0.50 x (grad_1 v1)^2 \int r2 \phi_i(2) \phi_j(2) u12^2 v2^2
|
||||
! + -1.00 x v1 (grad_1 v1) \int r2 \phi_i(2) \phi_j(2) (grad_1 u12) v2^2
|
||||
! + -1.00 x v1 (grad_1 v1) \int r2 \phi_i(2) \phi_j(2) (grad_1 u12) v2^2
|
||||
! = v1^2 x int2_grad1u2_grad2u2_j1b2
|
||||
! + -0.5 x (grad_1 v1)^2 x int2_u2_j1b2
|
||||
! + -1.0 X V1 x (grad_1 v1) \cdot [ int2_u_grad1u_j1b2 x r - int2_u_grad1u_x_j1b ]
|
||||
!
|
||||
!
|
||||
END_DOC
|
||||
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, igauss
|
||||
double precision :: x, y, z, r(3), delta, coef
|
||||
@ -100,7 +100,7 @@ BEGIN_PROVIDER [ double precision, gradu_squared_u_ij_mu, (ao_num, ao_num, n_poi
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for gradu_squared_u_ij_mu = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -151,7 +151,7 @@ END_PROVIDER
|
||||
!
|
||||
! deallocate(ac_mat)
|
||||
!
|
||||
!END_PROVIDER
|
||||
!END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -214,12 +214,12 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_loop, (ao_num, ao_num, ao_nu
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for tc_grad_square_ao_loop = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, grad12_j12, (ao_num, ao_num, n_points_final_grid) ]
|
||||
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, igauss
|
||||
double precision :: r(3), delta, coef
|
||||
@ -267,7 +267,7 @@ BEGIN_PROVIDER [ double precision, grad12_j12, (ao_num, ao_num, n_points_final_g
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for grad12_j12 = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -297,12 +297,12 @@ BEGIN_PROVIDER [ double precision, u12sq_j1bsq, (ao_num, ao_num, n_points_final_
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for u12sq_j1bsq = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, u12_grad1_u12_j1b_grad1_j1b, (ao_num, ao_num, n_points_final_grid) ]
|
||||
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, igauss
|
||||
double precision :: x, y, z
|
||||
@ -347,7 +347,7 @@ BEGIN_PROVIDER [ double precision, u12_grad1_u12_j1b_grad1_j1b, (ao_num, ao_num,
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for u12_grad1_u12_j1b_grad1_j1b = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -370,26 +370,18 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao, (ao_num, ao_num, ao_num, ao
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='tc_grad_square_ao', action="read")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
read(11) tc_grad_square_ao(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_square_ao', action="read")
|
||||
read(11) tc_grad_square_ao
|
||||
close(11)
|
||||
|
||||
else
|
||||
|
||||
allocate(b_mat(n_points_final_grid,ao_num,ao_num), tmp(ao_num,ao_num,n_points_final_grid))
|
||||
|
||||
|
||||
b_mat = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, b_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
@ -401,11 +393,11 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao, (ao_num, ao_num, ao_num, ao
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
tmp = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP SHARED (tmp, ao_num, n_points_final_grid, u12sq_j1bsq, u12_grad1_u12_j1b_grad1_j1b, grad12_j12)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -417,25 +409,25 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao, (ao_num, ao_num, ao_num, ao
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
tc_grad_square_ao = 0.d0
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, tmp(1,1,1), ao_num*ao_num, b_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, tc_grad_square_ao, ao_num*ao_num)
|
||||
deallocate(tmp, b_mat)
|
||||
|
||||
|
||||
call sum_A_At(tc_grad_square_ao(1,1,1,1), ao_num*ao_num)
|
||||
|
||||
|
||||
!!$OMP PARALLEL &
|
||||
!!$OMP DEFAULT (NONE) &
|
||||
!!$OMP PRIVATE (i, j, k, l) &
|
||||
!!$OMP PRIVATE (i, j, k, l) &
|
||||
!!$OMP SHARED (ac_mat, tc_grad_square_ao, ao_num)
|
||||
!!$OMP DO SCHEDULE (static)
|
||||
! do j = 1, ao_num
|
||||
! do l = 1, ao_num
|
||||
! do i = 1, ao_num
|
||||
! do k = 1, ao_num
|
||||
! tc_grad_square_ao(k,i,l,j) = ac_mat(k,i,l,j) + ac_mat(l,j,k,i)
|
||||
! tc_grad_square_ao(k,i,l,j) = ac_mat(k,i,l,j) + ac_mat(l,j,k,i)
|
||||
! enddo
|
||||
! enddo
|
||||
! enddo
|
||||
@ -444,23 +436,17 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao, (ao_num, ao_num, ao_num, ao
|
||||
!!$OMP END PARALLEL
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='tc_grad_square_ao', action="write")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
write(11) tc_grad_square_ao(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_square_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) tc_grad_square_ao
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for tc_grad_square_ao = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -17,29 +17,21 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
call wall_time(time0)
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='tc_grad_square_ao_test', action="read")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
read(11) tc_grad_square_ao_test(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_square_ao_test', action="read")
|
||||
read(11) tc_grad_square_ao_test
|
||||
close(11)
|
||||
|
||||
else
|
||||
|
||||
provide u12sq_j1bsq_test u12_grad1_u12_j1b_grad1_j1b_test grad12_j12_test
|
||||
|
||||
|
||||
allocate(b_mat(n_points_final_grid,ao_num,ao_num), tmp(ao_num,ao_num,n_points_final_grid))
|
||||
|
||||
|
||||
b_mat = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, b_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
@ -51,11 +43,11 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
tmp = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP SHARED (tmp, ao_num, n_points_final_grid, u12sq_j1bsq_test, u12_grad1_u12_j1b_grad1_j1b_test, grad12_j12_test)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -67,23 +59,23 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
tc_grad_square_ao_test = 0.d0
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, tmp(1,1,1), ao_num*ao_num, b_mat(1,1,1), n_points_final_grid &
|
||||
, 1.d0, tc_grad_square_ao_test, ao_num*ao_num)
|
||||
deallocate(tmp, b_mat)
|
||||
|
||||
|
||||
call sum_A_At(tc_grad_square_ao_test(1,1,1,1), ao_num*ao_num)
|
||||
!do i = 1, ao_num
|
||||
! do j = 1, ao_num
|
||||
! do k = i, ao_num
|
||||
|
||||
|
||||
! do l = max(j,k), ao_num
|
||||
! tc_grad_square_ao_test(i,j,k,l) = 0.5d0 * (tc_grad_square_ao_test(i,j,k,l) + tc_grad_square_ao_test(k,l,i,j))
|
||||
! tc_grad_square_ao_test(k,l,i,j) = tc_grad_square_ao_test(i,j,k,l)
|
||||
! end do
|
||||
|
||||
|
||||
! !if (j.eq.k) then
|
||||
! ! do l = j+1, ao_num
|
||||
! ! tc_grad_square_ao_test(i,j,k,l) = 0.5d0 * (tc_grad_square_ao_test(i,j,k,l) + tc_grad_square_ao_test(k,l,i,j))
|
||||
@ -95,14 +87,14 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
! ! tc_grad_square_ao_test(k,l,i,j) = tc_grad_square_ao_test(i,j,k,l)
|
||||
! ! enddo
|
||||
! !endif
|
||||
|
||||
|
||||
! enddo
|
||||
! enddo
|
||||
!enddo
|
||||
!tc_grad_square_ao_test = 2.d0 * tc_grad_square_ao_test
|
||||
! !$OMP PARALLEL &
|
||||
! !$OMP DEFAULT (NONE) &
|
||||
! !$OMP PRIVATE (i, j, k, l) &
|
||||
! !$OMP PRIVATE (i, j, k, l) &
|
||||
! !$OMP SHARED (tc_grad_square_ao_test, ao_num)
|
||||
! !$OMP DO SCHEDULE (static)
|
||||
! integer :: ii
|
||||
@ -121,10 +113,10 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
! print *, ' ii =', ii
|
||||
! !$OMP END DO
|
||||
! !$OMP END PARALLEL
|
||||
|
||||
|
||||
! !$OMP PARALLEL &
|
||||
! !$OMP DEFAULT (NONE) &
|
||||
! !$OMP PRIVATE (i, j, k, l) &
|
||||
! !$OMP PRIVATE (i, j, k, l) &
|
||||
! !$OMP SHARED (tc_grad_square_ao_test, ao_num)
|
||||
! !$OMP DO SCHEDULE (static)
|
||||
! do j = 1, ao_num
|
||||
@ -144,24 +136,18 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test, (ao_num, ao_num, ao_nu
|
||||
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='tc_grad_square_ao_test', action="write")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
write(11) tc_grad_square_ao_test(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_square_ao_test', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) tc_grad_square_ao_test
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for tc_grad_square_ao_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -189,7 +175,7 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test_ref, (ao_num, ao_num, a
|
||||
b_mat = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP PRIVATE (i, k, ipoint) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, b_mat, ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
@ -205,7 +191,7 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test_ref, (ao_num, ao_num, a
|
||||
tmp = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP PRIVATE (j, l, ipoint) &
|
||||
!$OMP SHARED (tmp, ao_num, n_points_final_grid, u12sq_j1bsq_test, u12_grad1_u12_j1b_grad1_j1b_test, grad12_j12_test)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do ipoint = 1, n_points_final_grid
|
||||
@ -226,7 +212,7 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test_ref, (ao_num, ao_num, a
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, k, l) &
|
||||
!$OMP PRIVATE (i, j, k, l) &
|
||||
!$OMP SHARED (ac_mat, tc_grad_square_ao_test_ref, ao_num)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do j = 1, ao_num
|
||||
@ -246,7 +232,7 @@ BEGIN_PROVIDER [double precision, tc_grad_square_ao_test_ref, (ao_num, ao_num, a
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for tc_grad_square_ao_test_ref = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -276,12 +262,12 @@ BEGIN_PROVIDER [ double precision, u12sq_j1bsq_test, (ao_num, ao_num, n_points_f
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for u12sq_j1bsq_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, u12_grad1_u12_j1b_grad1_j1b_test, (ao_num, ao_num, n_points_final_grid) ]
|
||||
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, igauss
|
||||
double precision :: x, y, z
|
||||
@ -328,12 +314,12 @@ BEGIN_PROVIDER [ double precision, u12_grad1_u12_j1b_grad1_j1b_test, (ao_num, ao
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for u12_grad1_u12_j1b_grad1_j1b_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
BEGIN_PROVIDER [ double precision, grad12_j12_test, (ao_num, ao_num, n_points_final_grid) ]
|
||||
|
||||
|
||||
implicit none
|
||||
integer :: ipoint, i, j, m, igauss
|
||||
double precision :: r(3), delta, coef
|
||||
@ -381,7 +367,7 @@ BEGIN_PROVIDER [ double precision, grad12_j12_test, (ao_num, ao_num, n_points_fi
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for grad12_j12_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
|
@ -36,16 +36,8 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao, (ao_num, ao_num, n_points_
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='int2_grad1_u12_ao', action="read")
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
read(11) int2_grad1_u12_ao(i,j,ipoint,m)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="read")
|
||||
read(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
|
||||
else
|
||||
@ -89,18 +81,12 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao, (ao_num, ao_num, n_points_
|
||||
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='int2_grad1_u12_ao', action="write")
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
write(11) int2_grad1_u12_ao(i,j,ipoint,m)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
@ -319,16 +305,8 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao, (ao_num, ao_num, ao_num,
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='tc_grad_and_lapl_ao', action="read")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
read(11) tc_grad_and_lapl_ao(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao', action="read")
|
||||
read(11) tc_grad_and_lapl_ao
|
||||
close(11)
|
||||
|
||||
else
|
||||
@ -388,18 +366,12 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao, (ao_num, ao_num, ao_num,
|
||||
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='tc_grad_and_lapl_ao', action="write")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
write(11) tc_grad_and_lapl_ao(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) tc_grad_and_lapl_ao
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
|
@ -3,7 +3,7 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_test, (ao_num, ao_num, n_po
|
||||
|
||||
BEGIN_DOC
|
||||
!
|
||||
! int2_grad1_u12_ao_test(i,j,ipoint,:) = \int dr2 [-1 * \grad_r1 J(r1,r2)] \phi_i(r2) \phi_j(r2)
|
||||
! int2_grad1_u12_ao_test(i,j,ipoint,:) = \int dr2 [-1 * \grad_r1 J(r1,r2)] \phi_i(r2) \phi_j(r2)
|
||||
!
|
||||
! where r1 = r(ipoint)
|
||||
!
|
||||
@ -15,9 +15,9 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_test, (ao_num, ao_num, n_po
|
||||
! if J(r1,r2) = u12 x v1 x v2
|
||||
!
|
||||
! int2_grad1_u12_ao_test(i,j,ipoint,:) = v1 x [ 0.5 x \int dr2 [(r1 - r2) (erf(mu * r12)-1)r_12] v2 \phi_i(r2) \phi_j(r2) ]
|
||||
! - \grad_1 v1 x [ \int dr2 u12 v2 \phi_i(r2) \phi_j(r2) ]
|
||||
! = 0.5 v_1b(ipoint) * v_ij_erf_rk_cst_mu_j1b(i,j,ipoint) * r(:)
|
||||
! - 0.5 v_1b(ipoint) * x_v_ij_erf_rk_cst_mu_j1b(i,j,ipoint,:)
|
||||
! - \grad_1 v1 x [ \int dr2 u12 v2 \phi_i(r2) \phi_j(r2) ]
|
||||
! = 0.5 v_1b(ipoint) * v_ij_erf_rk_cst_mu_j1b(i,j,ipoint) * r(:)
|
||||
! - 0.5 v_1b(ipoint) * x_v_ij_erf_rk_cst_mu_j1b(i,j,ipoint,:)
|
||||
! - v_1b_grad[:,ipoint] * v_ij_u_cst_mu_j1b(i,j,ipoint)
|
||||
!
|
||||
!
|
||||
@ -35,25 +35,18 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_test, (ao_num, ao_num, n_po
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='int2_grad1_u12_ao_test', action="read")
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
read(11) int2_grad1_u12_ao_test(i,j,ipoint,m)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao_test', action="read")
|
||||
read(11) int2_grad1_u12_ao_test
|
||||
close(11)
|
||||
|
||||
|
||||
else
|
||||
|
||||
|
||||
if(j1b_type .eq. 3) then
|
||||
do ipoint = 1, n_points_final_grid
|
||||
x = final_grid_points(1,ipoint)
|
||||
y = final_grid_points(2,ipoint)
|
||||
z = final_grid_points(3,ipoint)
|
||||
z = final_grid_points(3,ipoint)
|
||||
tmp0 = 0.5d0 * v_1b(ipoint)
|
||||
tmp_x = v_1b_grad(1,ipoint)
|
||||
tmp_y = v_1b_grad(2,ipoint)
|
||||
@ -87,24 +80,18 @@ BEGIN_PROVIDER [ double precision, int2_grad1_u12_ao_test, (ao_num, ao_num, n_po
|
||||
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='int2_grad1_u12_ao_test', action="write")
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
do j = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
write(11) int2_grad1_u12_ao_test(i,j,ipoint,m)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/int2_grad1_u12_ao_test', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) int2_grad1_u12_ao_test
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for int2_grad1_u12_ao_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
@ -114,9 +101,9 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao_test, (ao_num, ao_num, ao_
|
||||
!
|
||||
! tc_grad_and_lapl_ao_test(k,i,l,j) = < k l | -1/2 \Delta_1 u(r1,r2) - \grad_1 u(r1,r2) | ij >
|
||||
!
|
||||
! = 1/2 \int dr1 (phi_k(r1) \grad_r1 phi_i(r1) - phi_i(r1) \grad_r1 phi_k(r1)) . \int dr2 \grad_r1 u(r1,r2) \phi_l(r2) \phi_j(r2)
|
||||
! = 1/2 \int dr1 (phi_k(r1) \grad_r1 phi_i(r1) - phi_i(r1) \grad_r1 phi_k(r1)) . \int dr2 \grad_r1 u(r1,r2) \phi_l(r2) \phi_j(r2)
|
||||
!
|
||||
! This is obtained by integration by parts.
|
||||
! This is obtained by integration by parts.
|
||||
!
|
||||
END_DOC
|
||||
|
||||
@ -131,40 +118,32 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao_test, (ao_num, ao_num, ao_
|
||||
call wall_time(time0)
|
||||
|
||||
if(read_tc_integ) then
|
||||
|
||||
open(unit=11, form="unformatted", file='tc_grad_and_lapl_ao_test', action="read")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
read(11) tc_grad_and_lapl_ao_test(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao_test', action="read")
|
||||
read(11) tc_grad_and_lapl_ao_test
|
||||
close(11)
|
||||
|
||||
else
|
||||
|
||||
provide int2_grad1_u12_ao_test
|
||||
|
||||
provide int2_grad1_u12_ao_test
|
||||
|
||||
allocate(b_mat(n_points_final_grid,ao_num,ao_num,3), ac_mat(ao_num,ao_num,ao_num,ao_num))
|
||||
|
||||
|
||||
b_mat = 0.d0
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, k, ipoint, weight1, ao_i_r, ao_k_r) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, aos_grad_in_r_array_transp_bis, b_mat, &
|
||||
!$OMP PRIVATE (i, k, ipoint, weight1, ao_i_r, ao_k_r) &
|
||||
!$OMP SHARED (aos_in_r_array_transp, aos_grad_in_r_array_transp_bis, b_mat, &
|
||||
!$OMP ao_num, n_points_final_grid, final_weight_at_r_vector)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do ipoint = 1, n_points_final_grid
|
||||
|
||||
|
||||
weight1 = 0.5d0 * final_weight_at_r_vector(ipoint)
|
||||
ao_i_r = aos_in_r_array_transp(ipoint,i)
|
||||
ao_k_r = aos_in_r_array_transp(ipoint,k)
|
||||
|
||||
|
||||
b_mat(ipoint,k,i,1) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,1) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,1))
|
||||
b_mat(ipoint,k,i,2) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,2) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,2))
|
||||
b_mat(ipoint,k,i,3) = weight1 * (ao_k_r * aos_grad_in_r_array_transp_bis(ipoint,i,3) - ao_i_r * aos_grad_in_r_array_transp_bis(ipoint,k,3))
|
||||
@ -173,19 +152,19 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao_test, (ao_num, ao_num, ao_
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
ac_mat = 0.d0
|
||||
do m = 1, 3
|
||||
call dgemm( "N", "N", ao_num*ao_num, ao_num*ao_num, n_points_final_grid, 1.d0 &
|
||||
, int2_grad1_u12_ao_test(1,1,1,m), ao_num*ao_num, b_mat(1,1,1,m), n_points_final_grid &
|
||||
, 1.d0, ac_mat, ao_num*ao_num)
|
||||
|
||||
|
||||
enddo
|
||||
deallocate(b_mat)
|
||||
|
||||
|
||||
!$OMP PARALLEL &
|
||||
!$OMP DEFAULT (NONE) &
|
||||
!$OMP PRIVATE (i, j, k, l) &
|
||||
!$OMP PRIVATE (i, j, k, l) &
|
||||
!$OMP SHARED (ac_mat, tc_grad_and_lapl_ao_test, ao_num)
|
||||
!$OMP DO SCHEDULE (static)
|
||||
do j = 1, ao_num
|
||||
@ -199,29 +178,23 @@ BEGIN_PROVIDER [double precision, tc_grad_and_lapl_ao_test, (ao_num, ao_num, ao_
|
||||
enddo
|
||||
!$OMP END DO
|
||||
!$OMP END PARALLEL
|
||||
|
||||
|
||||
deallocate(ac_mat)
|
||||
|
||||
endif
|
||||
|
||||
if(write_tc_integ) then
|
||||
open(unit=11, form="unformatted", file='tc_grad_and_lapl_ao_test', action="write")
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
write(11) tc_grad_and_lapl_ao_test(l,k,j,i)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
if(write_tc_integ.and.mpi_master) then
|
||||
open(unit=11, form="unformatted", file=trim(ezfio_filename)//'/work/tc_grad_and_lapl_ao_test', action="write")
|
||||
call ezfio_set_work_empty(.False.)
|
||||
write(11) tc_grad_and_lapl_ao_test
|
||||
close(11)
|
||||
call ezfio_set_tc_keywords_io_tc_integ('Read')
|
||||
endif
|
||||
|
||||
call wall_time(time1)
|
||||
print*, ' Wall time for tc_grad_and_lapl_ao_test = ', time1 - time0
|
||||
|
||||
END_PROVIDER
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
||||
|
@ -68,7 +68,26 @@ BEGIN_PROVIDER [double precision, ao_tc_int_chemist, (ao_num, ao_num, ao_num, ao
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [double precision, ao_tc_int_chemist_no_cycle, (ao_num, ao_num, ao_num, ao_num)]
|
||||
! ---
|
||||
implicit none
|
||||
integer :: i, j, k, l
|
||||
double precision :: wall1, wall0
|
||||
print *, ' providing ao_tc_int_chemist_no_cycle ...'
|
||||
call wall_time(wall0)
|
||||
do j = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
ao_tc_int_chemist_no_cycle(k,i,l,j) = tc_grad_square_ao(k,i,l,j) + tc_grad_and_lapl_ao(k,i,l,j) + ao_two_e_coul(k,i,l,j)
|
||||
! ao_tc_int_chemist(k,i,l,j) = ao_two_e_coul(k,i,l,j)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
call wall_time(wall1)
|
||||
print *, ' wall time for ao_tc_int_chemist_no_cycle ', wall1 - wall0
|
||||
END_PROVIDER
|
||||
|
||||
BEGIN_PROVIDER [double precision, ao_tc_int_chemist_test, (ao_num, ao_num, ao_num, ao_num)]
|
||||
|
||||
|
@ -21,7 +21,7 @@ def mv_in_ezfio(ezfio,tmp):
|
||||
os.system(cmdmv)
|
||||
|
||||
|
||||
# Getting the EZFIO
|
||||
##Getting the EZFIO
|
||||
EZFIO=sys.argv[1]
|
||||
EZFIO=EZFIO.replace("/", "")
|
||||
print(EZFIO)
|
||||
@ -66,8 +66,20 @@ zip_in_ezfio(EZFIO,tmp)
|
||||
tmp="pts_charge_coord"
|
||||
fcoord = open(tmp,'w')
|
||||
fcoord.write(" 2\n")
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
#fcoord.write(" "+' 3 '+str(n_charges)+' \n')
|
||||
if(n_charges < 10):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <100):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <1000):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <10000):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <100000):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <1000000):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
elif(n_charges <10000000):
|
||||
fcoord.write(" "+str(n_charges)+' 3\n')
|
||||
for i in range(n_charges):
|
||||
fcoord.write(' '+coord_x[i]+'\n')
|
||||
for i in range(n_charges):
|
||||
|
557
src/tc_bi_ortho/dav_h_tc_s2.irp.f
Normal file
557
src/tc_bi_ortho/dav_h_tc_s2.irp.f
Normal file
@ -0,0 +1,557 @@
|
||||
|
||||
! ---
|
||||
|
||||
subroutine davidson_hs2_nonsym_b1space(u_in, H_jj, s2_out,energies, sze, N_st, N_st_diag_in, n_it_max_dav, converged, hcalc)
|
||||
|
||||
use mmap_module
|
||||
|
||||
BEGIN_DOC
|
||||
! Generic modified-Davidson diagonalization
|
||||
!
|
||||
! H_jj : specific diagonal H matrix elements to diagonalize de Davidson
|
||||
!
|
||||
! u_in : guess coefficients on the various states. Overwritten on exit by right eigenvectors
|
||||
!
|
||||
! sze : Number of determinants
|
||||
!
|
||||
! N_st : Number of eigenstates
|
||||
!
|
||||
! N_st_diag_in : Number of states in which H is diagonalized. Assumed > N_st
|
||||
!
|
||||
! Initial guess vectors are not necessarily orthonormal
|
||||
!
|
||||
! hcalc subroutine to compute W = H U (see routine hcalc_template for template of input/output)
|
||||
!
|
||||
! !!! WARNING !!! IT SEEMS THAT IF THE NUMBER OF MACRO ITERATIONS EXCEEDS n_it_max_dav,
|
||||
!
|
||||
! THE RECONTRACTION IS WRONG. YOU SHOULD CONSIDER CALLING MULTIPLE TIME THE ROUTINE
|
||||
!
|
||||
! SEE FOR INSTANCE IN tc_bi_ortho/tc_h_eigvectors.irp.f
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
|
||||
integer, intent(in) :: sze, N_st, N_st_diag_in, n_it_max_dav
|
||||
double precision, intent(in) :: H_jj(sze)
|
||||
logical, intent(inout) :: converged
|
||||
double precision, intent(inout) :: u_in(sze,N_st_diag_in)
|
||||
double precision, intent(out) :: energies(N_st)
|
||||
double precision, intent(inout) :: s2_out(N_st)
|
||||
external hcalc
|
||||
|
||||
character*(16384) :: write_buffer
|
||||
integer :: iter, N_st_diag
|
||||
integer :: i, j, k, l, m
|
||||
integer :: iter2, itertot
|
||||
logical :: disk_based
|
||||
integer :: shift, shift2, itermax
|
||||
integer :: nproc_target
|
||||
integer :: order(N_st_diag_in)
|
||||
double precision :: to_print(3,N_st)
|
||||
double precision :: r1, r2, alpha
|
||||
double precision :: cpu, wall
|
||||
double precision :: cmax
|
||||
double precision :: energy_shift(N_st_diag_in*davidson_sze_max)
|
||||
double precision, allocatable :: U(:,:)
|
||||
double precision, allocatable :: y(:,:), h(:,:), lambda(:), h_p(:,:), s2(:)
|
||||
real, allocatable :: y_s(:,:)
|
||||
double precision, allocatable :: s_(:,:), s_tmp(:,:)
|
||||
double precision, allocatable :: residual_norm(:)
|
||||
|
||||
double precision :: lambda_tmp
|
||||
integer, allocatable :: i_omax(:)
|
||||
double precision, allocatable :: U_tmp(:), overlap(:), S_d(:,:)
|
||||
|
||||
double precision, allocatable :: W(:,:)
|
||||
real, pointer :: S(:,:)
|
||||
|
||||
!double precision, pointer :: W(:,:)
|
||||
double precision, external :: u_dot_v, u_dot_u
|
||||
|
||||
|
||||
include 'constants.include.F'
|
||||
|
||||
N_st_diag = N_st_diag_in
|
||||
! print*,'trial vector'
|
||||
do i = 1, sze
|
||||
if(isnan(u_in(i,1)))then
|
||||
print*,'pb in input vector of davidson_general_ext_rout_nonsym_b1space'
|
||||
print*,i,u_in(i,1)
|
||||
stop
|
||||
else if (dabs(u_in(i,1)).lt.1.d-16)then
|
||||
u_in(i,1) = 0.d0
|
||||
endif
|
||||
enddo
|
||||
|
||||
!DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: U, W, S, y, y_s, S_d, h, lambda
|
||||
|
||||
if(N_st_diag*3 > sze) then
|
||||
print *, 'error in Davidson :'
|
||||
print *, 'Increase n_det_max_full to ', N_st_diag*3
|
||||
stop -1
|
||||
endif
|
||||
|
||||
itermax = max(2, min(davidson_sze_max, sze/N_st_diag)) + 1
|
||||
|
||||
provide threshold_nonsym_davidson
|
||||
call write_time(6)
|
||||
write(6,'(A)') ''
|
||||
write(6,'(A)') 'Davidson Diagonalization'
|
||||
write(6,'(A)') '------------------------'
|
||||
write(6,'(A)') ''
|
||||
|
||||
|
||||
! Find max number of cores to fit in memory
|
||||
! -----------------------------------------
|
||||
|
||||
nproc_target = nproc
|
||||
double precision :: rss
|
||||
integer :: maxab
|
||||
maxab = sze
|
||||
|
||||
m=1
|
||||
disk_based = .False.
|
||||
call resident_memory(rss)
|
||||
do
|
||||
r1 = 8.d0 * &! bytes
|
||||
( dble(sze)*(N_st_diag*itermax) &! U
|
||||
+ 1.5d0*dble(sze*m)*(N_st_diag*itermax) &! W, S
|
||||
+ 4.5d0*(N_st_diag*itermax)**2 &! h,y,y_s,s_, s_tmp
|
||||
+ 2.d0*(N_st_diag*itermax) &! s2,lambda
|
||||
+ 1.d0*(N_st_diag) &! residual_norm
|
||||
! In H_S2_u_0_nstates_zmq
|
||||
+ 3.d0*(N_st_diag*N_det) &! u_t, v_t, s_t on collector
|
||||
+ 3.d0*(N_st_diag*N_det) &! u_t, v_t, s_t on slave
|
||||
+ 0.5d0*maxab &! idx0 in H_S2_u_0_nstates_openmp_work_*
|
||||
+ nproc_target * &! In OMP section
|
||||
( 1.d0*(N_int*maxab) &! buffer
|
||||
+ 3.5d0*(maxab) ) &! singles_a, singles_b, doubles, idx
|
||||
) / 1024.d0**3
|
||||
|
||||
if(nproc_target == 0) then
|
||||
call check_mem(r1, irp_here)
|
||||
nproc_target = 1
|
||||
exit
|
||||
endif
|
||||
|
||||
if(r1+rss < qp_max_mem) then
|
||||
exit
|
||||
endif
|
||||
|
||||
if(itermax > 4) then
|
||||
itermax = itermax - 1
|
||||
! else if (m==1.and.disk_based_davidson) then
|
||||
! m = 0
|
||||
! disk_based = .True.
|
||||
! itermax = 6
|
||||
else
|
||||
nproc_target = nproc_target - 1
|
||||
endif
|
||||
|
||||
enddo
|
||||
|
||||
nthreads_davidson = nproc_target
|
||||
TOUCH nthreads_davidson
|
||||
|
||||
call write_int(6, N_st, 'Number of states')
|
||||
call write_int(6, N_st_diag, 'Number of states in diagonalization')
|
||||
call write_int(6, sze, 'Number of basis functions')
|
||||
call write_int(6, nproc_target, 'Number of threads for diagonalization')
|
||||
call write_double(6, r1, 'Memory(Gb)')
|
||||
if(disk_based) then
|
||||
print *, 'Using swap space to reduce RAM'
|
||||
endif
|
||||
|
||||
!---------------
|
||||
|
||||
write(6,'(A)') ''
|
||||
write_buffer = '====='
|
||||
do i=1,N_st
|
||||
write_buffer = trim(write_buffer)//' ================ =========== ==========='
|
||||
enddo
|
||||
write(6,'(A)') write_buffer(1:6+41*N_st)
|
||||
write_buffer = 'Iter'
|
||||
do i=1,N_st
|
||||
write_buffer = trim(write_buffer)//' Energy S^2 Residual '
|
||||
enddo
|
||||
write(6,'(A)') write_buffer(1:6+41*N_st)
|
||||
write_buffer = '====='
|
||||
do i=1,N_st
|
||||
write_buffer = trim(write_buffer)//' ================ =========== ==========='
|
||||
enddo
|
||||
write(6,'(A)') write_buffer(1:6+41*N_st)
|
||||
|
||||
|
||||
! ---
|
||||
|
||||
|
||||
allocate( W(sze,N_st_diag*itermax), S(sze,N_st_diag*itermax) )
|
||||
|
||||
allocate( &
|
||||
! Large
|
||||
U(sze,N_st_diag*itermax), &
|
||||
S_d(sze,N_st_diag), &
|
||||
|
||||
! Small
|
||||
h(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
h_p(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
y(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
s_(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
s_tmp(N_st_diag*itermax,N_st_diag*itermax), &
|
||||
lambda(N_st_diag*itermax), &
|
||||
residual_norm(N_st_diag), &
|
||||
i_omax(N_st), &
|
||||
s2(N_st_diag*itermax), &
|
||||
y_s(N_st_diag*itermax,N_st_diag*itermax) &
|
||||
)
|
||||
|
||||
U = 0.d0
|
||||
h = 0.d0
|
||||
y = 0.d0
|
||||
s_ = 0.d0
|
||||
s_tmp = 0.d0
|
||||
|
||||
lambda = 0.d0
|
||||
residual_norm = 0.d0
|
||||
|
||||
|
||||
ASSERT (N_st > 0)
|
||||
ASSERT (N_st_diag >= N_st)
|
||||
ASSERT (sze > 0)
|
||||
|
||||
! Davidson iterations
|
||||
! ===================
|
||||
|
||||
converged = .False.
|
||||
|
||||
! Initialize from N_st to N_st_diag with gaussian random numbers
|
||||
! to be sure to have overlap with any eigenvectors
|
||||
do k = N_st+1, N_st_diag
|
||||
u_in(k,k) = 10.d0
|
||||
do i = 1, sze
|
||||
call random_number(r1)
|
||||
call random_number(r2)
|
||||
r1 = dsqrt(-2.d0*dlog(r1))
|
||||
r2 = dtwo_pi*r2
|
||||
u_in(i,k) = r1*dcos(r2)
|
||||
enddo
|
||||
enddo
|
||||
! Normalize all states
|
||||
do k = 1, N_st_diag
|
||||
call normalize(u_in(1,k), sze)
|
||||
enddo
|
||||
|
||||
! Copy from the guess input "u_in" to the working vectors "U"
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! ---
|
||||
|
||||
itertot = 0
|
||||
|
||||
! do while (.not.converged.or.itertot.le.n_it_max_dav)
|
||||
integer :: iiii
|
||||
do iiii = 1, n_it_max_dav
|
||||
|
||||
itertot = itertot + 1
|
||||
if(itertot == 8) then
|
||||
exit
|
||||
endif
|
||||
|
||||
do iter = 1, itermax-1
|
||||
|
||||
shift = N_st_diag * (iter-1)
|
||||
shift2 = N_st_diag * iter
|
||||
|
||||
if( (iter > 1) .or. (itertot == 1) ) then
|
||||
|
||||
! Gram-Schmidt to orthogonalize all new guess with the previous vectors
|
||||
call ortho_qr(U, size(U, 1), sze, shift2)
|
||||
call ortho_qr(U, size(U, 1), sze, shift2)
|
||||
|
||||
! W = H U
|
||||
! call hcalc(W(1,shift+1), U(1,shift+1), N_st_diag, sze)
|
||||
call hcalc(W(1,shift+1),S_d,U(1,shift+1),N_st_diag,sze)
|
||||
S(1:sze,shift+1:shift+N_st_diag) = real(S_d(1:sze,1:N_st_diag))
|
||||
else
|
||||
|
||||
! Already computed in update below
|
||||
continue
|
||||
endif
|
||||
! Compute s_kl = <u_k | S_l> = <u_k| S2 |u_l>
|
||||
! -------------------------------------------
|
||||
|
||||
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,j,k) COLLAPSE(2)
|
||||
do j=1,shift2
|
||||
do i=1,shift2
|
||||
s_(i,j) = 0.d0
|
||||
do k=1,sze
|
||||
s_(i,j) = s_(i,j) + U(k,i) * dble(S(k,j))
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
|
||||
|
||||
! Compute h_kl = <u_k | W_l> = <u_k| H |u_l>
|
||||
! -------------------------------------------
|
||||
call dgemm( 'T', 'N', shift2, shift2, sze, 1.d0 &
|
||||
, U, size(U, 1), W, size(W, 1) &
|
||||
, 0.d0, h, size(h, 1) )
|
||||
! Penalty method
|
||||
! --------------
|
||||
|
||||
if (s2_eig) then
|
||||
h_p = s_
|
||||
do k=1,shift2
|
||||
h_p(k,k) = h_p(k,k) - expected_s2
|
||||
enddo
|
||||
if (only_expected_s2) then
|
||||
alpha = 0.1d0
|
||||
h_p = h + alpha*h_p
|
||||
else
|
||||
alpha = 0.0001d0
|
||||
h_p = h + alpha*h_p
|
||||
endif
|
||||
else
|
||||
h_p = h
|
||||
alpha = 0.d0
|
||||
endif
|
||||
|
||||
! Diagonalize h y = lambda y
|
||||
! ---------------------------
|
||||
call diag_nonsym_right(shift2, h_p(1,1), size(h_p, 1), y(1,1), size(y, 1), lambda(1), size(lambda, 1))
|
||||
|
||||
do k = 1, N_st_diag
|
||||
! print*,'lambda(k) before = ',lambda(k)
|
||||
lambda(k) = 0.d0
|
||||
do l = 1, shift2
|
||||
do m = 1, shift2
|
||||
lambda(k) += y(m,k) * h(m,l) * y(l,k)
|
||||
enddo
|
||||
enddo
|
||||
! print*,'lambda(k) new = ',lambda(k)
|
||||
enddo
|
||||
! Compute S2 for each eigenvector
|
||||
! -------------------------------
|
||||
|
||||
call dgemm('N','N',shift2,shift2,shift2, &
|
||||
1.d0, s_, size(s_,1), y, size(y,1), &
|
||||
0.d0, s_tmp, size(s_tmp,1))
|
||||
|
||||
call dgemm('T','N',shift2,shift2,shift2, &
|
||||
1.d0, y, size(y,1), s_tmp, size(s_tmp,1), &
|
||||
0.d0, s_, size(s_,1))
|
||||
|
||||
do k=1,shift2
|
||||
s2(k) = s_(k,k)
|
||||
enddo
|
||||
|
||||
! Express eigenvectors of h in the determinant basis:
|
||||
! ---------------------------------------------------
|
||||
|
||||
! y(:,k) = rk
|
||||
! U(:,k) = Bk
|
||||
! U(:,shift2+k) = Rk = Bk x rk
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, U, size(U, 1), y, size(y, 1) &
|
||||
, 0.d0, U(1,shift2+1), size(U, 1) )
|
||||
|
||||
do k = 1, N_st_diag
|
||||
call normalize(U(1,shift2+k), sze)
|
||||
enddo
|
||||
|
||||
! ---
|
||||
! select the max overlap
|
||||
|
||||
!
|
||||
! start test ------------------------------------------------------------------------
|
||||
!
|
||||
!double precision, allocatable :: Utest(:,:), Otest(:)
|
||||
!allocate( Utest(sze,shift2), Otest(shift2) )
|
||||
|
||||
!call dgemm( 'N', 'N', sze, shift2, shift2, 1.d0 &
|
||||
! , U, size(U, 1), y, size(y, 1), 0.d0, Utest(1,1), size(Utest, 1) )
|
||||
!do k = 1, shift2
|
||||
! call normalize(Utest(1,k), sze)
|
||||
!enddo
|
||||
!do j = 1, sze
|
||||
! write(455, '(100(1X, F16.10))') (Utest(j,k), k=1,shift2)
|
||||
!enddo
|
||||
|
||||
!do k = 1, shift2
|
||||
! Otest(k) = 0.d0
|
||||
! do i = 1, sze
|
||||
! Otest(k) += Utest(i,k) * u_in(i,1)
|
||||
! enddo
|
||||
! Otest(k) = dabs(Otest(k))
|
||||
! print *, ' Otest =', k, Otest(k), lambda(k)
|
||||
!enddo
|
||||
|
||||
!deallocate(Utest, Otest)
|
||||
!
|
||||
! end test ------------------------------------------------------------------------
|
||||
!
|
||||
|
||||
! TODO
|
||||
! state_following is more efficient
|
||||
do l = 1, N_st
|
||||
|
||||
allocate( overlap(N_st_diag) )
|
||||
|
||||
do k = 1, N_st_diag
|
||||
overlap(k) = 0.d0
|
||||
do i = 1, sze
|
||||
overlap(k) = overlap(k) + U(i,shift2+k) * u_in(i,l)
|
||||
enddo
|
||||
overlap(k) = dabs(overlap(k))
|
||||
!print *, ' overlap =', k, overlap(k)
|
||||
enddo
|
||||
|
||||
lambda_tmp = 0.d0
|
||||
do k = 1, N_st_diag
|
||||
if(overlap(k) .gt. lambda_tmp) then
|
||||
i_omax(l) = k
|
||||
lambda_tmp = overlap(k)
|
||||
endif
|
||||
enddo
|
||||
|
||||
deallocate(overlap)
|
||||
|
||||
if(lambda_tmp .lt. 0.7d0) then
|
||||
print *, ' very small overlap ...', l, i_omax(l)
|
||||
print *, ' max overlap = ', lambda_tmp
|
||||
stop
|
||||
endif
|
||||
|
||||
if(i_omax(l) .ne. l) then
|
||||
print *, ' !!! WARNONG !!!'
|
||||
print *, ' index of state', l, i_omax(l)
|
||||
endif
|
||||
enddo
|
||||
|
||||
! y(:,k) = rk
|
||||
! W(:,k) = H x Bk
|
||||
! W(:,shift2+k) = H x Bk x rk
|
||||
! = Wk
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, W, size(W, 1), y, size(y, 1) &
|
||||
, 0.d0, W(1,shift2+1), size(W, 1) )
|
||||
|
||||
! ---
|
||||
|
||||
! Compute residual vector and davidson step
|
||||
! -----------------------------------------
|
||||
|
||||
!$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(i,k)
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,shift2+k) = (lambda(k) * U(i,shift2+k) - W(i,shift2+k)) / max(H_jj(i)-lambda(k), 1.d-2)
|
||||
enddo
|
||||
if(k <= N_st) then
|
||||
l = k
|
||||
residual_norm(k) = u_dot_u(U(1,shift2+l), sze)
|
||||
to_print(1,k) = lambda(l)
|
||||
to_print(2,k) = s2(l)
|
||||
to_print(3,k) = residual_norm(l)
|
||||
endif
|
||||
enddo
|
||||
!$OMP END PARALLEL DO
|
||||
!residual_norm(1) = u_dot_u(U(1,shift2+1), sze)
|
||||
!to_print(1,1) = lambda(1)
|
||||
!to_print(2,1) = residual_norm(1)
|
||||
|
||||
|
||||
if( (itertot > 1) .and. (iter == 1) ) then
|
||||
!don't print
|
||||
continue
|
||||
else
|
||||
write(*, '(1X, I3, 1X, 100(1X, F16.10, 1X, F16.10, 1X, F16.10))') iter-1, to_print(1:3,1:N_st)
|
||||
endif
|
||||
|
||||
! Check convergence
|
||||
if(iter > 1) then
|
||||
converged = dabs(maxval(residual_norm(1:N_st))) < threshold_nonsym_davidson
|
||||
endif
|
||||
|
||||
do k = 1, N_st
|
||||
if(residual_norm(k) > 1.e8) then
|
||||
print *, 'Davidson failed'
|
||||
stop -1
|
||||
endif
|
||||
enddo
|
||||
if(converged) then
|
||||
exit
|
||||
endif
|
||||
|
||||
logical, external :: qp_stop
|
||||
if(qp_stop()) then
|
||||
converged = .True.
|
||||
exit
|
||||
endif
|
||||
|
||||
enddo ! loop over iter
|
||||
|
||||
|
||||
! Re-contract U and update W
|
||||
! --------------------------------
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, W, size(W, 1), y, size(y, 1) &
|
||||
, 0.d0, u_in, size(u_in, 1) )
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
W(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call dgemm( 'N', 'N', sze, N_st_diag, shift2, 1.d0 &
|
||||
, U, size(U, 1), y, size(y, 1) &
|
||||
, 0.d0, u_in, size(u_in, 1) )
|
||||
do k = 1, N_st_diag
|
||||
do i = 1, sze
|
||||
U(i,k) = u_in(i,k)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call ortho_qr(U, size(U, 1), sze, N_st_diag)
|
||||
call ortho_qr(U, size(U, 1), sze, N_st_diag)
|
||||
do j = 1, N_st_diag
|
||||
k = 1
|
||||
do while( (k < sze) .and. (U(k,j) == 0.d0) )
|
||||
k = k+1
|
||||
enddo
|
||||
if(U(k,j) * u_in(k,j) < 0.d0) then
|
||||
do i = 1, sze
|
||||
W(i,j) = -W(i,j)
|
||||
enddo
|
||||
endif
|
||||
enddo
|
||||
if(converged)exit
|
||||
enddo ! loop over while
|
||||
|
||||
! ---
|
||||
|
||||
do k = 1, N_st
|
||||
energies(k) = lambda(k)
|
||||
s2_out(k) = s2(k)
|
||||
enddo
|
||||
write_buffer = '====='
|
||||
do i = 1, N_st
|
||||
write_buffer = trim(write_buffer)//' ================ ==========='
|
||||
enddo
|
||||
write(6,'(A)') trim(write_buffer)
|
||||
write(6,'(A)') ''
|
||||
call write_time(6)
|
||||
|
||||
deallocate(W)
|
||||
deallocate(U, h, y, lambda, residual_norm, i_omax)
|
||||
|
||||
FREE nthreads_davidson
|
||||
|
||||
end subroutine davidson_general_ext_rout_nonsym_b1space
|
||||
|
||||
! ---
|
769
src/tc_bi_ortho/h_tc_s2_u0.irp.f
Normal file
769
src/tc_bi_ortho/h_tc_s2_u0.irp.f
Normal file
@ -0,0 +1,769 @@
|
||||
|
||||
subroutine get_H_tc_s2_l0_r0(l_0,r_0,N_st,sze,energies, s2)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $e_0 = \langle l_0 | H | r_0\rangle$.
|
||||
!
|
||||
! Computes $s_0 = \langle l_0 | S^2 | r_0\rangle$.
|
||||
!
|
||||
! Assumes that the determinants are in psi_det
|
||||
!
|
||||
! istart, iend, ishift, istep are used in ZMQ parallelization.
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze
|
||||
double precision, intent(in) :: l_0(sze,N_st), r_0(sze,N_st)
|
||||
double precision, intent(out) :: energies(N_st), s2(N_st)
|
||||
logical :: do_right
|
||||
integer :: istate
|
||||
double precision, allocatable :: s_0(:,:), v_0(:,:)
|
||||
double precision :: u_dot_v, norm
|
||||
allocate(s_0(sze,N_st), v_0(sze,N_st))
|
||||
do_right = .True.
|
||||
call H_tc_s2_u_0_opt(v_0,s_0,r_0,N_st,sze)
|
||||
do istate = 1, N_st
|
||||
norm = u_dot_v(l_0(1,istate),r_0(1,istate),sze)
|
||||
energies(istate) = u_dot_v(l_0(1,istate),v_0(1,istate),sze)/norm
|
||||
s2(istate) = u_dot_v(l_0(1,istate),s_0(1,istate),sze)/norm
|
||||
enddo
|
||||
end
|
||||
|
||||
subroutine H_tc_s2_u_0_opt(v_0,s_0,u_0,N_st,sze)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $v_0 = H | u_0\rangle$.
|
||||
!
|
||||
! Assumes that the determinants are in psi_det
|
||||
!
|
||||
! istart, iend, ishift, istep are used in ZMQ parallelization.
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze
|
||||
double precision, intent(inout) :: v_0(sze,N_st), u_0(sze,N_st), s_0(sze,N_st)
|
||||
logical :: do_right
|
||||
do_right = .True.
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze, do_right)
|
||||
end
|
||||
|
||||
subroutine H_tc_s2_dagger_u_0_opt(v_0,s_0,u_0,N_st,sze)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $v_0 = H | u_0\rangle$.
|
||||
!
|
||||
! Assumes that the determinants are in psi_det
|
||||
!
|
||||
! istart, iend, ishift, istep are used in ZMQ parallelization.
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze
|
||||
double precision, intent(inout) :: v_0(sze,N_st), u_0(sze,N_st), s_0(sze,N_st)
|
||||
logical :: do_right
|
||||
do_right = .False.
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze, do_right)
|
||||
end
|
||||
|
||||
|
||||
subroutine H_tc_s2_u_0_nstates_openmp(v_0,s_0,u_0,N_st,sze, do_right)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $v_0 = H | u_0\rangle$.
|
||||
!
|
||||
! Assumes that the determinants are in psi_det
|
||||
!
|
||||
! istart, iend, ishift, istep are used in ZMQ parallelization.
|
||||
!
|
||||
! if do_right == True then you compute H_TC |Psi>, else H_TC^T |Psi>
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze
|
||||
double precision, intent(inout) :: v_0(sze,N_st), u_0(sze,N_st), s_0(sze,N_st)
|
||||
logical, intent(in) :: do_right
|
||||
integer :: k
|
||||
double precision, allocatable :: u_t(:,:), v_t(:,:), s_t(:,:)
|
||||
!DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t
|
||||
allocate(u_t(N_st,N_det),v_t(N_st,N_det),s_t(N_st,N_det))
|
||||
do k=1,N_st
|
||||
call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det)
|
||||
enddo
|
||||
v_t = 0.d0
|
||||
s_t = 0.d0
|
||||
call dtranspose( &
|
||||
u_0, &
|
||||
size(u_0, 1), &
|
||||
u_t, &
|
||||
size(u_t, 1), &
|
||||
N_det, N_st)
|
||||
|
||||
call H_tc_s2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,1,N_det,0,1, do_right)
|
||||
deallocate(u_t)
|
||||
|
||||
call dtranspose( &
|
||||
v_t, &
|
||||
size(v_t, 1), &
|
||||
v_0, &
|
||||
size(v_0, 1), &
|
||||
N_st, N_det)
|
||||
call dtranspose( &
|
||||
s_t, &
|
||||
size(s_t, 1), &
|
||||
s_0, &
|
||||
size(s_0, 1), &
|
||||
N_st, N_det)
|
||||
deallocate(v_t,s_t)
|
||||
|
||||
do k=1,N_st
|
||||
call dset_order(v_0(1,k),psi_bilinear_matrix_order_reverse,N_det)
|
||||
call dset_order(s_0(1,k),psi_bilinear_matrix_order_reverse,N_det)
|
||||
call dset_order(u_0(1,k),psi_bilinear_matrix_order_reverse,N_det)
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
|
||||
subroutine H_tc_s2_u_0_nstates_openmp_work(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep, do_right)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $v_t = H | u_t\rangle$
|
||||
!
|
||||
! Default should be 1,N_det,0,1
|
||||
!
|
||||
! if do_right == True then you compute H_TC |Psi>, else H_TC^T |Psi>
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze,istart,iend,ishift,istep
|
||||
double precision, intent(in) :: u_t(N_st,N_det)
|
||||
logical, intent(in) :: do_right
|
||||
double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze)
|
||||
|
||||
|
||||
PROVIDE ref_bitmask_energy N_int
|
||||
|
||||
select case (N_int)
|
||||
case (1)
|
||||
call H_tc_s2_u_0_nstates_openmp_work_1(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
case (2)
|
||||
call H_tc_s2_u_0_nstates_openmp_work_2(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
case (3)
|
||||
call H_tc_s2_u_0_nstates_openmp_work_3(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
case (4)
|
||||
call H_tc_s2_u_0_nstates_openmp_work_4(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
case default
|
||||
call H_tc_s2_u_0_nstates_openmp_work_N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
end select
|
||||
end
|
||||
BEGIN_TEMPLATE
|
||||
|
||||
subroutine H_tc_s2_u_0_nstates_openmp_work_$N_int(v_t,s_t,u_t,N_st,sze,istart,iend,ishift,istep,do_right)
|
||||
use bitmasks
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Computes $v_t = H | u_t \\rangle$ and $s_t = S^2 | u_t\\rangle$
|
||||
!
|
||||
! Default should be 1,N_det,0,1
|
||||
!
|
||||
! if do_right == True then you compute H_TC |Psi>, else H_TC^T |Psi>
|
||||
END_DOC
|
||||
integer, intent(in) :: N_st,sze,istart,iend,ishift,istep
|
||||
double precision, intent(in) :: u_t(N_st,N_det)
|
||||
logical, intent(in) :: do_right
|
||||
double precision, intent(out) :: v_t(N_st,sze), s_t(N_st,sze)
|
||||
|
||||
double precision :: hij, sij
|
||||
integer :: i,j,k,l,kk
|
||||
integer :: k_a, k_b, l_a, l_b, m_a, m_b
|
||||
integer :: istate
|
||||
integer :: krow, kcol, krow_b, kcol_b
|
||||
integer :: lrow, lcol
|
||||
integer :: mrow, mcol
|
||||
integer(bit_kind) :: spindet($N_int)
|
||||
integer(bit_kind) :: tmp_det($N_int,2)
|
||||
integer(bit_kind) :: tmp_det2($N_int,2)
|
||||
integer(bit_kind) :: tmp_det3($N_int,2)
|
||||
integer(bit_kind), allocatable :: buffer(:,:)
|
||||
integer :: n_doubles
|
||||
integer, allocatable :: doubles(:)
|
||||
integer, allocatable :: singles_a(:)
|
||||
integer, allocatable :: singles_b(:)
|
||||
integer, allocatable :: idx(:), idx0(:)
|
||||
integer :: maxab, n_singles_a, n_singles_b, kcol_prev
|
||||
integer*8 :: k8
|
||||
logical :: compute_singles
|
||||
integer*8 :: last_found, left, right, right_max
|
||||
double precision :: rss, mem, ratio
|
||||
double precision, allocatable :: utl(:,:)
|
||||
integer, parameter :: block_size=128
|
||||
logical :: u_is_sparse
|
||||
|
||||
! call resident_memory(rss)
|
||||
! mem = dble(singles_beta_csc_size) / 1024.d0**3
|
||||
!
|
||||
! compute_singles = (mem+rss > qp_max_mem)
|
||||
!
|
||||
! if (.not.compute_singles) then
|
||||
! provide singles_beta_csc
|
||||
! endif
|
||||
compute_singles=.True.
|
||||
|
||||
|
||||
maxab = max(N_det_alpha_unique, N_det_beta_unique)+1
|
||||
allocate(idx0(maxab))
|
||||
|
||||
do i=1,maxab
|
||||
idx0(i) = i
|
||||
enddo
|
||||
|
||||
! Prepare the array of all alpha single excitations
|
||||
! -------------------------------------------------
|
||||
|
||||
PROVIDE N_int nthreads_davidson
|
||||
!$OMP PARALLEL DEFAULT(SHARED) NUM_THREADS(nthreads_davidson) &
|
||||
!$OMP SHARED(psi_bilinear_matrix_rows, N_det, &
|
||||
!$OMP psi_bilinear_matrix_columns, &
|
||||
!$OMP psi_det_alpha_unique, psi_det_beta_unique, &
|
||||
!$OMP n_det_alpha_unique, n_det_beta_unique, N_int, &
|
||||
!$OMP psi_bilinear_matrix_transp_rows, &
|
||||
!$OMP psi_bilinear_matrix_transp_columns, &
|
||||
!$OMP psi_bilinear_matrix_transp_order, N_st, &
|
||||
!$OMP psi_bilinear_matrix_order_transp_reverse, &
|
||||
!$OMP psi_bilinear_matrix_columns_loc, &
|
||||
!$OMP psi_bilinear_matrix_transp_rows_loc, &
|
||||
!$OMP istart, iend, istep, irp_here, v_t, s_t, &
|
||||
!$OMP ishift, idx0, u_t, maxab, compute_singles, &
|
||||
!$OMP singles_alpha_csc,singles_alpha_csc_idx, &
|
||||
!$OMP singles_beta_csc,singles_beta_csc_idx) &
|
||||
!$OMP PRIVATE(krow, kcol, tmp_det, spindet, k_a, k_b, i, &
|
||||
!$OMP lcol, lrow, l_a, l_b, utl, kk, u_is_sparse, &
|
||||
!$OMP buffer, doubles, n_doubles, umax, &
|
||||
!$OMP tmp_det2, hij, sij, idx, l, kcol_prev,hmono, htwoe, hthree, &
|
||||
!$OMP singles_a, n_singles_a, singles_b, ratio, &
|
||||
!$OMP n_singles_b, k8, last_found,left,right,right_max)
|
||||
|
||||
! Alpha/Beta double excitations
|
||||
! =============================
|
||||
|
||||
allocate( buffer($N_int,maxab), &
|
||||
singles_a(maxab), &
|
||||
singles_b(maxab), &
|
||||
doubles(maxab), &
|
||||
idx(maxab), utl(N_st,block_size))
|
||||
|
||||
kcol_prev=-1
|
||||
|
||||
! Check if u has multiple zeros
|
||||
kk=1 ! Avoid division by zero
|
||||
!$OMP DO
|
||||
do k=1,N_det
|
||||
umax = 0.d0
|
||||
do l=1,N_st
|
||||
umax = max(umax, dabs(u_t(l,k)))
|
||||
enddo
|
||||
if (umax < 1.d-20) then
|
||||
!$OMP ATOMIC
|
||||
kk = kk+1
|
||||
endif
|
||||
enddo
|
||||
!$OMP END DO
|
||||
u_is_sparse = N_det / kk < 20 ! 5%
|
||||
|
||||
ASSERT (iend <= N_det)
|
||||
ASSERT (istart > 0)
|
||||
ASSERT (istep > 0)
|
||||
|
||||
!$OMP DO SCHEDULE(guided,64)
|
||||
do k_a=istart+ishift,iend,istep ! Loop over all determinants (/!\ not in psidet order)
|
||||
|
||||
krow = psi_bilinear_matrix_rows(k_a) ! Index of alpha part of determinant k_a
|
||||
ASSERT (krow <= N_det_alpha_unique)
|
||||
|
||||
kcol = psi_bilinear_matrix_columns(k_a) ! Index of beta part of determinant k_a
|
||||
ASSERT (kcol <= N_det_beta_unique)
|
||||
|
||||
tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow)
|
||||
|
||||
if (kcol /= kcol_prev) then
|
||||
tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol)
|
||||
if (compute_singles) then
|
||||
call get_all_spin_singles_$N_int( &
|
||||
psi_det_beta_unique, idx0, &
|
||||
tmp_det(1,2), N_det_beta_unique, &
|
||||
singles_b, n_singles_b)
|
||||
else
|
||||
n_singles_b = 0
|
||||
!DIR$ LOOP COUNT avg(1000)
|
||||
do k8=singles_beta_csc_idx(kcol),singles_beta_csc_idx(kcol+1)-1
|
||||
n_singles_b = n_singles_b+1
|
||||
singles_b(n_singles_b) = singles_beta_csc(k8)
|
||||
enddo
|
||||
endif
|
||||
endif
|
||||
kcol_prev = kcol
|
||||
|
||||
! -> Here, tmp_det is determinant k_a
|
||||
|
||||
! Loop over singly excited beta columns
|
||||
! -------------------------------------
|
||||
|
||||
!DIR$ LOOP COUNT avg(1000)
|
||||
do i=1,n_singles_b
|
||||
lcol = singles_b(i)
|
||||
|
||||
tmp_det2(1:$N_int,2) = psi_det_beta_unique(1:$N_int, lcol)
|
||||
|
||||
! tmp_det2 is a single excitation of tmp_det in the beta spin
|
||||
! the alpha part is not defined yet
|
||||
|
||||
!---
|
||||
! if (compute_singles) then
|
||||
|
||||
l_a = psi_bilinear_matrix_columns_loc(lcol)
|
||||
ASSERT (l_a <= N_det)
|
||||
! rows : | 1 2 3 4 | 1 3 4 6 | .... | 1 2 4 5 |
|
||||
! cols : | 1 1 1 1 | 2 2 2 2 | .... | 8 8 8 8 |
|
||||
! index : | 1 2 3 4 | 5 6 7 8 | .... | 58 59 60 61 |
|
||||
! ^ ^
|
||||
! | |
|
||||
! l_a N_det
|
||||
! l_a is the index in the big vector os size Ndet of the position of the first element of column lcol
|
||||
|
||||
! Below we identify all the determinants with the same beta part
|
||||
|
||||
!DIR$ UNROLL(8)
|
||||
!DIR$ LOOP COUNT avg(50000)
|
||||
do j=1,psi_bilinear_matrix_columns_loc(lcol+1) - psi_bilinear_matrix_columns_loc(lcol)
|
||||
lrow = psi_bilinear_matrix_rows(l_a)
|
||||
ASSERT (lrow <= N_det_alpha_unique)
|
||||
|
||||
buffer(1:$N_int,j) = psi_det_alpha_unique(1:$N_int, lrow) ! hot spot
|
||||
|
||||
ASSERT (l_a <= N_det)
|
||||
idx(j) = l_a
|
||||
l_a = l_a+1
|
||||
enddo
|
||||
j = j-1
|
||||
|
||||
! Get all single excitations from tmp_det(1,1) to buffer(1,?)
|
||||
|
||||
call get_all_spin_singles_$N_int( &
|
||||
buffer, idx, tmp_det(1,1), j, &
|
||||
singles_a, n_singles_a )
|
||||
|
||||
! Loop over alpha singles
|
||||
! -----------------------
|
||||
|
||||
double precision :: umax
|
||||
|
||||
!DIR$ LOOP COUNT avg(1000)
|
||||
do k = 1,n_singles_a,block_size
|
||||
umax = 0.d0
|
||||
! Prefetch u_t(:,l_a)
|
||||
if (u_is_sparse) then
|
||||
do kk=0,block_size-1
|
||||
if (k+kk > n_singles_a) exit
|
||||
l_a = singles_a(k+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
|
||||
do l=1,N_st
|
||||
utl(l,kk+1) = u_t(l,l_a)
|
||||
umax = max(umax, dabs(utl(l,kk+1)))
|
||||
enddo
|
||||
enddo
|
||||
else
|
||||
do kk=0,block_size-1
|
||||
if (k+kk > n_singles_a) exit
|
||||
l_a = singles_a(k+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
utl(:,kk+1) = u_t(:,l_a)
|
||||
enddo
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
do kk=0,block_size-1
|
||||
if (k+kk > n_singles_a) exit
|
||||
l_a = singles_a(k+kk)
|
||||
lrow = psi_bilinear_matrix_rows(l_a)
|
||||
ASSERT (lrow <= N_det_alpha_unique)
|
||||
|
||||
tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, lrow)
|
||||
! call i_H_j( tmp_det, tmp_det2, $N_int, hij) ! double alpha-beta
|
||||
if(do_right)then
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det,tmp_det2,$N_int,hij)
|
||||
else
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det2,tmp_det,$N_int,hij)
|
||||
endif
|
||||
call get_s2(tmp_det,tmp_det2,$N_int,sij)
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1)
|
||||
s_t(l,k_a) = s_t(l,k_a) + sij * utl(l,kk+1)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
enddo
|
||||
!$OMP END DO
|
||||
|
||||
!$OMP DO SCHEDULE(guided,64)
|
||||
do k_a=istart+ishift,iend,istep
|
||||
|
||||
|
||||
! Single and double alpha excitations
|
||||
! ===================================
|
||||
|
||||
|
||||
! Initial determinant is at k_a in alpha-major representation
|
||||
! -----------------------------------------------------------------------
|
||||
|
||||
krow = psi_bilinear_matrix_rows(k_a)
|
||||
ASSERT (krow <= N_det_alpha_unique)
|
||||
|
||||
kcol = psi_bilinear_matrix_columns(k_a)
|
||||
ASSERT (kcol <= N_det_beta_unique)
|
||||
|
||||
tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow)
|
||||
tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol)
|
||||
|
||||
! Initial determinant is at k_b in beta-major representation
|
||||
! ----------------------------------------------------------------------
|
||||
|
||||
k_b = psi_bilinear_matrix_order_transp_reverse(k_a)
|
||||
ASSERT (k_b <= N_det)
|
||||
|
||||
spindet(1:$N_int) = tmp_det(1:$N_int,1)
|
||||
|
||||
! Loop inside the beta column to gather all the connected alphas
|
||||
lcol = psi_bilinear_matrix_columns(k_a)
|
||||
l_a = psi_bilinear_matrix_columns_loc(lcol)
|
||||
|
||||
!DIR$ LOOP COUNT avg(200000)
|
||||
do i=1,N_det_alpha_unique
|
||||
if (l_a > N_det) exit
|
||||
lcol = psi_bilinear_matrix_columns(l_a)
|
||||
if (lcol /= kcol) exit
|
||||
lrow = psi_bilinear_matrix_rows(l_a)
|
||||
ASSERT (lrow <= N_det_alpha_unique)
|
||||
|
||||
buffer(1:$N_int,i) = psi_det_alpha_unique(1:$N_int, lrow) ! Hot spot
|
||||
idx(i) = l_a
|
||||
l_a = l_a+1
|
||||
enddo
|
||||
i = i-1
|
||||
|
||||
call get_all_spin_singles_and_doubles_$N_int( &
|
||||
buffer, idx, spindet, i, &
|
||||
singles_a, doubles, n_singles_a, n_doubles )
|
||||
|
||||
! Compute Hij for all alpha singles
|
||||
! ----------------------------------
|
||||
|
||||
tmp_det2(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol)
|
||||
!DIR$ LOOP COUNT avg(1000)
|
||||
do i=1,n_singles_a,block_size
|
||||
umax = 0.d0
|
||||
! Prefetch u_t(:,l_a)
|
||||
if (u_is_sparse) then
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_a) exit
|
||||
l_a = singles_a(i+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
|
||||
do l=1,N_st
|
||||
utl(l,kk+1) = u_t(l,l_a)
|
||||
umax = max(umax, dabs(utl(l,kk+1)))
|
||||
enddo
|
||||
enddo
|
||||
else
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_a) exit
|
||||
l_a = singles_a(i+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
utl(:,kk+1) = u_t(:,l_a)
|
||||
enddo
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_a) exit
|
||||
l_a = singles_a(i+kk)
|
||||
lrow = psi_bilinear_matrix_rows(l_a)
|
||||
ASSERT (lrow <= N_det_alpha_unique)
|
||||
|
||||
tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, lrow)
|
||||
! call i_h_j_single_spin( tmp_det, tmp_det2, $N_int, 1, hij)
|
||||
if(do_right)then
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det,tmp_det2,$N_int,hij)
|
||||
else
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det2,tmp_det,$N_int,hij)
|
||||
endif
|
||||
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
! Compute Hij for all alpha doubles
|
||||
! ----------------------------------
|
||||
|
||||
!DIR$ LOOP COUNT avg(50000)
|
||||
do i=1,n_doubles,block_size
|
||||
umax = 0.d0
|
||||
! Prefetch u_t(:,l_a)
|
||||
if (u_is_sparse) then
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_a = doubles(i+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
|
||||
do l=1,N_st
|
||||
utl(l,kk+1) = u_t(l,l_a)
|
||||
umax = max(umax, dabs(utl(l,kk+1)))
|
||||
enddo
|
||||
enddo
|
||||
else
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_a = doubles(i+kk)
|
||||
ASSERT (l_a <= N_det)
|
||||
utl(:,kk+1) = u_t(:,l_a)
|
||||
enddo
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_a = doubles(i+kk)
|
||||
lrow = psi_bilinear_matrix_rows(l_a)
|
||||
ASSERT (lrow <= N_det_alpha_unique)
|
||||
|
||||
tmp_det2(1:N_int,1) = psi_det_alpha_unique(1:N_int, lrow)
|
||||
! call i_H_j( tmp_det, tmp_det2, $N_int, hij)
|
||||
! call i_H_j_double_spin( tmp_det(1,1), psi_det_alpha_unique(1, lrow), $N_int, hij)
|
||||
if(do_right)then
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det,tmp_det2,$N_int,hij)
|
||||
else
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det2,tmp_det,$N_int,hij)
|
||||
endif
|
||||
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
! Single and double beta excitations
|
||||
! ==================================
|
||||
|
||||
|
||||
! Initial determinant is at k_a in alpha-major representation
|
||||
! -----------------------------------------------------------------------
|
||||
|
||||
krow = psi_bilinear_matrix_rows(k_a)
|
||||
kcol = psi_bilinear_matrix_columns(k_a)
|
||||
|
||||
tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow)
|
||||
tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol)
|
||||
|
||||
spindet(1:$N_int) = tmp_det(1:$N_int,2)
|
||||
|
||||
! Initial determinant is at k_b in beta-major representation
|
||||
! -----------------------------------------------------------------------
|
||||
|
||||
k_b = psi_bilinear_matrix_order_transp_reverse(k_a)
|
||||
ASSERT (k_b <= N_det)
|
||||
|
||||
! Loop inside the alpha row to gather all the connected betas
|
||||
lrow = psi_bilinear_matrix_transp_rows(k_b)
|
||||
l_b = psi_bilinear_matrix_transp_rows_loc(lrow)
|
||||
!DIR$ LOOP COUNT avg(200000)
|
||||
do i=1,N_det_beta_unique
|
||||
if (l_b > N_det) exit
|
||||
lrow = psi_bilinear_matrix_transp_rows(l_b)
|
||||
if (lrow /= krow) exit
|
||||
lcol = psi_bilinear_matrix_transp_columns(l_b)
|
||||
ASSERT (lcol <= N_det_beta_unique)
|
||||
|
||||
buffer(1:$N_int,i) = psi_det_beta_unique(1:$N_int, lcol)
|
||||
idx(i) = l_b
|
||||
l_b = l_b+1
|
||||
enddo
|
||||
i = i-1
|
||||
|
||||
call get_all_spin_singles_and_doubles_$N_int( &
|
||||
buffer, idx, spindet, i, &
|
||||
singles_b, doubles, n_singles_b, n_doubles )
|
||||
|
||||
! Compute Hij for all beta singles
|
||||
! ----------------------------------
|
||||
|
||||
tmp_det2(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow)
|
||||
!DIR$ LOOP COUNT avg(1000)
|
||||
do i=1,n_singles_b,block_size
|
||||
umax = 0.d0
|
||||
if (u_is_sparse) then
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_b) exit
|
||||
l_b = singles_b(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
ASSERT (l_b <= N_det)
|
||||
ASSERT (l_a <= N_det)
|
||||
|
||||
do l=1,N_st
|
||||
utl(l,kk+1) = u_t(l,l_a)
|
||||
umax = max(umax, dabs(utl(l,kk+1)))
|
||||
enddo
|
||||
enddo
|
||||
else
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_b) exit
|
||||
l_b = singles_b(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
ASSERT (l_b <= N_det)
|
||||
ASSERT (l_a <= N_det)
|
||||
utl(:,kk+1) = u_t(:,l_a)
|
||||
enddo
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_singles_b) exit
|
||||
l_b = singles_b(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
lcol = psi_bilinear_matrix_transp_columns(l_b)
|
||||
ASSERT (lcol <= N_det_beta_unique)
|
||||
|
||||
tmp_det2(1:$N_int,2) = psi_det_beta_unique (1:$N_int, lcol)
|
||||
! call i_H_j_single_spin( tmp_det, tmp_det2, $N_int, 2, hij)
|
||||
if(do_right)then
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det,tmp_det2,$N_int,hij)
|
||||
else
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det2,tmp_det,$N_int,hij)
|
||||
endif
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
! Compute Hij for all beta doubles
|
||||
! ----------------------------------
|
||||
|
||||
!DIR$ LOOP COUNT avg(50000)
|
||||
do i=1,n_doubles,block_size
|
||||
umax = 0.d0
|
||||
if (u_is_sparse) then
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_b = doubles(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
ASSERT (l_b <= N_det)
|
||||
ASSERT (l_a <= N_det)
|
||||
do l=1,N_st
|
||||
utl(l,kk+1) = u_t(l,l_a)
|
||||
umax = max(umax, dabs(utl(l,kk+1)))
|
||||
enddo
|
||||
enddo
|
||||
else
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_b = doubles(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
ASSERT (l_b <= N_det)
|
||||
ASSERT (l_a <= N_det)
|
||||
utl(:,kk+1) = u_t(:,l_a)
|
||||
enddo
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
do kk=0,block_size-1
|
||||
if (i+kk > n_doubles) exit
|
||||
l_b = doubles(i+kk)
|
||||
l_a = psi_bilinear_matrix_transp_order(l_b)
|
||||
lcol = psi_bilinear_matrix_transp_columns(l_b)
|
||||
ASSERT (lcol <= N_det_beta_unique)
|
||||
|
||||
tmp_det2(1:N_int,2) = psi_det_beta_unique(1:N_int, lcol)
|
||||
! call i_H_j( tmp_det, tmp_det2, $N_int, hij)
|
||||
! call i_H_j_double_spin( tmp_det(1,2), psi_det_beta_unique(1, lcol), $N_int, hij)
|
||||
if(do_right)then
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det,tmp_det2,$N_int,hij)
|
||||
else
|
||||
call htilde_mu_mat_opt_bi_ortho_tot(tmp_det2,tmp_det,$N_int,hij)
|
||||
endif
|
||||
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * utl(l,kk+1)
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
|
||||
! Diagonal contribution
|
||||
! =====================
|
||||
|
||||
|
||||
! Initial determinant is at k_a in alpha-major representation
|
||||
! -----------------------------------------------------------------------
|
||||
|
||||
if (u_is_sparse) then
|
||||
umax = 0.d0
|
||||
do l=1,N_st
|
||||
umax = max(umax, dabs(u_t(l,k_a)))
|
||||
enddo
|
||||
else
|
||||
umax = 1.d0
|
||||
endif
|
||||
if (umax < 1.d-20) cycle
|
||||
|
||||
krow = psi_bilinear_matrix_rows(k_a)
|
||||
ASSERT (krow <= N_det_alpha_unique)
|
||||
|
||||
kcol = psi_bilinear_matrix_columns(k_a)
|
||||
ASSERT (kcol <= N_det_beta_unique)
|
||||
|
||||
tmp_det(1:$N_int,1) = psi_det_alpha_unique(1:$N_int, krow)
|
||||
tmp_det(1:$N_int,2) = psi_det_beta_unique (1:$N_int, kcol)
|
||||
|
||||
double precision, external :: diag_H_mat_elem
|
||||
double precision :: hmono, htwoe, hthree
|
||||
|
||||
! hij = diag_H_mat_elem(tmp_det,$N_int)
|
||||
call diag_htilde_mu_mat_fock_bi_ortho ($N_int, tmp_det, hmono, htwoe, hthree, hij)
|
||||
call get_s2(tmp_det,tmp_det,$N_int,sij)
|
||||
|
||||
!DIR$ LOOP COUNT AVG(4)
|
||||
do l=1,N_st
|
||||
v_t(l,k_a) = v_t(l,k_a) + hij * u_t(l,k_a)
|
||||
s_t(l,k_a) = s_t(l,k_a) + sij * u_t(l,k_a)
|
||||
enddo
|
||||
|
||||
end do
|
||||
!$OMP END DO
|
||||
deallocate(buffer, singles_a, singles_b, doubles, idx, utl)
|
||||
!$OMP END PARALLEL
|
||||
|
||||
end
|
||||
|
||||
SUBST [ N_int ]
|
||||
|
||||
1;;
|
||||
2;;
|
||||
3;;
|
||||
4;;
|
||||
N_int;;
|
||||
|
||||
END_TEMPLATE
|
||||
|
||||
|
@ -93,9 +93,6 @@ subroutine H_tc_u_0_nstates_openmp(v_0,u_0,N_st,sze, do_right)
|
||||
double precision, allocatable :: u_t(:,:), v_t(:,:)
|
||||
!DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: u_t
|
||||
allocate(u_t(N_st,N_det),v_t(N_st,N_det))
|
||||
! provide mo_bi_ortho_tc_one_e mo_bi_ortho_tc_two_e
|
||||
! provide ref_tc_energy_tot fock_op_2_e_tc_closed_shell
|
||||
! provide eff_2_e_from_3_e_ab eff_2_e_from_3_e_aa eff_2_e_from_3_e_bb
|
||||
do k=1,N_st
|
||||
call dset_order(u_0(1,k),psi_bilinear_matrix_order,N_det)
|
||||
enddo
|
@ -1,4 +1,4 @@
|
||||
program tc_bi_ortho
|
||||
program print_tc_energy
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! TODO : Put the documentation of the program here
|
||||
@ -10,6 +10,6 @@ program tc_bi_ortho
|
||||
read_wf = .True.
|
||||
touch read_wf
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
call routine_save_left_right_bi_ortho
|
||||
! call test
|
||||
call write_tc_energy
|
||||
end
|
||||
|
@ -17,6 +17,8 @@ BEGIN_PROVIDER [ double precision, psi_bitcleft_bilinear_matrix_values, (N_det,
|
||||
implicit none
|
||||
integer :: k, l
|
||||
|
||||
!print *, ' providing psi_bitcleft_bilinear_matrix_values'
|
||||
|
||||
if(N_det .eq. 1) then
|
||||
|
||||
do l = 1, N_states
|
||||
@ -38,6 +40,8 @@ BEGIN_PROVIDER [ double precision, psi_bitcleft_bilinear_matrix_values, (N_det,
|
||||
|
||||
endif
|
||||
|
||||
!print *, ' psi_bitcleft_bilinear_matrix_values OK'
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
! ---
|
||||
|
@ -136,7 +136,7 @@ BEGIN_PROVIDER [ double precision, psi_r_coef_bi_ortho, (psi_det_size,N_states)
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
subroutine save_tc_wavefunction_general(ndet,nstates,psidet,sze,dim_psicoef,psilcoef,psircoef)
|
||||
subroutine save_tc_wavefunction_general(ndet, nstates, psidet, sze, dim_psicoef, psilcoef, psircoef)
|
||||
implicit none
|
||||
BEGIN_DOC
|
||||
! Save the wave function into the |EZFIO| file
|
||||
@ -192,37 +192,78 @@ subroutine save_tc_wavefunction_general(ndet,nstates,psidet,sze,dim_psicoef,psil
|
||||
endif
|
||||
end
|
||||
|
||||
subroutine save_tc_bi_ortho_wavefunction
|
||||
implicit none
|
||||
if(save_sorted_tc_wf)then
|
||||
call save_tc_wavefunction_general(N_det,N_states,psi_det_sorted_tc,size(psi_det_sorted_tc, 3),size(psi_l_coef_sorted_bi_ortho, 1),psi_l_coef_sorted_bi_ortho,psi_r_coef_sorted_bi_ortho)
|
||||
else
|
||||
call save_tc_wavefunction_general(N_det,N_states,psi_det,size(psi_det, 3), size(psi_l_coef_bi_ortho, 1),psi_l_coef_bi_ortho,psi_r_coef_bi_ortho)
|
||||
endif
|
||||
call routine_save_right_bi_ortho
|
||||
! ---
|
||||
|
||||
subroutine save_tc_bi_ortho_wavefunction()
|
||||
|
||||
implicit none
|
||||
|
||||
if(save_sorted_tc_wf) then
|
||||
|
||||
call save_tc_wavefunction_general( N_det, N_states, psi_det_sorted_tc, size(psi_det_sorted_tc, 3) &
|
||||
, size(psi_l_coef_sorted_bi_ortho, 1), psi_l_coef_sorted_bi_ortho, psi_r_coef_sorted_bi_ortho)
|
||||
call routine_save_right_sorted_bi_ortho()
|
||||
|
||||
else
|
||||
|
||||
call save_tc_wavefunction_general( N_det, N_states, psi_det, size(psi_det, 3) &
|
||||
, size(psi_l_coef_bi_ortho, 1), psi_l_coef_bi_ortho, psi_r_coef_bi_ortho )
|
||||
call routine_save_right_bi_ortho()
|
||||
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
subroutine routine_save_right_bi_ortho
|
||||
implicit none
|
||||
double precision, allocatable :: coef_tmp(:,:)
|
||||
integer :: i
|
||||
allocate(coef_tmp(N_det, N_states))
|
||||
do i = 1, N_det
|
||||
coef_tmp(i,1:N_states) = psi_r_coef_sorted_bi_ortho(i,1:N_states)
|
||||
enddo
|
||||
call save_wavefunction_general_unormalized(N_det,N_states,psi_det_sorted_tc,size(coef_tmp,1),coef_tmp(1,1))
|
||||
end
|
||||
! ---
|
||||
|
||||
subroutine routine_save_right_sorted_bi_ortho()
|
||||
|
||||
implicit none
|
||||
integer :: i
|
||||
double precision, allocatable :: coef_tmp(:,:)
|
||||
|
||||
allocate(coef_tmp(N_det, N_states))
|
||||
do i = 1, N_det
|
||||
coef_tmp(i,1:N_states) = psi_r_coef_sorted_bi_ortho(i,1:N_states)
|
||||
enddo
|
||||
call save_wavefunction_general_unormalized(N_det, N_states, psi_det_sorted_tc, size(coef_tmp, 1), coef_tmp(1,1))
|
||||
deallocate(coef_tmp)
|
||||
|
||||
subroutine routine_save_left_right_bi_ortho
|
||||
implicit none
|
||||
double precision, allocatable :: coef_tmp(:,:)
|
||||
integer :: i,n_states_tmp
|
||||
n_states_tmp = 2
|
||||
allocate(coef_tmp(N_det, n_states_tmp))
|
||||
do i = 1, N_det
|
||||
coef_tmp(i,1) = psi_r_coef_bi_ortho(i,1)
|
||||
coef_tmp(i,2) = psi_l_coef_bi_ortho(i,1)
|
||||
enddo
|
||||
call save_wavefunction_general_unormalized(N_det,n_states_tmp,psi_det,size(coef_tmp,1),coef_tmp(1,1))
|
||||
end
|
||||
|
||||
subroutine routine_save_left_right_sorted_bi_ortho()
|
||||
|
||||
implicit none
|
||||
integer :: i, n_states_tmp
|
||||
double precision, allocatable :: coef_tmp(:,:)
|
||||
|
||||
n_states_tmp = 2
|
||||
allocate(coef_tmp(N_det, n_states_tmp))
|
||||
do i = 1, N_det
|
||||
coef_tmp(i,1) = psi_r_coef_bi_ortho(i,1)
|
||||
coef_tmp(i,2) = psi_l_coef_bi_ortho(i,1)
|
||||
enddo
|
||||
call save_wavefunction_general_unormalized(N_det, n_states_tmp, psi_det, size(coef_tmp, 1), coef_tmp(1,1))
|
||||
deallocate(coef_tmp)
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
subroutine routine_save_right_bi_ortho()
|
||||
|
||||
implicit none
|
||||
integer :: i
|
||||
double precision, allocatable :: coef_tmp(:,:)
|
||||
|
||||
allocate(coef_tmp(N_det, N_states))
|
||||
do i = 1, N_det
|
||||
coef_tmp(i,1:N_states) = psi_r_coef_bi_ortho(i,1:N_states)
|
||||
enddo
|
||||
call save_wavefunction_general_unormalized(N_det, N_states, psi_det, size(coef_tmp, 1), coef_tmp(1,1))
|
||||
deallocate(coef_tmp)
|
||||
|
||||
end
|
||||
|
||||
! ---
|
||||
|
||||
|
||||
|
@ -1,5 +1,18 @@
|
||||
program save_bitcpsileft_for_qmcchem
|
||||
|
||||
implicit none
|
||||
|
||||
read_wf = .True.
|
||||
TOUCH read_wf
|
||||
|
||||
call main()
|
||||
|
||||
end
|
||||
|
||||
|
||||
subroutine main()
|
||||
|
||||
implicit none
|
||||
integer :: iunit
|
||||
logical :: exists
|
||||
double precision :: e_ref
|
||||
@ -46,7 +59,7 @@ program save_bitcpsileft_for_qmcchem
|
||||
|
||||
close(iunit)
|
||||
|
||||
end
|
||||
end subroutine main
|
||||
|
||||
! --
|
||||
|
||||
@ -61,12 +74,18 @@ subroutine write_lr_spindeterminants()
|
||||
|
||||
PROVIDE psi_bitcleft_bilinear_matrix_values
|
||||
|
||||
print *, ' saving left determinants'
|
||||
print *, ' assuming save_for_qmc called before to save right determinants'
|
||||
print *, ' N_det = ', N_det
|
||||
print *, ' N_states = ', N_states
|
||||
|
||||
allocate(buffer(N_det,N_states))
|
||||
do l = 1, N_states
|
||||
do k = 1, N_det
|
||||
buffer(k,l) = psi_bitcleft_bilinear_matrix_values(k,l)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call ezfio_set_spindeterminants_psi_left_coef_matrix_values(buffer)
|
||||
deallocate(buffer)
|
||||
|
@ -1,17 +1,25 @@
|
||||
program tc_bi_ortho
|
||||
implicit none
|
||||
|
||||
BEGIN_DOC
|
||||
! TODO : Reads psi_det in the EZFIO folder and prints out the left- and right-eigenvectors together with the energy. Saves the left-right wave functions at the end.
|
||||
!
|
||||
! TODO : Reads psi_det in the EZFIO folder and prints out the left- and right-eigenvectors together
|
||||
! with the energy. Saves the left-right wave functions at the end.
|
||||
!
|
||||
END_DOC
|
||||
print *, 'Hello world'
|
||||
|
||||
my_grid_becke = .True.
|
||||
my_n_pt_r_grid = 30
|
||||
my_n_pt_a_grid = 50
|
||||
read_wf = .True.
|
||||
touch read_wf
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
call routine_diag
|
||||
call save_tc_bi_ortho_wavefunction
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
|
||||
print*, ' nb of states = ', N_states
|
||||
print*, ' nb of det = ', N_det
|
||||
|
||||
call routine_diag()
|
||||
call write_tc_energy()
|
||||
call save_tc_bi_ortho_wavefunction()
|
||||
end
|
||||
|
||||
subroutine test
|
||||
@ -28,26 +36,53 @@ subroutine test
|
||||
|
||||
end
|
||||
|
||||
subroutine routine_diag
|
||||
implicit none
|
||||
! provide eigval_right_tc_bi_orth
|
||||
! provide overlap_bi_ortho
|
||||
! provide htilde_matrix_elmt_bi_ortho
|
||||
integer ::i,j
|
||||
print*,'eigval_right_tc_bi_orth = ',eigval_right_tc_bi_orth(1)
|
||||
print*,'e_tc_left_right = ',e_tc_left_right
|
||||
print*,'e_tilde_bi_orth_00 = ',e_tilde_bi_orth_00
|
||||
print*,'e_pt2_tc_bi_orth = ',e_pt2_tc_bi_orth
|
||||
print*,'e_pt2_tc_bi_orth_single = ',e_pt2_tc_bi_orth_single
|
||||
print*,'e_pt2_tc_bi_orth_double = ',e_pt2_tc_bi_orth_double
|
||||
print*,'***'
|
||||
print*,'e_corr_bi_orth = ',e_corr_bi_orth
|
||||
print*,'e_corr_bi_orth_proj = ',e_corr_bi_orth_proj
|
||||
print*,'e_corr_single_bi_orth = ',e_corr_single_bi_orth
|
||||
print*,'e_corr_double_bi_orth = ',e_corr_double_bi_orth
|
||||
print*,'Left/right eigenvectors'
|
||||
do i = 1,N_det
|
||||
write(*,'(I5,X,(100(F12.7,X)))')i,leigvec_tc_bi_orth(i,1),reigvec_tc_bi_orth(i,1),leigvec_tc_bi_orth(i,1)*reigvec_tc_bi_orth(i,1)
|
||||
enddo
|
||||
subroutine routine_diag()
|
||||
|
||||
implicit none
|
||||
integer :: i, j, k
|
||||
double precision :: dE
|
||||
|
||||
! provide eigval_right_tc_bi_orth
|
||||
! provide overlap_bi_ortho
|
||||
! provide htilde_matrix_elmt_bi_ortho
|
||||
|
||||
if(N_states .eq. 1) then
|
||||
|
||||
print*,'eigval_right_tc_bi_orth = ',eigval_right_tc_bi_orth(1)
|
||||
print*,'e_tc_left_right = ',e_tc_left_right
|
||||
print*,'e_tilde_bi_orth_00 = ',e_tilde_bi_orth_00
|
||||
print*,'e_pt2_tc_bi_orth = ',e_pt2_tc_bi_orth
|
||||
print*,'e_pt2_tc_bi_orth_single = ',e_pt2_tc_bi_orth_single
|
||||
print*,'e_pt2_tc_bi_orth_double = ',e_pt2_tc_bi_orth_double
|
||||
print*,'***'
|
||||
print*,'e_corr_bi_orth = ',e_corr_bi_orth
|
||||
print*,'e_corr_bi_orth_proj = ',e_corr_bi_orth_proj
|
||||
print*,'e_corr_single_bi_orth = ',e_corr_single_bi_orth
|
||||
print*,'e_corr_double_bi_orth = ',e_corr_double_bi_orth
|
||||
print*,'Left/right eigenvectors'
|
||||
do i = 1,N_det
|
||||
write(*,'(I5,X,(100(F12.7,X)))')i,leigvec_tc_bi_orth(i,1),reigvec_tc_bi_orth(i,1),leigvec_tc_bi_orth(i,1)*reigvec_tc_bi_orth(i,1)
|
||||
enddo
|
||||
|
||||
else
|
||||
|
||||
print*,'eigval_right_tc_bi_orth : '
|
||||
do i = 1, N_states
|
||||
print*, i, eigval_right_tc_bi_orth(i)
|
||||
enddo
|
||||
|
||||
print*,''
|
||||
print*,'******************************************************'
|
||||
print*,'TC Excitation energies (au) (eV)'
|
||||
do i = 2, N_states
|
||||
dE = eigval_right_tc_bi_orth(i) - eigval_right_tc_bi_orth(1)
|
||||
print*, i, dE, dE/0.0367502d0
|
||||
enddo
|
||||
print*,''
|
||||
|
||||
endif
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
@ -25,8 +25,6 @@ subroutine diagonalize_CI_tc
|
||||
psi_r_coef_bi_ortho(i,j) = reigvec_tc_bi_orth(i,j)
|
||||
enddo
|
||||
enddo
|
||||
! psi_energy(1:N_states) = CI_electronic_energy(1:N_states)
|
||||
! psi_s2(1:N_states) = CI_s2(1:N_states)
|
||||
|
||||
SOFT_TOUCH psi_l_coef_bi_ortho psi_r_coef_bi_ortho
|
||||
end
|
||||
@ -37,6 +35,7 @@ end
|
||||
&BEGIN_PROVIDER [double precision, eigval_left_tc_bi_orth, (N_states)]
|
||||
&BEGIN_PROVIDER [double precision, reigvec_tc_bi_orth, (N_det,N_states)]
|
||||
&BEGIN_PROVIDER [double precision, leigvec_tc_bi_orth, (N_det,N_states)]
|
||||
&BEGIN_PROVIDER [double precision, s2_eigvec_tc_bi_orth, (N_states)]
|
||||
&BEGIN_PROVIDER [double precision, norm_ground_left_right_bi_orth ]
|
||||
|
||||
BEGIN_DOC
|
||||
@ -44,159 +43,335 @@ end
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer :: i, idx_dress, j, istate
|
||||
integer :: i, idx_dress, j, istate, k
|
||||
logical :: converged, dagger
|
||||
integer :: n_real_tc_bi_orth_eigval_right,igood_r,igood_l
|
||||
double precision, allocatable :: reigvec_tc_bi_orth_tmp(:,:),leigvec_tc_bi_orth_tmp(:,:),eigval_right_tmp(:)
|
||||
double precision, allocatable :: s2_values_tmp(:), H_prime(:,:), expect_e(:)
|
||||
double precision, parameter :: alpha = 0.1d0
|
||||
integer :: i_good_state,i_other_state, i_state
|
||||
integer, allocatable :: index_good_state_array(:)
|
||||
logical, allocatable :: good_state_array(:)
|
||||
double precision, allocatable :: coef_hf_r(:),coef_hf_l(:)
|
||||
double precision, allocatable :: Stmp(:,:)
|
||||
integer, allocatable :: iorder(:)
|
||||
|
||||
PROVIDE N_det N_int
|
||||
|
||||
if(n_det.le.N_det_max_full)then
|
||||
allocate(reigvec_tc_bi_orth_tmp(N_det,N_det),leigvec_tc_bi_orth_tmp(N_det,N_det),eigval_right_tmp(N_det))
|
||||
call non_hrmt_real_diag(N_det,htilde_matrix_elmt_bi_ortho,&
|
||||
leigvec_tc_bi_orth_tmp,reigvec_tc_bi_orth_tmp,&
|
||||
n_real_tc_bi_orth_eigval_right,eigval_right_tmp)
|
||||
double precision, allocatable :: coef_hf_r(:),coef_hf_l(:)
|
||||
integer, allocatable :: iorder(:)
|
||||
allocate(coef_hf_r(N_det),coef_hf_l(N_det),iorder(N_det))
|
||||
do i = 1,N_det
|
||||
iorder(i) = i
|
||||
coef_hf_r(i) = -dabs(reigvec_tc_bi_orth_tmp(index_HF_psi_det,i))
|
||||
enddo
|
||||
call dsort(coef_hf_r,iorder,N_det)
|
||||
igood_r = iorder(1)
|
||||
print*,'igood_r, coef_hf_r = ',igood_r,coef_hf_r(1)
|
||||
do i = 1,N_det
|
||||
iorder(i) = i
|
||||
coef_hf_l(i) = -dabs(leigvec_tc_bi_orth_tmp(index_HF_psi_det,i))
|
||||
enddo
|
||||
call dsort(coef_hf_l,iorder,N_det)
|
||||
igood_l = iorder(1)
|
||||
print*,'igood_l, coef_hf_l = ',igood_l,coef_hf_l(1)
|
||||
if(n_det .le. N_det_max_full) then
|
||||
|
||||
if(igood_r.ne.igood_l.and.igood_r.ne.1)then
|
||||
print *,''
|
||||
print *,'Warning, the left and right eigenvectors are "not the same" '
|
||||
print *,'Warning, the ground state is not dominated by HF...'
|
||||
print *,'State with largest RIGHT coefficient of HF ',igood_r
|
||||
print *,'coef of HF in RIGHT eigenvector = ',reigvec_tc_bi_orth_tmp(index_HF_psi_det,igood_r)
|
||||
print *,'State with largest LEFT coefficient of HF ',igood_l
|
||||
print *,'coef of HF in LEFT eigenvector = ',leigvec_tc_bi_orth_tmp(index_HF_psi_det,igood_l)
|
||||
allocate(reigvec_tc_bi_orth_tmp(N_det,N_det),leigvec_tc_bi_orth_tmp(N_det,N_det),eigval_right_tmp(N_det),expect_e(N_det))
|
||||
allocate (H_prime(N_det,N_det),s2_values_tmp(N_det))
|
||||
|
||||
H_prime(1:N_det,1:N_det) = htilde_matrix_elmt_bi_ortho(1:N_det,1:N_det)
|
||||
if(s2_eig) then
|
||||
H_prime(1:N_det,1:N_det) += alpha * S2_matrix_all_dets(1:N_det,1:N_det)
|
||||
do j=1,N_det
|
||||
H_prime(j,j) = H_prime(j,j) - alpha*expected_s2
|
||||
enddo
|
||||
endif
|
||||
if(state_following_tc)then
|
||||
print *,'Following the states with the largest coef on HF'
|
||||
print *,'igood_r,igood_l',igood_r,igood_l
|
||||
i= igood_r
|
||||
eigval_right_tc_bi_orth(1) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
reigvec_tc_bi_orth(j,1) = reigvec_tc_bi_orth_tmp(j,i)
|
||||
! print*,reigvec_tc_bi_orth(j,1)
|
||||
enddo
|
||||
i= igood_l
|
||||
eigval_left_tc_bi_orth(1) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
leigvec_tc_bi_orth(j,1) = leigvec_tc_bi_orth_tmp(j,i)
|
||||
enddo
|
||||
else
|
||||
do i = 1, N_states
|
||||
eigval_right_tc_bi_orth(i) = eigval_right_tmp(i)
|
||||
eigval_left_tc_bi_orth(i) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
reigvec_tc_bi_orth(j,i) = reigvec_tc_bi_orth_tmp(j,i)
|
||||
leigvec_tc_bi_orth(j,i) = leigvec_tc_bi_orth_tmp(j,i)
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call non_hrmt_real_diag(N_det, H_prime, leigvec_tc_bi_orth_tmp, reigvec_tc_bi_orth_tmp, n_real_tc_bi_orth_eigval_right, eigval_right_tmp)
|
||||
! do i = 1, N_det
|
||||
! call get_H_tc_s2_l0_r0(leigvec_tc_bi_orth_tmp(1,i),reigvec_tc_bi_orth_tmp(1,i),1,N_det,expect_e(i), s2_values_tmp(i))
|
||||
! enddo
|
||||
call get_H_tc_s2_l0_r0(leigvec_tc_bi_orth_tmp,reigvec_tc_bi_orth_tmp,N_det,N_det,expect_e, s2_values_tmp)
|
||||
|
||||
allocate(index_good_state_array(N_det),good_state_array(N_det))
|
||||
i_state = 0
|
||||
good_state_array = .False.
|
||||
|
||||
if(s2_eig) then
|
||||
|
||||
if(only_expected_s2) then
|
||||
do j = 1, N_det
|
||||
! Select at least n_states states with S^2 values closed to "expected_s2"
|
||||
! print*,'s2_values_tmp(j) = ',s2_values_tmp(j),eigval_right_tmp(j),expect_e(j)
|
||||
if(dabs(s2_values_tmp(j) - expected_s2).le.0.5d0)then
|
||||
i_state +=1
|
||||
index_good_state_array(i_state) = j
|
||||
good_state_array(j) = .True.
|
||||
endif
|
||||
if(i_state.eq.N_states) then
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
else
|
||||
do j = 1, N_det
|
||||
index_good_state_array(j) = j
|
||||
good_state_array(j) = .True.
|
||||
enddo
|
||||
endif
|
||||
|
||||
if(i_state .ne. 0) then
|
||||
! Fill the first "i_state" states that have a correct S^2 value
|
||||
do j = 1, i_state
|
||||
do i = 1, N_det
|
||||
reigvec_tc_bi_orth(i,j) = reigvec_tc_bi_orth_tmp(i,index_good_state_array(j))
|
||||
leigvec_tc_bi_orth(i,j) = leigvec_tc_bi_orth_tmp(i,index_good_state_array(j))
|
||||
enddo
|
||||
eigval_right_tc_bi_orth(j) = expect_e(index_good_state_array(j))
|
||||
eigval_left_tc_bi_orth(j) = expect_e(index_good_state_array(j))
|
||||
s2_eigvec_tc_bi_orth(j) = s2_values_tmp(index_good_state_array(j))
|
||||
enddo
|
||||
i_other_state = 0
|
||||
do j = 1, N_det
|
||||
if(good_state_array(j))cycle
|
||||
i_other_state +=1
|
||||
if(i_state+i_other_state.gt.n_states)then
|
||||
exit
|
||||
endif
|
||||
do i = 1, N_det
|
||||
reigvec_tc_bi_orth(i,i_state+i_other_state) = reigvec_tc_bi_orth_tmp(i,j)
|
||||
leigvec_tc_bi_orth(i,i_state+i_other_state) = leigvec_tc_bi_orth_tmp(i,j)
|
||||
enddo
|
||||
eigval_right_tc_bi_orth(i_state+i_other_state) = eigval_right_tmp(j)
|
||||
eigval_left_tc_bi_orth (i_state+i_other_state) = eigval_right_tmp(j)
|
||||
s2_eigvec_tc_bi_orth(i_state+i_other_state) = s2_values_tmp(i_state+i_other_state)
|
||||
enddo
|
||||
else ! istate == 0
|
||||
print*,''
|
||||
print*,'!!!!!!!! WARNING !!!!!!!!!'
|
||||
print*,' Within the ',N_det,'determinants selected'
|
||||
print*,' and the ',N_states_diag,'states requested'
|
||||
print*,' We did not find only states with S^2 values close to ',expected_s2
|
||||
print*,' We will then set the first N_states eigenvectors of the H matrix'
|
||||
print*,' as the CI_eigenvectors'
|
||||
print*,' You should consider more states and maybe ask for s2_eig to be .True. or just enlarge the CI space'
|
||||
print*,''
|
||||
do j = 1, min(N_states_diag, N_det)
|
||||
do i = 1, N_det
|
||||
leigvec_tc_bi_orth(i,j) = leigvec_tc_bi_orth_tmp(i,j)
|
||||
reigvec_tc_bi_orth(i,j) = reigvec_tc_bi_orth_tmp(i,j)
|
||||
enddo
|
||||
eigval_right_tc_bi_orth(j) = eigval_right_tmp(j)
|
||||
eigval_left_tc_bi_orth (j) = eigval_right_tmp(j)
|
||||
s2_eigvec_tc_bi_orth(j) = s2_values_tmp(j)
|
||||
enddo
|
||||
endif ! istate .ne. 0
|
||||
|
||||
else ! s2_eig
|
||||
|
||||
allocate(coef_hf_r(N_det),coef_hf_l(N_det),iorder(N_det))
|
||||
do i = 1,N_det
|
||||
iorder(i) = i
|
||||
coef_hf_r(i) = -dabs(reigvec_tc_bi_orth_tmp(index_HF_psi_det,i))
|
||||
enddo
|
||||
call dsort(coef_hf_r,iorder,N_det)
|
||||
igood_r = iorder(1)
|
||||
print*,'igood_r, coef_hf_r = ',igood_r,coef_hf_r(1)
|
||||
do i = 1,N_det
|
||||
iorder(i) = i
|
||||
coef_hf_l(i) = -dabs(leigvec_tc_bi_orth_tmp(index_HF_psi_det,i))
|
||||
enddo
|
||||
call dsort(coef_hf_l,iorder,N_det)
|
||||
igood_l = iorder(1)
|
||||
print*,'igood_l, coef_hf_l = ',igood_l,coef_hf_l(1)
|
||||
|
||||
if(igood_r.ne.igood_l .and. igood_r.ne.1) then
|
||||
print *,''
|
||||
print *,'Warning, the left and right eigenvectors are "not the same" '
|
||||
print *,'Warning, the ground state is not dominated by HF...'
|
||||
print *,'State with largest RIGHT coefficient of HF ',igood_r
|
||||
print *,'coef of HF in RIGHT eigenvector = ',reigvec_tc_bi_orth_tmp(index_HF_psi_det,igood_r)
|
||||
print *,'State with largest LEFT coefficient of HF ',igood_l
|
||||
print *,'coef of HF in LEFT eigenvector = ',leigvec_tc_bi_orth_tmp(index_HF_psi_det,igood_l)
|
||||
endif
|
||||
|
||||
if(state_following_tc) then
|
||||
print *,'Following the states with the largest coef on HF'
|
||||
print *,'igood_r,igood_l',igood_r,igood_l
|
||||
i = igood_r
|
||||
eigval_right_tc_bi_orth(1) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
reigvec_tc_bi_orth(j,1) = reigvec_tc_bi_orth_tmp(j,i)
|
||||
enddo
|
||||
i = igood_l
|
||||
eigval_left_tc_bi_orth(1) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
leigvec_tc_bi_orth(j,1) = leigvec_tc_bi_orth_tmp(j,i)
|
||||
enddo
|
||||
else
|
||||
do i = 1, N_states
|
||||
eigval_right_tc_bi_orth(i) = eigval_right_tmp(i)
|
||||
eigval_left_tc_bi_orth(i) = eigval_right_tmp(i)
|
||||
do j = 1, N_det
|
||||
reigvec_tc_bi_orth(j,i) = reigvec_tc_bi_orth_tmp(j,i)
|
||||
leigvec_tc_bi_orth(j,i) = leigvec_tc_bi_orth_tmp(j,i)
|
||||
enddo
|
||||
enddo
|
||||
endif
|
||||
|
||||
endif
|
||||
else
|
||||
|
||||
else ! n_det > N_det_max_full
|
||||
|
||||
double precision, allocatable :: H_jj(:),vec_tmp(:,:)
|
||||
external htc_bi_ortho_calc_tdav
|
||||
external htcdag_bi_ortho_calc_tdav
|
||||
external H_tc_u_0_opt
|
||||
external H_tc_dagger_u_0_opt
|
||||
external H_tc_s2_dagger_u_0_opt
|
||||
external H_tc_s2_u_0_opt
|
||||
|
||||
allocate(H_jj(N_det),vec_tmp(N_det,n_states_diag))
|
||||
|
||||
do i = 1, N_det
|
||||
call htilde_mu_mat_bi_ortho_tot(psi_det(1,1,i), psi_det(1,1,i), N_int, H_jj(i))
|
||||
enddo
|
||||
!!!! Preparing the left-eigenvector
|
||||
|
||||
print*,'---------------------------------'
|
||||
print*,'---------------------------------'
|
||||
print*,'Computing the left-eigenvector '
|
||||
print*,'---------------------------------'
|
||||
print*,'---------------------------------'
|
||||
!!!! Preparing the left-eigenvector
|
||||
vec_tmp = 0.d0
|
||||
do istate = 1, N_states
|
||||
vec_tmp(1:N_det,istate) = psi_l_coef_bi_ortho(1:N_det,istate)
|
||||
vec_tmp(1:N_det,istate) = psi_l_coef_bi_ortho(1:N_det,istate)
|
||||
enddo
|
||||
do istate = N_states+1, n_states_diag
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
enddo
|
||||
!call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_left_tc_bi_orth, N_det, n_states, n_states_diag, converged, htcdag_bi_ortho_calc_tdav)
|
||||
!call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_left_tc_bi_orth, N_det, n_states, n_states_diag, converged, H_tc_dagger_u_0_opt)
|
||||
integer :: n_it_max,i_it
|
||||
n_it_max = 1
|
||||
converged = .False.
|
||||
i_it = 0
|
||||
do while (.not.converged)
|
||||
call davidson_hs2_nonsym_b1space(vec_tmp, H_jj, s2_eigvec_tc_bi_orth, eigval_left_tc_bi_orth, N_det, n_states, n_states_diag, n_it_max, converged, H_tc_s2_dagger_u_0_opt)
|
||||
i_it += 1
|
||||
if(i_it .gt. 5) exit
|
||||
enddo
|
||||
! call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_left_tc_bi_orth, N_det, n_states, n_states_diag, converged, htcdag_bi_ortho_calc_tdav)
|
||||
call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_left_tc_bi_orth, N_det, n_states, n_states_diag, converged, H_tc_dagger_u_0_opt)
|
||||
do istate = 1, N_states
|
||||
leigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
leigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
enddo
|
||||
|
||||
print*,'---------------------------------'
|
||||
print*,'---------------------------------'
|
||||
print*,'Computing the right-eigenvector '
|
||||
!!!! Preparing the right-eigenvector
|
||||
print*,'---------------------------------'
|
||||
print*,'---------------------------------'
|
||||
!!!! Preparing the right-eigenvector
|
||||
vec_tmp = 0.d0
|
||||
do istate = 1, N_states
|
||||
vec_tmp(1:N_det,istate) = psi_r_coef_bi_ortho(1:N_det,istate)
|
||||
vec_tmp(1:N_det,istate) = psi_r_coef_bi_ortho(1:N_det,istate)
|
||||
enddo
|
||||
do istate = N_states+1, n_states_diag
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
enddo
|
||||
!call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_right_tc_bi_orth, N_det, n_states, n_states_diag, converged, htc_bi_ortho_calc_tdav)
|
||||
!call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_right_tc_bi_orth, N_det, n_states, n_states_diag, converged, H_tc_u_0_opt)
|
||||
converged = .False.
|
||||
i_it = 0
|
||||
do while (.not. converged)
|
||||
call davidson_hs2_nonsym_b1space(vec_tmp, H_jj, s2_eigvec_tc_bi_orth, eigval_right_tc_bi_orth, N_det, n_states, n_states_diag, n_it_max, converged, H_tc_s2_u_0_opt)
|
||||
i_it += 1
|
||||
if(i_it .gt. 5) exit
|
||||
enddo
|
||||
! call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_right_tc_bi_orth, N_det, n_states, n_states_diag, converged, htc_bi_ortho_calc_tdav)
|
||||
call davidson_general_ext_rout_nonsym_b1space(vec_tmp, H_jj, eigval_right_tc_bi_orth, N_det, n_states, n_states_diag, converged, H_tc_u_0_opt)
|
||||
do istate = 1, N_states
|
||||
reigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
reigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
enddo
|
||||
|
||||
deallocate(H_jj)
|
||||
endif
|
||||
call bi_normalize(leigvec_tc_bi_orth,reigvec_tc_bi_orth,size(reigvec_tc_bi_orth,1),N_det,N_states)
|
||||
print*,'leigvec_tc_bi_orth(1,1),reigvec_tc_bi_orth(1,1) = ',leigvec_tc_bi_orth(1,1),reigvec_tc_bi_orth(1,1)
|
||||
norm_ground_left_right_bi_orth = 0.d0
|
||||
do j = 1, N_det
|
||||
norm_ground_left_right_bi_orth += leigvec_tc_bi_orth(j,1) * reigvec_tc_bi_orth(j,1)
|
||||
enddo
|
||||
print*,'norm l/r = ',norm_ground_left_right_bi_orth
|
||||
endif
|
||||
|
||||
call bi_normalize(leigvec_tc_bi_orth, reigvec_tc_bi_orth, size(reigvec_tc_bi_orth, 1), N_det, N_states)
|
||||
! check bi-orthogonality
|
||||
allocate(Stmp(N_states,N_states))
|
||||
call dgemm( 'T', 'N', N_states, N_states, N_det, 1.d0 &
|
||||
, leigvec_tc_bi_orth(1,1), size(leigvec_tc_bi_orth, 1), reigvec_tc_bi_orth(1,1), size(reigvec_tc_bi_orth, 1) &
|
||||
, 0.d0, Stmp(1,1), size(Stmp, 1) )
|
||||
print *, ' overlap matrix between states:'
|
||||
do i = 1, N_states
|
||||
write(*,'(1000(F16.10,X))') Stmp(i,:)
|
||||
enddo
|
||||
deallocate(Stmp)
|
||||
|
||||
print*,'leigvec_tc_bi_orth(1,1),reigvec_tc_bi_orth(1,1) = ', leigvec_tc_bi_orth(1,1), reigvec_tc_bi_orth(1,1)
|
||||
do i = 1, N_states
|
||||
norm_ground_left_right_bi_orth = 0.d0
|
||||
do j = 1, N_det
|
||||
norm_ground_left_right_bi_orth += leigvec_tc_bi_orth(j,i) * reigvec_tc_bi_orth(j,i)
|
||||
enddo
|
||||
print*,' state ', i
|
||||
print*,' norm l/r = ', norm_ground_left_right_bi_orth
|
||||
print*,' <S2> = ', s2_eigvec_tc_bi_orth(i)
|
||||
enddo
|
||||
|
||||
double precision, allocatable :: buffer(:,:)
|
||||
allocate(buffer(N_det,N_states))
|
||||
do k = 1, N_states
|
||||
do i = 1, N_det
|
||||
psi_l_coef_bi_ortho(i,k) = leigvec_tc_bi_orth(i,k)
|
||||
buffer(i,k) = leigvec_tc_bi_orth(i,k)
|
||||
enddo
|
||||
enddo
|
||||
TOUCH psi_l_coef_bi_ortho
|
||||
call ezfio_set_tc_bi_ortho_psi_l_coef_bi_ortho(buffer)
|
||||
do k = 1, N_states
|
||||
do i = 1, N_det
|
||||
psi_r_coef_bi_ortho(i,k) = reigvec_tc_bi_orth(i,k)
|
||||
buffer(i,k) = reigvec_tc_bi_orth(i,k)
|
||||
enddo
|
||||
enddo
|
||||
TOUCH psi_r_coef_bi_ortho
|
||||
call ezfio_set_tc_bi_ortho_psi_r_coef_bi_ortho(buffer)
|
||||
deallocate(buffer)
|
||||
|
||||
END_PROVIDER
|
||||
|
||||
|
||||
|
||||
subroutine bi_normalize(u_l,u_r,n,ld,nstates)
|
||||
subroutine bi_normalize(u_l, u_r, n, ld, nstates)
|
||||
|
||||
BEGIN_DOC
|
||||
!!!! Normalization of the scalar product of the left/right eigenvectors
|
||||
END_DOC
|
||||
|
||||
implicit none
|
||||
integer, intent(in) :: n, ld, nstates
|
||||
double precision, intent(inout) :: u_l(ld,nstates), u_r(ld,nstates)
|
||||
integer, intent(in) :: n,ld,nstates
|
||||
integer :: i
|
||||
double precision :: accu, tmp
|
||||
integer :: i, j
|
||||
double precision :: accu, tmp
|
||||
|
||||
do i = 1, nstates
|
||||
!!!! Normalization of right eigenvectors |Phi>
|
||||
accu = 0.d0
|
||||
do j = 1, n
|
||||
accu += u_r(j,i) * u_r(j,i)
|
||||
enddo
|
||||
accu = 1.d0/dsqrt(accu)
|
||||
print*,'accu_r = ',accu
|
||||
do j = 1, n
|
||||
u_r(j,i) *= accu
|
||||
enddo
|
||||
tmp = u_r(1,i) / dabs(u_r(1,i))
|
||||
do j = 1, n
|
||||
u_r(j,i) *= tmp
|
||||
enddo
|
||||
!!!! Adaptation of the norm of the left eigenvector such that <chi|Phi> = 1
|
||||
accu = 0.d0
|
||||
do j = 1, n
|
||||
accu += u_l(j,i) * u_r(j,i)
|
||||
! print*,j, u_l(j,i) , u_r(j,i)
|
||||
enddo
|
||||
if(accu.gt.0.d0)then
|
||||
|
||||
!!!! Normalization of right eigenvectors |Phi>
|
||||
accu = 0.d0
|
||||
do j = 1, n
|
||||
accu += u_r(j,i) * u_r(j,i)
|
||||
enddo
|
||||
accu = 1.d0/dsqrt(accu)
|
||||
else
|
||||
accu = 1.d0/dsqrt(-accu)
|
||||
endif
|
||||
tmp = (u_l(1,i) * u_r(1,i) )/dabs(u_l(1,i) * u_r(1,i))
|
||||
do j = 1, n
|
||||
u_l(j,i) *= accu * tmp
|
||||
u_r(j,i) *= accu
|
||||
enddo
|
||||
print*,'accu_r = ',accu
|
||||
do j = 1, n
|
||||
u_r(j,i) *= accu
|
||||
enddo
|
||||
tmp = u_r(1,i) / dabs(u_r(1,i))
|
||||
do j = 1, n
|
||||
u_r(j,i) *= tmp
|
||||
enddo
|
||||
|
||||
!!!! Adaptation of the norm of the left eigenvector such that <chi|Phi> = 1
|
||||
accu = 0.d0
|
||||
do j = 1, n
|
||||
accu += u_l(j,i) * u_r(j,i)
|
||||
!print*,j, u_l(j,i) , u_r(j,i)
|
||||
enddo
|
||||
print*,'accu_lr = ', accu
|
||||
if(accu.gt.0.d0)then
|
||||
accu = 1.d0/dsqrt(accu)
|
||||
else
|
||||
accu = 1.d0/dsqrt(-accu)
|
||||
endif
|
||||
tmp = (u_l(1,i) * u_r(1,i) )/dabs(u_l(1,i) * u_r(1,i))
|
||||
do j = 1, n
|
||||
u_l(j,i) *= accu * tmp
|
||||
u_r(j,i) *= accu
|
||||
enddo
|
||||
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
|
@ -12,6 +12,11 @@
|
||||
double precision :: hmono,htwoe,hthree,htot
|
||||
|
||||
PROVIDE N_int
|
||||
|
||||
i = 1
|
||||
j = 1
|
||||
call htilde_mu_mat_bi_ortho(psi_det(1,1,j), psi_det(1,1,i), N_int, hmono, htwoe, hthree, htot)
|
||||
|
||||
!$OMP PARALLEL DO SCHEDULE(GUIDED) DEFAULT(NONE) PRIVATE(i,j,hmono, htwoe, hthree, htot) &
|
||||
!$OMP SHARED (N_det, psi_det, N_int,htilde_matrix_elmt_bi_ortho)
|
||||
do i = 1, N_det
|
||||
|
34
src/tc_bi_ortho/tc_utils.irp.f
Normal file
34
src/tc_bi_ortho/tc_utils.irp.f
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
subroutine write_tc_energy()
|
||||
|
||||
implicit none
|
||||
integer :: i, j, k
|
||||
double precision :: hmono, htwoe, hthree, htot
|
||||
double precision :: E_TC, O_TC
|
||||
|
||||
do k = 1, n_states
|
||||
|
||||
E_TC = 0.d0
|
||||
do i = 1, N_det
|
||||
do j = 1, N_det
|
||||
!htot = htilde_matrix_elmt_bi_ortho(i,j)
|
||||
call htilde_mu_mat_bi_ortho(psi_det(1,1,i), psi_det(1,1,j), N_int, hmono, htwoe, hthree, htot)
|
||||
E_TC = E_TC + psi_l_coef_bi_ortho(i,k) * psi_r_coef_bi_ortho(j,k) * htot
|
||||
!E_TC = E_TC + leigvec_tc_bi_orth(i,k) * reigvec_tc_bi_orth(j,k) * htot
|
||||
enddo
|
||||
enddo
|
||||
|
||||
O_TC = 0.d0
|
||||
do i = 1, N_det
|
||||
!O_TC = O_TC + leigvec_tc_bi_orth(i,k) * reigvec_tc_bi_orth(i,k)
|
||||
O_TC = O_TC + psi_l_coef_bi_ortho(i,k) * psi_r_coef_bi_ortho(i,k)
|
||||
enddo
|
||||
|
||||
print *, ' state :', k
|
||||
print *, " E_TC = ", E_TC / O_TC
|
||||
print *, " O_TC = ", O_TC
|
||||
|
||||
enddo
|
||||
|
||||
end
|
||||
|
162
src/tc_bi_ortho/test_s2_tc.irp.f
Normal file
162
src/tc_bi_ortho/test_s2_tc.irp.f
Normal file
@ -0,0 +1,162 @@
|
||||
program test_tc
|
||||
implicit none
|
||||
read_wf = .True.
|
||||
my_grid_becke = .True.
|
||||
my_n_pt_r_grid = 30
|
||||
my_n_pt_a_grid = 50
|
||||
read_wf = .True.
|
||||
touch read_wf
|
||||
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
|
||||
call routine_test_s2
|
||||
call routine_test_s2_davidson
|
||||
end
|
||||
|
||||
subroutine routine_test_s2
|
||||
implicit none
|
||||
logical :: do_right
|
||||
integer :: sze ,i, N_st, j
|
||||
double precision :: sij, accu_e, accu_s, accu_e_0, accu_s_0
|
||||
double precision, allocatable :: v_0_ref(:,:),u_0(:,:),s_0_ref(:,:)
|
||||
double precision, allocatable :: v_0_new(:,:),s_0_new(:,:)
|
||||
sze = N_det
|
||||
N_st = 1
|
||||
allocate(v_0_ref(N_det,1),u_0(N_det,1),s_0_ref(N_det,1),s_0_new(N_det,1),v_0_new(N_det,1))
|
||||
print*,'Checking first the Left '
|
||||
do_right = .False.
|
||||
do i = 1, sze
|
||||
u_0(i,1) = psi_l_coef_bi_ortho(i,1)
|
||||
enddo
|
||||
call H_tc_u_0_nstates_openmp(v_0_ref,u_0,N_st,sze, do_right)
|
||||
s_0_ref = 0.d0
|
||||
do i = 1, sze
|
||||
do j = 1, sze
|
||||
call get_s2(psi_det(1,1,i),psi_det(1,1,j),N_int,sij)
|
||||
s_0_ref(i,1) += u_0(j,1) * sij
|
||||
enddo
|
||||
enddo
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0_new,s_0_new,u_0,N_st,sze, do_right)
|
||||
accu_e = 0.d0
|
||||
accu_s = 0.d0
|
||||
accu_e_0 = 0.d0
|
||||
accu_s_0 = 0.d0
|
||||
do i = 1, sze
|
||||
accu_e_0 += v_0_ref(i,1) * psi_r_coef_bi_ortho(i,1)
|
||||
accu_s_0 += s_0_ref(i,1) * psi_r_coef_bi_ortho(i,1)
|
||||
accu_e += dabs(v_0_ref(i,1) - v_0_new(i,1))
|
||||
accu_s += dabs(s_0_ref(i,1) - s_0_new(i,1))
|
||||
enddo
|
||||
print*,'accu_e = ',accu_e
|
||||
print*,'accu_s = ',accu_s
|
||||
print*,'accu_e_0 = ',accu_e_0
|
||||
print*,'accu_s_0 = ',accu_s_0
|
||||
|
||||
print*,'Checking then the right '
|
||||
do_right = .True.
|
||||
do i = 1, sze
|
||||
u_0(i,1) = psi_r_coef_bi_ortho(i,1)
|
||||
enddo
|
||||
call H_tc_u_0_nstates_openmp(v_0_ref,u_0,N_st,sze, do_right)
|
||||
s_0_ref = 0.d0
|
||||
do i = 1, sze
|
||||
do j = 1, sze
|
||||
call get_s2(psi_det(1,1,i),psi_det(1,1,j),N_int,sij)
|
||||
s_0_ref(i,1) += u_0(j,1) * sij
|
||||
enddo
|
||||
enddo
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0_new,s_0_new,u_0,N_st,sze, do_right)
|
||||
accu_e = 0.d0
|
||||
accu_s = 0.d0
|
||||
accu_e_0 = 0.d0
|
||||
accu_s_0 = 0.d0
|
||||
do i = 1, sze
|
||||
accu_e_0 += v_0_ref(i,1) * psi_l_coef_bi_ortho(i,1)
|
||||
accu_s_0 += s_0_ref(i,1) * psi_l_coef_bi_ortho(i,1)
|
||||
accu_e += dabs(v_0_ref(i,1) - v_0_new(i,1))
|
||||
accu_s += dabs(s_0_ref(i,1) - s_0_new(i,1))
|
||||
enddo
|
||||
print*,'accu_e = ',accu_e
|
||||
print*,'accu_s = ',accu_s
|
||||
print*,'accu_e_0 = ',accu_e_0
|
||||
print*,'accu_s_0 = ',accu_s_0
|
||||
|
||||
|
||||
end
|
||||
|
||||
subroutine routine_test_s2_davidson
|
||||
implicit none
|
||||
double precision, allocatable :: H_jj(:),vec_tmp(:,:), energies(:) , s2(:)
|
||||
integer :: i,istate
|
||||
logical :: converged
|
||||
external H_tc_s2_dagger_u_0_opt
|
||||
external H_tc_s2_u_0_opt
|
||||
allocate(H_jj(N_det),vec_tmp(N_det,n_states_diag),energies(n_states_diag), s2(n_states_diag))
|
||||
do i = 1, N_det
|
||||
call htilde_mu_mat_bi_ortho_tot(psi_det(1,1,i), psi_det(1,1,i), N_int, H_jj(i))
|
||||
enddo
|
||||
! Preparing the left-eigenvector
|
||||
print*,'Computing the left-eigenvector '
|
||||
vec_tmp = 0.d0
|
||||
do istate = 1, N_states
|
||||
vec_tmp(1:N_det,istate) = psi_l_coef_bi_ortho(1:N_det,istate)
|
||||
enddo
|
||||
do istate = N_states+1, n_states_diag
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
enddo
|
||||
do istate = 1, N_states
|
||||
leigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
enddo
|
||||
integer :: n_it_max
|
||||
n_it_max = 1
|
||||
call davidson_hs2_nonsym_b1space(vec_tmp, H_jj, s2, energies, N_det, n_states, n_states_diag, n_it_max, converged, H_tc_s2_dagger_u_0_opt)
|
||||
double precision, allocatable :: v_0_new(:,:),s_0_new(:,:)
|
||||
integer :: sze,N_st
|
||||
logical :: do_right
|
||||
sze = N_det
|
||||
N_st = 1
|
||||
do_right = .False.
|
||||
allocate(s_0_new(N_det,1),v_0_new(N_det,1))
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0_new,s_0_new,vec_tmp,N_st,sze, do_right)
|
||||
double precision :: accu_e_0, accu_s_0
|
||||
accu_e_0 = 0.d0
|
||||
accu_s_0 = 0.d0
|
||||
do i = 1, sze
|
||||
accu_e_0 += v_0_new(i,1) * vec_tmp(i,1)
|
||||
accu_s_0 += s_0_new(i,1) * vec_tmp(i,1)
|
||||
enddo
|
||||
print*,'energies = ',energies
|
||||
print*,'s2 = ',s2
|
||||
print*,'accu_e_0',accu_e_0
|
||||
print*,'accu_s_0',accu_s_0
|
||||
|
||||
! Preparing the right-eigenvector
|
||||
print*,'Computing the right-eigenvector '
|
||||
vec_tmp = 0.d0
|
||||
do istate = 1, N_states
|
||||
vec_tmp(1:N_det,istate) = psi_r_coef_bi_ortho(1:N_det,istate)
|
||||
enddo
|
||||
do istate = N_states+1, n_states_diag
|
||||
vec_tmp(istate,istate) = 1.d0
|
||||
enddo
|
||||
do istate = 1, N_states
|
||||
leigvec_tc_bi_orth(1:N_det,istate) = vec_tmp(1:N_det,istate)
|
||||
enddo
|
||||
n_it_max = 1
|
||||
call davidson_hs2_nonsym_b1space(vec_tmp, H_jj, s2, energies, N_det, n_states, n_states_diag, n_it_max, converged, H_tc_s2_u_0_opt)
|
||||
sze = N_det
|
||||
N_st = 1
|
||||
do_right = .True.
|
||||
v_0_new = 0.d0
|
||||
s_0_new = 0.d0
|
||||
call H_tc_s2_u_0_nstates_openmp(v_0_new,s_0_new,vec_tmp,N_st,sze, do_right)
|
||||
accu_e_0 = 0.d0
|
||||
accu_s_0 = 0.d0
|
||||
do i = 1, sze
|
||||
accu_e_0 += v_0_new(i,1) * vec_tmp(i,1)
|
||||
accu_s_0 += s_0_new(i,1) * vec_tmp(i,1)
|
||||
enddo
|
||||
print*,'energies = ',energies
|
||||
print*,'s2 = ',s2
|
||||
print*,'accu_e_0',accu_e_0
|
||||
print*,'accu_s_0',accu_s_0
|
||||
|
||||
end
|
@ -6,7 +6,7 @@ default: False
|
||||
|
||||
[comp_left_eigv]
|
||||
type: logical
|
||||
doc: If |true|, computes also the left-eigenvector
|
||||
doc: If |true|, computes also the left-eigenvector
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
@ -14,7 +14,7 @@ default: False
|
||||
type: logical
|
||||
doc: If |true|, three-body terms are included
|
||||
interface: ezfio,provider,ocaml
|
||||
default: True
|
||||
default: True
|
||||
|
||||
[pure_three_body_h_tc]
|
||||
type: logical
|
||||
@ -30,13 +30,13 @@ default: False
|
||||
|
||||
[core_tc_op]
|
||||
type: logical
|
||||
doc: If |true|, takes the usual Hamiltonian for core orbitals (assumed to be doubly occupied)
|
||||
doc: If |true|, takes the usual Hamiltonian for core orbitals (assumed to be doubly occupied)
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
[full_tc_h_solver]
|
||||
type: logical
|
||||
doc: If |true|, you diagonalize the full TC H matrix
|
||||
doc: If |true|, you diagonalize the full TC H matrix
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
@ -46,6 +46,12 @@ doc: Thresholds on the energy for iterative Davidson used in TC
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-5
|
||||
|
||||
[thrsh_cycle_tc]
|
||||
type: Threshold
|
||||
doc: Thresholds to cycle the integrals with the envelop
|
||||
interface: ezfio,provider,ocaml
|
||||
default: 1.e-10
|
||||
|
||||
[max_it_dav]
|
||||
type: integer
|
||||
doc: nb max of iteration in Davidson used in TC
|
||||
@ -60,11 +66,11 @@ default: 0.000005
|
||||
|
||||
[thresh_psi_r_norm]
|
||||
type: logical
|
||||
doc: If |true|, you prune the WF to compute the PT1 coef based on the norm. If False, the pruning is done through the amplitude on the right-coefficient.
|
||||
doc: If |true|, you prune the WF to compute the PT1 coef based on the norm. If False, the pruning is done through the amplitude on the right-coefficient.
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
[state_following_tc]
|
||||
[state_following_tc]
|
||||
type: logical
|
||||
doc: If |true|, the states are re-ordered to match the input states
|
||||
default: False
|
||||
@ -78,7 +84,7 @@ default: True
|
||||
|
||||
[symetric_fock_tc]
|
||||
type: logical
|
||||
doc: If |true|, using F+F^t as Fock TC
|
||||
doc: If |true|, using F+F^t as Fock TC
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
@ -126,7 +132,7 @@ default: 1.e-6
|
||||
|
||||
[maxovl_tc]
|
||||
type: logical
|
||||
doc: If |true|, maximize the overlap between orthogonalized left- and right eigenvectors
|
||||
doc: If |true|, maximize the overlap between orthogonalized left- and right eigenvectors
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
@ -152,7 +158,7 @@ default: 0.
|
||||
type: character*(32)
|
||||
doc: Type of TCSCF algorithm used. Possible choices are [Simple | DIIS]
|
||||
interface: ezfio,provider,ocaml
|
||||
default: Simple
|
||||
default: DIIS
|
||||
|
||||
[im_thresh_tcscf]
|
||||
type: Threshold
|
||||
@ -180,21 +186,15 @@ default: 1.e-6
|
||||
|
||||
[var_tc]
|
||||
type: logical
|
||||
doc: If |true|, use VAR-TC
|
||||
doc: If |true|, use VAR-TC
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
[read_tc_integ]
|
||||
type: logical
|
||||
doc: If |true|, read integrals: int2_grad1_u12_ao, tc_grad_square_ao and tc_grad_and_lapl_ao
|
||||
[io_tc_integ]
|
||||
type: Disk_access
|
||||
doc: Read/Write integrals int2_grad1_u12_ao, tc_grad_square_ao and tc_grad_and_lapl_ao from/to disk [ Write | Read | None ]
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
|
||||
[write_tc_integ]
|
||||
type: logical
|
||||
doc: If |true|, write integrals: int2_grad1_u12_ao, tc_grad_square_ao and tc_grad_and_lapl_ao
|
||||
interface: ezfio,provider,ocaml
|
||||
default: False
|
||||
default: None
|
||||
|
||||
[debug_tc_pt2]
|
||||
type: integer
|
||||
|
@ -21,25 +21,22 @@ program test_ints
|
||||
touch my_extra_grid_becke my_n_pt_r_extra_grid my_n_pt_a_extra_grid
|
||||
|
||||
!! OK
|
||||
!call routine_int2_u_grad1u_j1b2
|
||||
!! OK
|
||||
!call routine_v_ij_erf_rk_cst_mu_j1b
|
||||
!! OK
|
||||
! call routine_int2_u_grad1u_j1b2
|
||||
! OK
|
||||
! call routine_v_ij_erf_rk_cst_mu_j1b
|
||||
! OK
|
||||
! call routine_x_v_ij_erf_rk_cst_mu_j1b
|
||||
!! OK
|
||||
! call routine_v_ij_u_cst_mu_j1b
|
||||
|
||||
!! OK
|
||||
!call routine_int2_u2_j1b2
|
||||
|
||||
!! OK
|
||||
!call routine_int2_u_grad1u_x_j1b2
|
||||
|
||||
!! OK
|
||||
! OK
|
||||
! call routine_int2_u2_j1b2
|
||||
! OK
|
||||
! call routine_int2_u_grad1u_x_j1b2
|
||||
! OK
|
||||
! call routine_int2_grad1u2_grad2u2_j1b2
|
||||
! call routine_int2_u_grad1u_j1b2
|
||||
! call test_total_grad_lapl
|
||||
! call test_total_grad_square
|
||||
! call test_int2_grad1_u12_ao_test
|
||||
! call routine_v_ij_u_cst_mu_j1b_test
|
||||
! call test_ao_tc_int_chemist
|
||||
! call test_grid_points_ao
|
||||
! call test_tc_scf
|
||||
@ -53,12 +50,12 @@ program test_ints
|
||||
|
||||
!call test_two_e_tc_non_hermit_integral()
|
||||
|
||||
call test_tc_grad_square_ao_test()
|
||||
|
||||
PROVIDE TC_HF_energy VARTC_HF_energy
|
||||
print *, ' TC_HF_energy = ', TC_HF_energy
|
||||
print *, ' VARTC_HF_energy = ', VARTC_HF_energy
|
||||
! call test_tc_grad_square_ao_test()
|
||||
|
||||
!!PROVIDE TC_HF_energy VARTC_HF_energy
|
||||
!!print *, ' TC_HF_energy = ', TC_HF_energy
|
||||
!!print *, ' VARTC_HF_energy = ', VARTC_HF_energy
|
||||
call test_old_ints
|
||||
end
|
||||
|
||||
! ---
|
||||
@ -157,6 +154,9 @@ subroutine routine_int2_u_grad1u_j1b2
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_int2_u_grad1u_j1b2'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -169,20 +169,6 @@ subroutine routine_v_ij_erf_rk_cst_mu_j1b
|
||||
integer :: i,j,ipoint,k,l
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
! print*,'ao_overlap_abs = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_overlap_abs(i,:)
|
||||
! enddo
|
||||
! print*,'center = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_center(2,i,:)
|
||||
! enddo
|
||||
! print*,'sigma = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_sigma(i,:)
|
||||
! enddo
|
||||
|
||||
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
allocate(array_ref(ao_num, ao_num, ao_num, ao_num))
|
||||
@ -215,6 +201,9 @@ subroutine routine_v_ij_erf_rk_cst_mu_j1b
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_v_ij_erf_rk_cst_mu_j1b'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -228,20 +217,6 @@ subroutine routine_x_v_ij_erf_rk_cst_mu_j1b
|
||||
integer :: i,j,ipoint,k,l,m
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
! print*,'ao_overlap_abs = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_overlap_abs(i,:)
|
||||
! enddo
|
||||
! print*,'center = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_center(2,i,:)
|
||||
! enddo
|
||||
! print*,'sigma = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_sigma(i,:)
|
||||
! enddo
|
||||
|
||||
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
allocate(array_ref(ao_num, ao_num, ao_num, ao_num))
|
||||
@ -276,6 +251,10 @@ subroutine routine_x_v_ij_erf_rk_cst_mu_j1b
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_x_v_ij_erf_rk_cst_mu_j1b'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -290,20 +269,6 @@ subroutine routine_v_ij_u_cst_mu_j1b_test
|
||||
integer :: i,j,ipoint,k,l
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
! print*,'ao_overlap_abs = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_overlap_abs(i,:)
|
||||
! enddo
|
||||
! print*,'center = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_center(2,i,:)
|
||||
! enddo
|
||||
! print*,'sigma = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_sigma(i,:)
|
||||
! enddo
|
||||
|
||||
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
allocate(array_ref(ao_num, ao_num, ao_num, ao_num))
|
||||
@ -336,6 +301,9 @@ subroutine routine_v_ij_u_cst_mu_j1b_test
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_v_ij_u_cst_mu_j1b_test'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -427,19 +395,6 @@ subroutine routine_int2_u2_j1b2
|
||||
integer :: i,j,ipoint,k,l
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
! print*,'ao_overlap_abs = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_overlap_abs(i,:)
|
||||
! enddo
|
||||
! print*,'center = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_center(2,i,:)
|
||||
! enddo
|
||||
! print*,'sigma = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_sigma(i,:)
|
||||
! enddo
|
||||
|
||||
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
@ -473,6 +428,9 @@ subroutine routine_int2_u2_j1b2
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_int2_u2_j1b2'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -486,19 +444,6 @@ subroutine routine_int2_u_grad1u_x_j1b2
|
||||
integer :: i,j,ipoint,k,l,m
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
! print*,'ao_overlap_abs = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_overlap_abs(i,:)
|
||||
! enddo
|
||||
! print*,'center = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_center(2,i,:)
|
||||
! enddo
|
||||
! print*,'sigma = '
|
||||
! do i = 1, ao_num
|
||||
! write(*,'(100(F10.5,X))')ao_prod_sigma(i,:)
|
||||
! enddo
|
||||
|
||||
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
@ -534,6 +479,9 @@ subroutine routine_int2_u_grad1u_x_j1b2
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_int2_u_grad1u_x_j1b2'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -579,6 +527,9 @@ subroutine routine_v_ij_u_cst_mu_j1b
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'routine_v_ij_u_cst_mu_j1b'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -742,6 +693,9 @@ subroutine test_total_grad_lapl
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,' test_total_grad_lapl'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -767,6 +721,9 @@ subroutine test_total_grad_square
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'test_total_grad_square'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
|
||||
@ -1057,3 +1014,86 @@ end
|
||||
! ---
|
||||
|
||||
|
||||
|
||||
subroutine test_old_ints
|
||||
implicit none
|
||||
integer :: i,j,k,l
|
||||
double precision :: old, new, contrib, get_ao_tc_sym_two_e_pot
|
||||
double precision :: integral_sym , integral_nsym,accu
|
||||
PROVIDE ao_tc_sym_two_e_pot_in_map
|
||||
accu = 0.d0
|
||||
do j = 1, ao_num
|
||||
do l= 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do k = 1, ao_num
|
||||
! integral_sym = get_ao_tc_sym_two_e_pot(i, j, k, l, ao_tc_sym_two_e_pot_map)
|
||||
! ao_non_hermit_term_chemist(k,i,l,j) = < k l | [erf( mu r12) - 1] d/d_r12 | i j > on the AO basis
|
||||
! integral_nsym = ao_non_hermit_term_chemist(k,i,l,j)
|
||||
! old = integral_sym + integral_nsym
|
||||
! old = tc_grad_square_ao(k,i,l,j) + tc_grad_and_lapl_ao(k,i,l,j) + ao_two_e_coul(k,i,l,j)
|
||||
new = ao_tc_int_chemist_test(k,i,l,j)
|
||||
old = ao_tc_int_chemist_no_cycle(k,i,l,j)
|
||||
contrib = dabs(old - new)
|
||||
if(contrib.gt.1.d-6)then
|
||||
print*,'problem !!'
|
||||
print*,i,j,k,l
|
||||
print*,old, new, contrib
|
||||
endif
|
||||
accu += contrib
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'in test_old_ints'
|
||||
print*,'accu = ',accu/dble(ao_num**4)
|
||||
|
||||
end
|
||||
|
||||
subroutine test_int2_grad1_u12_ao_test
|
||||
implicit none
|
||||
integer :: i,j,ipoint,m,k,l
|
||||
double precision :: weight,accu_relat, accu_abs, contrib
|
||||
double precision, allocatable :: array(:,:,:,:), array_ref(:,:,:,:)
|
||||
allocate(array(ao_num, ao_num, ao_num, ao_num))
|
||||
array = 0.d0
|
||||
allocate(array_ref(ao_num, ao_num, ao_num, ao_num))
|
||||
array_ref = 0.d0
|
||||
do m = 1, 3
|
||||
do ipoint = 1, n_points_final_grid
|
||||
weight = final_weight_at_r_vector(ipoint)
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
array(j,i,l,k) += int2_grad1_u12_ao_test(j,i,ipoint,m) * aos_grad_in_r_array_transp(m,k,ipoint) * aos_in_r_array(l,ipoint) * weight
|
||||
array_ref(j,i,l,k) += int2_grad1_u12_ao(j,i,ipoint,m) * aos_grad_in_r_array_transp(m,k,ipoint) * aos_in_r_array(l,ipoint) * weight
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
|
||||
accu_relat = 0.d0
|
||||
accu_abs = 0.d0
|
||||
do k = 1, ao_num
|
||||
do l = 1, ao_num
|
||||
do i = 1, ao_num
|
||||
do j = 1, ao_num
|
||||
contrib = dabs(array(j,i,l,k) - array_ref(j,i,l,k))
|
||||
accu_abs += contrib
|
||||
if(dabs(array_ref(j,i,l,k)).gt.1.d-10)then
|
||||
accu_relat += contrib/dabs(array_ref(j,i,l,k))
|
||||
endif
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
enddo
|
||||
print*,'******'
|
||||
print*,'******'
|
||||
print*,'test_int2_grad1_u12_ao_test'
|
||||
print*,'accu_abs = ',accu_abs/dble(ao_num)**4
|
||||
print*,'accu_relat = ',accu_relat/dble(ao_num)**4
|
||||
end
|
||||
|
20
src/tools/sort_wf.irp.f
Normal file
20
src/tools/sort_wf.irp.f
Normal file
@ -0,0 +1,20 @@
|
||||
program sort_wf
|
||||
implicit none
|
||||
read_wf = .true.
|
||||
touch read_wf
|
||||
call routine
|
||||
|
||||
end
|
||||
|
||||
subroutine routine
|
||||
implicit none
|
||||
integer :: i
|
||||
character*(128) :: output
|
||||
integer :: i_unit_output,getUnitAndOpen
|
||||
output=trim(ezfio_filename)//'.wf_sorted'
|
||||
i_unit_output = getUnitAndOpen(output,'w')
|
||||
do i = 1, N_det
|
||||
write(i_unit_output, *)i,dabs(psi_coef_sorted(i,1))/dabs(psi_coef_sorted(1,1))
|
||||
enddo
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user