1
0
mirror of https://gitlab.com/scemama/qp_plugins_scemama.git synced 2024-12-23 04:43:38 +01:00

Optimizing r2_cc

This commit is contained in:
Anthony Scemama 2019-09-17 23:31:12 +02:00
parent 1a10877cdd
commit b6c41bb9d0
2 changed files with 54 additions and 158 deletions

View File

@ -38,6 +38,19 @@ BEGIN_PROVIDER [ double precision, c_spin_fock_matrix_mo_oo, (spin_occ_num,spin_
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, c_spin_fock_matrix_mo_oo_transp, (spin_occ_num,spin_occ_num) ]
implicit none
BEGIN_DOC
! Transpose of c_spin_fock_matrix_mo_oo
END_DOC
integer :: i,j
do i=1,spin_occ_num
do j=1,spin_occ_num
c_spin_fock_matrix_mo_oo_transp(j,i) = c_spin_fock_matrix_mo_oo(i,j)
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ double precision, c_spin_fock_matrix_mo_ov, (spin_occ_num,spin_vir_num) ] BEGIN_PROVIDER [ double precision, c_spin_fock_matrix_mo_ov, (spin_occ_num,spin_vir_num) ]
implicit none implicit none

View File

@ -7,160 +7,75 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
integer :: a,b,e,f integer :: a,b,e,f
double precision :: x double precision :: x
double precision, allocatable :: tmp_oo(:,:), tmp_oo2(:,:) double precision, allocatable :: tmp_oo(:,:), tmp_oo2(:,:)
double precision, external :: u_dot_v
allocate ( tmp_oo(spin_occ_num,spin_occ_num) ) allocate ( tmp_oo(spin_occ_num,spin_occ_num) )
r2_cc(:,:,:,:) = OOVV(:,:,:,:) r2_cc(:,:,:,:) = OOVV(:,:,:,:)
do e=1,spin_vir_num do b=1,spin_vir_num
do b=1,spin_vir_num do a=1,spin_vir_num
do a=1,spin_vir_num if (a == b) cycle
if (a == b) cycle
tmp_oo(:,:) = c_spin_fock_matrix_mo_vv(b,e) * t2_cc(:,:,a,e) do e=1,spin_vir_num
do m=1,spin_occ_num x = u_dot_v( t1_cc(1,b), c_spin_fock_matrix_mo_ov(1,e), spin_occ_num )
x = 0.5d0 * t1_cc(m,b) * c_spin_fock_matrix_mo_ov(m,e) x = c_spin_fock_matrix_mo_vv(b,e) - x*0.5d0
if (x == 0.d0) cycle if (x == 0.d0) cycle
tmp_oo(:,:) = tmp_oo(:,:) - t2_cc(:,:,a,e)*x tmp_oo(:,:) = t2_cc(:,:,a,e) * x
enddo
r2_cc(:,:,a,b) = r2_cc(:,:,a,b) + tmp_oo(:,:) r2_cc(:,:,a,b) = r2_cc(:,:,a,b) + tmp_oo(:,:)
r2_cc(:,:,b,a) = r2_cc(:,:,b,a) - tmp_oo(:,:) r2_cc(:,:,b,a) = r2_cc(:,:,b,a) - tmp_oo(:,:)
end do end do
do i=1,spin_occ_num
do m=1,spin_occ_num
tmp_oo(m,i) = t2_cc(i,m,a,b)
enddo
enddo
do m=1,spin_occ_num
do j=1,spin_occ_num
x = c_spin_fock_matrix_mo_oo(m,j)
r2_cc(:,j,b,e) = r2_cc(:,j,b,e) - t2_cc(:,m,b,e)*x
end do
end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
x = 0.d0
do m=1,spin_occ_num do m=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + t2_cc(j,m,a,b)*c_spin_fock_matrix_mo_oo(m,i) do e=1,spin_vir_num
end do x = x + c_spin_fock_matrix_mo_ov(m,e) * &
end do ( tmp_oo(m,j)*t1_cc(i,e) - &
end do tmp_oo(m,i)*t1_cc(j,e) )
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do e=1,spin_vir_num
do m=1,spin_occ_num
x = 0.5d0*c_spin_fock_matrix_mo_ov(m,e)
if (x == 0.d0) cycle
do j=1,spin_occ_num
do i=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) - x*t2_cc(i,m,a,b)*t1_cc(j,e)
end do end do
end do end do
end do x = x + u_dot_v( tau_cc(1,1,a,b), cWoooo(1,1,i,j), spin_occ_num*spin_occ_num )
end do x = x * 0.5d0 + &
end do u_dot_v( tmp_oo(1,j), c_spin_fock_matrix_mo_oo(1,i), spin_occ_num ) - &
end do u_dot_v( tmp_oo(1,i), c_spin_fock_matrix_mo_oo(1,j), spin_occ_num )
do e=1,spin_vir_num
x = x - sum(t2_cc(j,:,a,e)*cWovvo(:,b,e,i))
do b=1,spin_vir_num
do a=1,spin_vir_num
do e=1,spin_vir_num
do m=1,spin_occ_num
x = 0.5d0*c_spin_fock_matrix_mo_ov(m,e)
do j=1,spin_occ_num
do i=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + x*t2_cc(j,m,a,b)*t1_cc(i,e)
end do
end do end do
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + x
end do end do
end do end do
end do
end do
tmp_oo(:,:) = 0.d0
do b=1,spin_vir_num do f=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num
do i=1,spin_occ_num
do n=1,spin_occ_num
do m=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + 0.5d0*tau_cc(m,n,a,b)*cWoooo(m,n,i,j)
end do
end do
end do
end do
end do
end do
do f=1,spin_vir_num
do e=1,spin_vir_num
do b=1,spin_vir_num
do a=1,spin_vir_num
x = 0.5d0*cWvvvv(a,b,e,f)
if (x /= 0.d0) then
do j=1,spin_occ_num
do i=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + x*tau_cc(i,j,e,f)
end do
end do
endif
end do
end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num
do e=1,spin_vir_num do e=1,spin_vir_num
do m=1,spin_occ_num x = 0.5d0*cWvvvv(a,b,e,f)
do i=1,spin_occ_num if (x == 0.d0) cycle
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + t2_cc(i,m,a,e)*cWovvo(m,b,e,j) tmp_oo(:,:) = tmp_oo(:,:) + x*tau_cc(:,:,e,f)
end do
end do
end do end do
end do end do
end do r2_cc(:,:,a,b) = r2_cc(:,:,a,b) + tmp_oo(:,:)
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do e=1,spin_vir_num do e=1,spin_vir_num
do m=1,spin_occ_num do m=1,spin_occ_num
x = t1_cc(m,a)*OVVO(m,b,e,j) x = t1_cc(m,a)*OVVO(m,b,e,j)
do i=1,spin_occ_num do i=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) - t1_cc(i,e)*x r2_cc(i,j,a,b) = r2_cc(i,j,a,b) + t2_cc(i,m,a,e)*cWovvo(m,b,e,j) - t1_cc(i,e)*x
end do enddo
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do e=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num
do i=1,spin_occ_num
do m=1,spin_occ_num
r2_cc(i,j,a,b) = r2_cc(i,j,a,b) - t2_cc(j,m,a,e)*cWovvo(m,b,e,i)
end do
end do
end do
end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do e=1,spin_vir_num do e=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
@ -170,12 +85,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do e=1,spin_vir_num do e=1,spin_vir_num
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do m=1,spin_occ_num do m=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
@ -184,11 +95,7 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do e=1,spin_vir_num do e=1,spin_vir_num
do i=1,spin_occ_num do i=1,spin_occ_num
@ -198,12 +105,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do e=1,spin_vir_num do e=1,spin_vir_num
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
do m=1,spin_occ_num do m=1,spin_occ_num
@ -212,12 +115,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num do e=1,spin_vir_num
do e=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
do m=1,spin_occ_num do m=1,spin_occ_num
@ -226,12 +125,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do e=1,spin_vir_num do e=1,spin_vir_num
do i=1,spin_occ_num do i=1,spin_occ_num
@ -239,12 +134,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do e=1,spin_vir_num do e=1,spin_vir_num
do i=1,spin_occ_num do i=1,spin_occ_num
do j=1,spin_occ_num do j=1,spin_occ_num
@ -252,12 +143,8 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
do m=1,spin_occ_num do m=1,spin_occ_num
@ -265,11 +152,7 @@ BEGIN_PROVIDER [ double precision, r2_cc, (spin_occ_num,spin_occ_num,spin_vir_nu
end do end do
end do end do
end do end do
end do
end do
do b=1,spin_vir_num
do a=1,spin_vir_num
do j=1,spin_occ_num do j=1,spin_occ_num
do i=1,spin_occ_num do i=1,spin_occ_num
do m=1,spin_occ_num do m=1,spin_occ_num