9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-07 05:53:37 +01:00

Merge branch 'dev-stable' of github.com:quantumpackage/qp2 into dev-stable

This commit is contained in:
Anthony Scemama 2024-02-28 15:46:48 +01:00
commit e9463ae681
5 changed files with 111 additions and 10 deletions

View File

@ -313,10 +313,19 @@ def write_ezfio(res, filename):
MoMatrix = [] MoMatrix = []
sym0 = [i.sym for i in res.mo_sets[MO_type]] sym0 = [i.sym for i in res.mo_sets[MO_type]]
sym = [i.sym for i in res.mo_sets[MO_type]] sym = [i.sym for i in res.mo_sets[MO_type]]
for i in range(len(sym)): for i in range(len(sym)):
sym[MOmap[i]] = sym0[i] sym[MOmap[i]] = sym0[i]
irrep = {}
for i in sym:
irrep[i] = 0
for i, j in enumerate(irrep.keys()):
irrep[j] = i+1
sym = [ irrep[k] for k in sym ]
MoMatrix = [] MoMatrix = []
for i in range(len(MOs)): for i in range(len(MOs)):
m = MOs[i] m = MOs[i]
@ -333,6 +342,7 @@ def write_ezfio(res, filename):
ezfio.set_mo_basis_mo_num(mo_num) ezfio.set_mo_basis_mo_num(mo_num)
ezfio.set_mo_basis_mo_coef(MoMatrix) ezfio.set_mo_basis_mo_coef(MoMatrix)
ezfio.set_mo_basis_mo_occ(OccNum) ezfio.set_mo_basis_mo_occ(OccNum)
ezfio.set_mo_basis_mo_symmetry(sym)
print("OK") print("OK")

View File

@ -103,7 +103,7 @@ subroutine routine_save_rotated_mos(thr_deg, good_angles)
double precision, allocatable :: stmp(:,:), T(:,:), Snew(:,:), smat2(:,:) double precision, allocatable :: stmp(:,:), T(:,:), Snew(:,:), smat2(:,:)
double precision, allocatable :: mo_l_coef_tmp(:,:), mo_r_coef_tmp(:,:), mo_l_coef_new(:,:) double precision, allocatable :: mo_l_coef_tmp(:,:), mo_r_coef_tmp(:,:), mo_l_coef_new(:,:)
E_thr = 1d-8 E_thr = 1d-04
E_old = TC_HF_energy E_old = TC_HF_energy
allocate(mo_l_coef_old(ao_num,mo_num), mo_r_coef_old(ao_num,mo_num)) allocate(mo_l_coef_old(ao_num,mo_num), mo_r_coef_old(ao_num,mo_num))
mo_r_coef_old = mo_r_coef mo_r_coef_old = mo_r_coef
@ -164,10 +164,42 @@ subroutine routine_save_rotated_mos(thr_deg, good_angles)
allocate(mo_r_coef_tmp(ao_num,n_degen), mo_l_coef_tmp(ao_num,n_degen), mo_l_coef_new(ao_num,n_degen)) allocate(mo_r_coef_tmp(ao_num,n_degen), mo_l_coef_tmp(ao_num,n_degen), mo_l_coef_new(ao_num,n_degen))
allocate(T(n_degen,n_degen), Snew(n_degen,n_degen)) allocate(T(n_degen,n_degen), Snew(n_degen,n_degen))
do j = 1, n_degen print*,'Right orbitals before'
mo_r_coef_tmp(1:ao_num,j) = mo_r_coef_new(1:ao_num,list_degen(i,j)) do j = 1, n_degen
mo_l_coef_tmp(1:ao_num,j) = mo_l_coef(1:ao_num,list_degen(i,j)) write(*,'(100(F16.10,X))') mo_r_coef_new(1:ao_num,list_degen(i,j))
enddo enddo
print*,'Left orbitals before'
do j = 1, n_degen
write(*,'(100(F16.10,X))')mo_l_coef(1:ao_num,list_degen(i,j))
enddo
if(angle_left_right(list_degen(i,1)).gt.80.d0.and.n_degen==2)then
integer :: i_list, j_list
i_list = list_degen(i,1)
j_list = list_degen(i,2)
print*,'Huge angle !!! == ',angle_left_right(list_degen(i,1)),angle_left_right(list_degen(i,2))
print*,'i_list = ',i_list
print*,'i_list = ',j_list
print*,'Swapping left/right orbitals'
call print_strong_overlap(i_list, j_list)
mo_r_coef_tmp(1:ao_num,1) = mo_r_coef_new(1:ao_num,i_list)
mo_r_coef_tmp(1:ao_num,2) = mo_l_coef(1:ao_num,i_list)
mo_l_coef_tmp(1:ao_num,1) = mo_l_coef(1:ao_num,j_list)
mo_l_coef_tmp(1:ao_num,2) = mo_r_coef_new(1:ao_num,j_list)
else
do j = 1, n_degen
print*,'i_list = ',list_degen(i,j)
mo_r_coef_tmp(1:ao_num,j) = mo_r_coef_new(1:ao_num,list_degen(i,j))
mo_l_coef_tmp(1:ao_num,j) = mo_l_coef(1:ao_num,list_degen(i,j))
enddo
endif
print*,'Right orbitals '
do j = 1, n_degen
write(*,'(100(F16.10,X))')mo_r_coef_tmp(1:ao_num,j)
enddo
print*,'Left orbitals '
do j = 1, n_degen
write(*,'(100(F16.10,X))')mo_l_coef_tmp(1:ao_num,j)
enddo
! Orthogonalization of right functions ! Orthogonalization of right functions
print *, ' Orthogonalization of RIGHT functions' print *, ' Orthogonalization of RIGHT functions'
print *, ' ------------------------------------' print *, ' ------------------------------------'
@ -445,3 +477,31 @@ subroutine sort_by_tc_fock
end end
subroutine print_strong_overlap(i_list, j_list)
implicit none
integer, intent(in) :: i_list,j_list
double precision :: o_i, o_j,o_ij
double precision :: s_mat_r(2,2),s_mat_l(2,2)
o_i = dsqrt(overlap_mo_r(i_list, i_list))
o_j = dsqrt(overlap_mo_r(j_list, j_list))
o_ij = overlap_mo_r(j_list, i_list)
s_mat_r(1,1) = o_i*o_i
s_mat_r(2,1) = o_ij/(o_i * o_j)
s_mat_r(2,2) = o_j*o_j
s_mat_r(1,2) = s_mat_r(2,1)
print*,'Right overlap matrix '
write(*,'(2(F10.5,X))')s_mat_r(1:2,1)
write(*,'(2(F10.5,X))')s_mat_r(1:2,2)
o_i = dsqrt(overlap_mo_l(i_list, i_list))
o_j = dsqrt(overlap_mo_l(j_list, j_list))
o_ij = overlap_mo_l(j_list, i_list)
s_mat_l(1,1) = o_i*o_i
s_mat_l(2,1) = o_ij/(o_i * o_j)
s_mat_l(2,2) = o_j*o_j
s_mat_l(1,2) = s_mat_l(2,1)
print*,'Left overlap matrix '
write(*,'(2(F10.5,X))')s_mat_l(1:2,1)
write(*,'(2(F10.5,X))')s_mat_l(1:2,2)
end

View File

@ -32,6 +32,12 @@ doc: |MO| occupation numbers
interface: ezfio interface: ezfio
size: (mo_basis.mo_num) size: (mo_basis.mo_num)
[mo_symmetry]
type: integer
doc: MOs with the same integer belong to the same irrep.
interface: ezfio
size: (mo_basis.mo_num)
[mo_class] [mo_class]
type: MO_class type: MO_class
doc: [ Core | Inactive | Active | Virtual | Deleted ], as defined by :ref:`qp_set_mo_class` doc: [ Core | Inactive | Active | Virtual | Deleted ], as defined by :ref:`qp_set_mo_class`

View File

@ -58,3 +58,21 @@ END_PROVIDER
) )
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [double precision, mo_spread_centered_x, (mo_num, mo_num) ]
&BEGIN_PROVIDER [double precision, mo_spread_centered_y, (mo_num, mo_num) ]
&BEGIN_PROVIDER [double precision, mo_spread_centered_z, (mo_num, mo_num) ]
BEGIN_DOC
! array of the integrals of MO_i * (x^2 - <MO_i|x|MO_j>^2) MO_j = MO_i x^2 MO_j - (MO_i x MO_j)^2
! array of the integrals of MO_i * (y^2 - <MO_i|y|MO_j>^2) MO_j = MO_i y^2 MO_j - (MO_i y MO_j)^2
! array of the integrals of MO_i * (z^2 - <MO_i|z|MO_j>^2) MO_j = MO_i z^2 MO_j - (MO_i z MO_j)^2
END_DOC
implicit none
integer :: i,j
do i = 1, mo_num
do j = 1, mo_num
mo_spread_centered_x(j,i) = mo_spread_x(j,i) - mo_dipole_x(j,i)**2
mo_spread_centered_y(j,i) = mo_spread_y(j,i) - mo_dipole_y(j,i)**2
mo_spread_centered_z(j,i) = mo_spread_z(j,i) - mo_dipole_z(j,i)**2
enddo
enddo
END_PROVIDER

View File

@ -1920,8 +1920,12 @@ subroutine exp_matrix(X,n,exp_X)
call get_A_squared(X,n,r2_mat) call get_A_squared(X,n,r2_mat)
call lapack_diagd(eigvalues,eigvectors,r2_mat,n,n) call lapack_diagd(eigvalues,eigvectors,r2_mat,n,n)
eigvalues=-eigvalues eigvalues=-eigvalues
do i = 1,n
! t = dsqrt(t^2) where t^2 are eigenvalues of X^2
eigvalues(i) = dsqrt(eigvalues(i))
enddo
if(.False.)then if(.false.)then
!!! For debugging and following the book intermediate !!! For debugging and following the book intermediate
! rebuilding the matrix : X^2 = -W t^2 W^T as in 3.1.30 ! rebuilding the matrix : X^2 = -W t^2 W^T as in 3.1.30
! matrix_tmp1 = W t^2 ! matrix_tmp1 = W t^2
@ -1932,14 +1936,16 @@ subroutine exp_matrix(X,n,exp_X)
enddo enddo
eigvalues_mat=0.d0 eigvalues_mat=0.d0
do i = 1,n do i = 1,n
! t = dsqrt(t^2) where t^2 are eigenvalues of X^2
eigvalues(i) = dsqrt(eigvalues(i))
eigvalues_mat(i,i) = eigvalues(i)*eigvalues(i) eigvalues_mat(i,i) = eigvalues(i)*eigvalues(i)
enddo enddo
call dgemm('N','N',n,n,n,1.d0,eigvectors,size(eigvectors,1), & call dgemm('N','N',n,n,n,1.d0,eigvectors,size(eigvectors,1), &
eigvalues_mat,size(eigvalues_mat,1),0.d0,matrix_tmp1,size(matrix_tmp1,1)) eigvalues_mat,size(eigvalues_mat,1),0.d0,matrix_tmp1,size(matrix_tmp1,1))
call dgemm('N','T',n,n,n,-1.d0,matrix_tmp1,size(matrix_tmp1,1), & call dgemm('N','T',n,n,n,-1.d0,matrix_tmp1,size(matrix_tmp1,1), &
eigvectors,size(eigvectors,1),0.d0,matrix_tmp2,size(matrix_tmp2,1)) eigvectors,size(eigvectors,1),0.d0,matrix_tmp2,size(matrix_tmp2,1))
print*,'r2_mat = '
do i = 1, n
write(*,'(100(F16.10,X))')r2_mat(:,i)
enddo
print*,'r2_mat new = ' print*,'r2_mat new = '
do i = 1, n do i = 1, n
write(*,'(100(F16.10,X))')matrix_tmp2(:,i) write(*,'(100(F16.10,X))')matrix_tmp2(:,i)
@ -1964,7 +1970,8 @@ subroutine exp_matrix(X,n,exp_X)
if(dabs(eigvalues(i)).gt.1.d-4)then if(dabs(eigvalues(i)).gt.1.d-4)then
eigvalues_mat(i,i) = dsin(eigvalues(i))/eigvalues(i) eigvalues_mat(i,i) = dsin(eigvalues(i))/eigvalues(i)
else ! Taylor development of sin(x)/x near x=0 = 1 - x^2/6 else ! Taylor development of sin(x)/x near x=0 = 1 - x^2/6
eigvalues_mat(i,i) = 1.d0 - eigvalues(i)*eigvalues(i)*c_1_3*0.5d0 eigvalues_mat(i,i) = 1.d0 - eigvalues(i)*eigvalues(i)*c_1_3*0.5d0 &
+ eigvalues(i)*eigvalues(i)*eigvalues(i)*eigvalues(i)*c_1_3*0.025d0
endif endif
enddo enddo
! matrix_tmp1 = W t^-1 sin(t) ! matrix_tmp1 = W t^-1 sin(t)