mirror of
https://github.com/LCPQ/quantum_package
synced 2024-08-24 21:41:46 +02:00
Added Davidson threshold in EZFIO
This commit is contained in:
parent
b3d0c06209
commit
4679023df9
@ -40,6 +40,12 @@ doc: Force the wave function to be an eigenfunction of S^2
|
|||||||
interface: ezfio,provider,ocaml
|
interface: ezfio,provider,ocaml
|
||||||
default: False
|
default: False
|
||||||
|
|
||||||
|
[threshold_davidson]
|
||||||
|
type: Threshold
|
||||||
|
doc: Thresholds of Davidson's algorithm
|
||||||
|
interface: ezfio,provider,ocaml
|
||||||
|
default: 1.e-8
|
||||||
|
|
||||||
[threshold_generators]
|
[threshold_generators]
|
||||||
type: Threshold
|
type: Threshold
|
||||||
doc: Thresholds on generators (fraction of the norm)
|
doc: Thresholds on generators (fraction of the norm)
|
||||||
|
@ -591,14 +591,12 @@ subroutine davidson_diag_hjj(dets_in,u_in,H_jj,energies,dim_in,sze,N_st,Nint,iun
|
|||||||
abort_here = abort_all
|
abort_here = abort_all
|
||||||
end
|
end
|
||||||
|
|
||||||
BEGIN_PROVIDER [ character(64), davidson_criterion ]
|
BEGIN_PROVIDER [ character(64), davidson_criterion ]
|
||||||
&BEGIN_PROVIDER [ double precision, davidson_threshold ]
|
|
||||||
implicit none
|
implicit none
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! Can be : [ energy | residual | both | wall_time | cpu_time | iterations ]
|
! Can be : [ energy | residual | both | wall_time | cpu_time | iterations ]
|
||||||
END_DOC
|
END_DOC
|
||||||
davidson_criterion = 'residual'
|
davidson_criterion = 'residual'
|
||||||
davidson_threshold = 1.d-10
|
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged)
|
subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged)
|
||||||
@ -621,20 +619,20 @@ subroutine davidson_converged(energy,residual,wall,iterations,cpu,N_st,converged
|
|||||||
E = energy - energy_old
|
E = energy - energy_old
|
||||||
energy_old = energy
|
energy_old = energy
|
||||||
if (davidson_criterion == 'energy') then
|
if (davidson_criterion == 'energy') then
|
||||||
converged = dabs(maxval(E(1:N_st))) < davidson_threshold
|
converged = dabs(maxval(E(1:N_st))) < threshold_davidson
|
||||||
else if (davidson_criterion == 'residual') then
|
else if (davidson_criterion == 'residual') then
|
||||||
converged = dabs(maxval(residual(1:N_st))) < davidson_threshold
|
converged = dabs(maxval(residual(1:N_st))) < threshold_davidson
|
||||||
else if (davidson_criterion == 'both') then
|
else if (davidson_criterion == 'both') then
|
||||||
converged = dabs(maxval(residual(1:N_st))) + dabs(maxval(E(1:N_st)) ) &
|
converged = dabs(maxval(residual(1:N_st))) + dabs(maxval(E(1:N_st)) ) &
|
||||||
< davidson_threshold
|
< threshold_davidson
|
||||||
else if (davidson_criterion == 'wall_time') then
|
else if (davidson_criterion == 'wall_time') then
|
||||||
call wall_time(time)
|
call wall_time(time)
|
||||||
converged = time - wall > davidson_threshold
|
converged = time - wall > threshold_davidson
|
||||||
else if (davidson_criterion == 'cpu_time') then
|
else if (davidson_criterion == 'cpu_time') then
|
||||||
call cpu_time(time)
|
call cpu_time(time)
|
||||||
converged = time - cpu > davidson_threshold
|
converged = time - cpu > threshold_davidson
|
||||||
else if (davidson_criterion == 'iterations') then
|
else if (davidson_criterion == 'iterations') then
|
||||||
converged = iterations >= int(davidson_threshold)
|
converged = iterations >= int(threshold_davidson)
|
||||||
endif
|
endif
|
||||||
converged = converged.or.abort_here
|
converged = converged.or.abort_here
|
||||||
end
|
end
|
||||||
|
@ -122,15 +122,13 @@ subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2)
|
|||||||
integer :: sh, sh2, ni, exa, ext, org_i, org_j, endi, pass
|
integer :: sh, sh2, ni, exa, ext, org_i, org_j, endi, pass
|
||||||
double precision :: davidson_threshold_bis
|
double precision :: davidson_threshold_bis
|
||||||
|
|
||||||
!PROVIDE davidson_threshold
|
|
||||||
|
|
||||||
s2 = 0.d0
|
s2 = 0.d0
|
||||||
davidson_threshold_bis = davidson_threshold
|
davidson_threshold_bis = threshold_davidson
|
||||||
call sort_dets_ab_v(psi_keys_tmp, sorted, sort_idx, shortcut, version, n, N_int)
|
call sort_dets_ab_v(psi_keys_tmp, sorted, sort_idx, shortcut, version, n, N_int)
|
||||||
|
|
||||||
!$OMP PARALLEL DEFAULT(NONE) &
|
!$OMP PARALLEL DEFAULT(NONE) &
|
||||||
!$OMP PRIVATE(i,j,s2_tmp,sh, sh2, ni, exa, ext, org_i, org_j, endi, pass)&
|
!$OMP PRIVATE(i,j,s2_tmp,sh, sh2, ni, exa, ext, org_i, org_j, endi, pass)&
|
||||||
!$OMP SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int,davidson_threshold,shortcut,sorted,sort_idx,version)&
|
!$OMP SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int,threshold_davidson,shortcut,sorted,sort_idx,version)&
|
||||||
!$OMP REDUCTION(+:s2)
|
!$OMP REDUCTION(+:s2)
|
||||||
|
|
||||||
!$OMP DO SCHEDULE(dynamic)
|
!$OMP DO SCHEDULE(dynamic)
|
||||||
@ -162,7 +160,7 @@ subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2)
|
|||||||
org_j = sort_idx(j)
|
org_j = sort_idx(j)
|
||||||
|
|
||||||
if ( dabs(psi_coefs_tmp(org_j)) + dabs(psi_coefs_tmp(org_i))&
|
if ( dabs(psi_coefs_tmp(org_j)) + dabs(psi_coefs_tmp(org_i))&
|
||||||
> davidson_threshold ) then
|
> threshold_davidson ) then
|
||||||
call get_s2(psi_keys_tmp(1,1,org_i),psi_keys_tmp(1,1,org_j),s2_tmp,N_int)
|
call get_s2(psi_keys_tmp(1,1,org_i),psi_keys_tmp(1,1,org_j),s2_tmp,N_int)
|
||||||
s2 = s2 + psi_coefs_tmp(org_i)*psi_coefs_tmp(org_j)*s2_tmp
|
s2 = s2 + psi_coefs_tmp(org_i)*psi_coefs_tmp(org_j)*s2_tmp
|
||||||
endif
|
endif
|
||||||
@ -179,7 +177,7 @@ subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2)
|
|||||||
|
|
||||||
!$OMP PARALLEL DEFAULT(NONE) &
|
!$OMP PARALLEL DEFAULT(NONE) &
|
||||||
!$OMP PRIVATE(i,j,s2_tmp,sh, sh2, ni, exa, ext, org_i, org_j, endi, pass)&
|
!$OMP PRIVATE(i,j,s2_tmp,sh, sh2, ni, exa, ext, org_i, org_j, endi, pass)&
|
||||||
!$OMP SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int,davidson_threshold,shortcut,sorted,sort_idx,version)&
|
!$OMP SHARED(n,psi_coefs_tmp,psi_keys_tmp,N_int,threshold_davidson,shortcut,sorted,sort_idx,version)&
|
||||||
!$OMP REDUCTION(+:s2)
|
!$OMP REDUCTION(+:s2)
|
||||||
|
|
||||||
!$OMP DO SCHEDULE(dynamic)
|
!$OMP DO SCHEDULE(dynamic)
|
||||||
@ -195,7 +193,7 @@ subroutine get_s2_u0(psi_keys_tmp,psi_coefs_tmp,n,nmax,s2)
|
|||||||
org_j = sort_idx(j)
|
org_j = sort_idx(j)
|
||||||
|
|
||||||
if ( dabs(psi_coefs_tmp(org_j)) + dabs(psi_coefs_tmp(org_i))&
|
if ( dabs(psi_coefs_tmp(org_j)) + dabs(psi_coefs_tmp(org_i))&
|
||||||
> davidson_threshold ) then
|
> threshold_davidson ) then
|
||||||
call get_s2(psi_keys_tmp(1,1,org_i),psi_keys_tmp(1,1,org_j),s2_tmp,N_int)
|
call get_s2(psi_keys_tmp(1,1,org_i),psi_keys_tmp(1,1,org_j),s2_tmp,N_int)
|
||||||
s2 = s2 + psi_coefs_tmp(org_i)*psi_coefs_tmp(org_j)*s2_tmp
|
s2 = s2 + psi_coefs_tmp(org_i)*psi_coefs_tmp(org_j)*s2_tmp
|
||||||
endif
|
endif
|
||||||
|
@ -1256,7 +1256,7 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
|
|||||||
|
|
||||||
!$OMP PARALLEL DEFAULT(NONE) &
|
!$OMP PARALLEL DEFAULT(NONE) &
|
||||||
!$OMP PRIVATE(i,hij,j,k,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi,local_threshold,sorted_i)&
|
!$OMP PRIVATE(i,hij,j,k,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi,local_threshold,sorted_i)&
|
||||||
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold,sorted,shortcut,sort_idx,version)
|
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,threshold_davidson,sorted,shortcut,sort_idx,version)
|
||||||
allocate(vt(n))
|
allocate(vt(n))
|
||||||
Vt = 0.d0
|
Vt = 0.d0
|
||||||
|
|
||||||
@ -1273,7 +1273,7 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
|
|||||||
|
|
||||||
do i=shortcut(sh),shortcut(sh+1)-1
|
do i=shortcut(sh),shortcut(sh+1)-1
|
||||||
org_i = sort_idx(i)
|
org_i = sort_idx(i)
|
||||||
local_threshold = davidson_threshold - dabs(u_0(org_i))
|
local_threshold = threshold_davidson - dabs(u_0(org_i))
|
||||||
if(sh==sh2) then
|
if(sh==sh2) then
|
||||||
endi = i-1
|
endi = i-1
|
||||||
else
|
else
|
||||||
@ -1315,14 +1315,14 @@ subroutine H_u_0(v_0,u_0,H_jj,n,keys_tmp,Nint)
|
|||||||
|
|
||||||
!$OMP PARALLEL DEFAULT(NONE) &
|
!$OMP PARALLEL DEFAULT(NONE) &
|
||||||
!$OMP PRIVATE(i,hij,j,k,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi,local_threshold)&
|
!$OMP PRIVATE(i,hij,j,k,jj,vt,ii,sh,sh2,ni,exa,ext,org_i,org_j,endi,local_threshold)&
|
||||||
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,davidson_threshold,sorted,shortcut,sort_idx,version)
|
!$OMP SHARED(n,H_jj,u_0,keys_tmp,Nint,v_0,threshold_davidson,sorted,shortcut,sort_idx,version)
|
||||||
allocate(vt(n))
|
allocate(vt(n))
|
||||||
Vt = 0.d0
|
Vt = 0.d0
|
||||||
|
|
||||||
!$OMP DO SCHEDULE(dynamic)
|
!$OMP DO SCHEDULE(dynamic)
|
||||||
do sh=1,shortcut(0)
|
do sh=1,shortcut(0)
|
||||||
do i=shortcut(sh),shortcut(sh+1)-1
|
do i=shortcut(sh),shortcut(sh+1)-1
|
||||||
local_threshold = davidson_threshold - dabs(u_0(org_i))
|
local_threshold = threshold_davidson - dabs(u_0(org_i))
|
||||||
org_i = sort_idx(i)
|
org_i = sort_idx(i)
|
||||||
do j=shortcut(sh),i-1
|
do j=shortcut(sh),i-1
|
||||||
org_j = sort_idx(j)
|
org_j = sort_idx(j)
|
||||||
|
Loading…
Reference in New Issue
Block a user