mirror of
https://gitlab.com/scemama/qp_plugins_scemama.git
synced 2024-08-30 07:53:39 +02:00
added the diagonal hessian
This commit is contained in:
parent
d5192bcbc9
commit
1edbd0b890
@ -23,6 +23,13 @@ interface: ezfio,provider,ocaml
|
|||||||
default: False
|
default: False
|
||||||
|
|
||||||
|
|
||||||
|
[diag_hess_cas]
|
||||||
|
type: logical
|
||||||
|
doc: If |true|, only the DIAGONAL part of the hessian is retained for the CASSCF
|
||||||
|
interface: ezfio,provider,ocaml
|
||||||
|
default: False
|
||||||
|
|
||||||
|
|
||||||
[level_shift_casscf]
|
[level_shift_casscf]
|
||||||
type: Positive_float
|
type: Positive_float
|
||||||
doc: Energy shift on the virtual MOs to improve SCF convergence
|
doc: Energy shift on the virtual MOs to improve SCF convergence
|
||||||
|
@ -4,8 +4,8 @@ program casscf
|
|||||||
! TODO : Put the documentation of the program here
|
! TODO : Put the documentation of the program here
|
||||||
END_DOC
|
END_DOC
|
||||||
call reorder_orbitals_for_casscf
|
call reorder_orbitals_for_casscf
|
||||||
! no_vvvv_integrals = .True.
|
no_vvvv_integrals = .True.
|
||||||
! touch no_vvvv_integrals
|
touch no_vvvv_integrals
|
||||||
pt2_max = 0.02
|
pt2_max = 0.02
|
||||||
SOFT_TOUCH pt2_max
|
SOFT_TOUCH pt2_max
|
||||||
call run_stochastic_cipsi
|
call run_stochastic_cipsi
|
||||||
@ -33,6 +33,7 @@ subroutine run
|
|||||||
call write_time(6)
|
call write_time(6)
|
||||||
call write_int(6,iteration,'CAS-SCF iteration')
|
call write_int(6,iteration,'CAS-SCF iteration')
|
||||||
call write_double(6,energy,'CAS-SCF energy')
|
call write_double(6,energy,'CAS-SCF energy')
|
||||||
|
call write_double(6,norm_grad_vec2,'Norm of gradients')
|
||||||
call write_double(6,energy_improvement, 'Predicted energy improvement')
|
call write_double(6,energy_improvement, 'Predicted energy improvement')
|
||||||
|
|
||||||
converged = dabs(energy_improvement) < thresh_scf
|
converged = dabs(energy_improvement) < thresh_scf
|
||||||
|
@ -61,6 +61,7 @@ END_PROVIDER
|
|||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
BEGIN_PROVIDER [real*8, gradvec2, (nMonoEx)]
|
BEGIN_PROVIDER [real*8, gradvec2, (nMonoEx)]
|
||||||
|
&BEGIN_PROVIDER [real*8, norm_grad_vec2]
|
||||||
BEGIN_DOC
|
BEGIN_DOC
|
||||||
! calculate the orbital gradient <Psi| H E_pq |Psi> from density
|
! calculate the orbital gradient <Psi| H E_pq |Psi> from density
|
||||||
! matrices and integrals; Siegbahn et al, Phys Scr 1980
|
! matrices and integrals; Siegbahn et al, Phys Scr 1980
|
||||||
@ -69,7 +70,6 @@ BEGIN_PROVIDER [real*8, gradvec2, (nMonoEx)]
|
|||||||
implicit none
|
implicit none
|
||||||
integer :: i,t,a,indx
|
integer :: i,t,a,indx
|
||||||
real*8 :: gradvec_it,gradvec_ia,gradvec_ta
|
real*8 :: gradvec_it,gradvec_ia,gradvec_ta
|
||||||
real*8 :: norm_grad
|
|
||||||
|
|
||||||
indx=0
|
indx=0
|
||||||
do i=1,n_core_inact_orb
|
do i=1,n_core_inact_orb
|
||||||
@ -93,14 +93,16 @@ BEGIN_PROVIDER [real*8, gradvec2, (nMonoEx)]
|
|||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
|
|
||||||
norm_grad=0.d0
|
norm_grad_vec2=0.d0
|
||||||
do indx=1,nMonoEx
|
do indx=1,nMonoEx
|
||||||
norm_grad+=gradvec2(indx)*gradvec2(indx)
|
norm_grad_vec2+=gradvec2(indx)*gradvec2(indx)
|
||||||
end do
|
end do
|
||||||
norm_grad=sqrt(norm_grad)
|
norm_grad_vec2=sqrt(norm_grad_vec2)
|
||||||
|
if(bavard)then
|
||||||
write(6,*)
|
write(6,*)
|
||||||
write(6,*) ' Norm of the orbital gradient (via D, P and integrals): ', norm_grad
|
write(6,*) ' Norm of the orbital gradient (via D, P and integrals): ', norm_grad_vec2
|
||||||
write(6,*)
|
write(6,*)
|
||||||
|
endif
|
||||||
|
|
||||||
END_PROVIDER
|
END_PROVIDER
|
||||||
|
|
||||||
|
@ -208,10 +208,12 @@ BEGIN_PROVIDER [real*8, hessmat2, (nMonoEx,nMonoEx)]
|
|||||||
!$OMP PRIVATE(i,indx,jndx,j,ustart,t,u,a,bstart,indx_shift)
|
!$OMP PRIVATE(i,indx,jndx,j,ustart,t,u,a,bstart,indx_shift)
|
||||||
|
|
||||||
!$OMP DO
|
!$OMP DO
|
||||||
|
! (DOUBLY OCCUPIED ---> ACT )
|
||||||
do i=1,n_core_inact_orb
|
do i=1,n_core_inact_orb
|
||||||
do t=1,n_act_orb
|
do t=1,n_act_orb
|
||||||
indx = t + (i-1)*n_act_orb
|
indx = t + (i-1)*n_act_orb
|
||||||
jndx=indx
|
jndx=indx
|
||||||
|
! (DOUBLY OCCUPIED ---> ACT )
|
||||||
do j=i,n_core_inact_orb
|
do j=i,n_core_inact_orb
|
||||||
if (i.eq.j) then
|
if (i.eq.j) then
|
||||||
ustart=t
|
ustart=t
|
||||||
@ -223,12 +225,14 @@ BEGIN_PROVIDER [real*8, hessmat2, (nMonoEx,nMonoEx)]
|
|||||||
jndx+=1
|
jndx+=1
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
|
! (DOUBLY OCCUPIED ---> VIRTUAL)
|
||||||
do j=1,n_core_inact_orb
|
do j=1,n_core_inact_orb
|
||||||
do a=1,n_virt_orb
|
do a=1,n_virt_orb
|
||||||
hessmat2(jndx,indx)=hessmat_itja(i,t,j,a)
|
hessmat2(jndx,indx)=hessmat_itja(i,t,j,a)
|
||||||
jndx+=1
|
jndx+=1
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
|
! (ACTIVE ---> VIRTUAL)
|
||||||
do u=1,n_act_orb
|
do u=1,n_act_orb
|
||||||
do a=1,n_virt_orb
|
do a=1,n_virt_orb
|
||||||
hessmat2(jndx,indx)=hessmat_itua(i,t,u,a)
|
hessmat2(jndx,indx)=hessmat_itua(i,t,u,a)
|
||||||
@ -241,10 +245,12 @@ BEGIN_PROVIDER [real*8, hessmat2, (nMonoEx,nMonoEx)]
|
|||||||
|
|
||||||
indx_shift = n_core_inact_orb*n_act_orb
|
indx_shift = n_core_inact_orb*n_act_orb
|
||||||
!$OMP DO
|
!$OMP DO
|
||||||
|
! (DOUBLY OCCUPIED ---> VIRTUAL)
|
||||||
do a=1,n_virt_orb
|
do a=1,n_virt_orb
|
||||||
do i=1,n_core_inact_orb
|
do i=1,n_core_inact_orb
|
||||||
indx = a + (i-1)*n_virt_orb + indx_shift
|
indx = a + (i-1)*n_virt_orb + indx_shift
|
||||||
jndx=indx
|
jndx=indx
|
||||||
|
! (DOUBLY OCCUPIED ---> VIRTUAL)
|
||||||
do j=i,n_core_inact_orb
|
do j=i,n_core_inact_orb
|
||||||
if (i.eq.j) then
|
if (i.eq.j) then
|
||||||
bstart=a
|
bstart=a
|
||||||
@ -256,6 +262,7 @@ BEGIN_PROVIDER [real*8, hessmat2, (nMonoEx,nMonoEx)]
|
|||||||
jndx+=1
|
jndx+=1
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
|
! (ACT ---> VIRTUAL)
|
||||||
do t=1,n_act_orb
|
do t=1,n_act_orb
|
||||||
do b=1,n_virt_orb
|
do b=1,n_virt_orb
|
||||||
hessmat2(jndx,indx)=hessmat_iatb(i,a,t,b)
|
hessmat2(jndx,indx)=hessmat_iatb(i,a,t,b)
|
||||||
@ -268,10 +275,12 @@ BEGIN_PROVIDER [real*8, hessmat2, (nMonoEx,nMonoEx)]
|
|||||||
|
|
||||||
indx_shift += n_core_inact_orb*n_virt_orb
|
indx_shift += n_core_inact_orb*n_virt_orb
|
||||||
!$OMP DO
|
!$OMP DO
|
||||||
|
! (ACT ---> VIRTUAL)
|
||||||
do a=1,n_virt_orb
|
do a=1,n_virt_orb
|
||||||
do t=1,n_act_orb
|
do t=1,n_act_orb
|
||||||
indx = a + (t-1)*n_virt_orb + indx_shift
|
indx = a + (t-1)*n_virt_orb + indx_shift
|
||||||
jndx=indx
|
jndx=indx
|
||||||
|
! (ACT ---> VIRTUAL)
|
||||||
do u=t,n_act_orb
|
do u=t,n_act_orb
|
||||||
if (t.eq.u) then
|
if (t.eq.u) then
|
||||||
bstart=a
|
bstart=a
|
||||||
|
@ -16,13 +16,18 @@ BEGIN_PROVIDER [real*8, SXmatrix, (nMonoEx+1,nMonoEx+1)]
|
|||||||
SXmatrix(1,i+1)=gradvec2(i)
|
SXmatrix(1,i+1)=gradvec2(i)
|
||||||
SXmatrix(1+i,1)=gradvec2(i)
|
SXmatrix(1+i,1)=gradvec2(i)
|
||||||
end do
|
end do
|
||||||
|
if(diag_hess_cas)then
|
||||||
|
do i = 1, nMonoEx
|
||||||
|
SXmatrix(i+1,i+1) = hessdiag(i)
|
||||||
|
enddo
|
||||||
|
else
|
||||||
do i=1,nMonoEx
|
do i=1,nMonoEx
|
||||||
do j=1,nMonoEx
|
do j=1,nMonoEx
|
||||||
SXmatrix(i+1,j+1)=hessmat2(i,j)
|
SXmatrix(i+1,j+1)=hessmat2(i,j)
|
||||||
SXmatrix(j+1,i+1)=hessmat2(i,j)
|
SXmatrix(j+1,i+1)=hessmat2(i,j)
|
||||||
end do
|
end do
|
||||||
end do
|
end do
|
||||||
|
endif
|
||||||
|
|
||||||
do i = 1, nMonoEx
|
do i = 1, nMonoEx
|
||||||
SXmatrix(i+1,i+1) += level_shift_casscf
|
SXmatrix(i+1,i+1) += level_shift_casscf
|
||||||
|
Loading…
Reference in New Issue
Block a user