9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-12-22 03:23:29 +01:00

Merge pull request #5 from QuantumPackage/dev-stable-tc-scf

Dev stable tc scf
This commit is contained in:
AbdAmmar 2023-03-16 17:19:49 +01:00 committed by GitHub
commit 6370d7fce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 108 additions and 156 deletions

View File

@ -312,9 +312,6 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
end do end do
deallocate(indices) deallocate(indices)
! !$OMP CRITICAL
! print *, 'Step1: ', i_generator, preinteresting(0)
! !$OMP END CRITICAL
allocate(banned(mo_num, mo_num,2), bannedOrb(mo_num, 2)) allocate(banned(mo_num, mo_num,2), bannedOrb(mo_num, 2))
allocate (mat(N_states, mo_num, mo_num)) allocate (mat(N_states, mo_num, mo_num))
@ -466,17 +463,8 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
fullinteresting(sze+1) = i fullinteresting(sze+1) = i
end if end if
end do end do
allocate (fullminilist (N_int, 2, fullinteresting(0)), & allocate (fullminilist (N_int, 2, fullinteresting(0)), &
minilist (N_int, 2, interesting(0)) ) minilist (N_int, 2, interesting(0)) )
! if(pert_2rdm)then
! allocate(coef_fullminilist_rev(N_states,fullinteresting(0)))
! do i=1,fullinteresting(0)
! do j = 1, N_states
! coef_fullminilist_rev(j,i) = psi_coef_sorted(fullinteresting(i),j)
! enddo
! enddo
! endif
do i=1,fullinteresting(0) do i=1,fullinteresting(0)
fullminilist(:,:,i) = psi_det_sorted(:,:,fullinteresting(i)) fullminilist(:,:,i) = psi_det_sorted(:,:,fullinteresting(i))
@ -524,33 +512,19 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d
call spot_isinwf(mask, fullminilist, i_generator, fullinteresting(0), banned, fullMatch, fullinteresting) call spot_isinwf(mask, fullminilist, i_generator, fullinteresting(0), banned, fullMatch, fullinteresting)
if(fullMatch) cycle if(fullMatch) cycle
! !$OMP CRITICAL
! print *, 'Step3: ', i_generator, h1, interesting(0)
! !$OMP END CRITICAL
call splash_pq(mask, sp, minilist, i_generator, interesting(0), bannedOrb, banned, mat, interesting) call splash_pq(mask, sp, minilist, i_generator, interesting(0), bannedOrb, banned, mat, interesting)
call fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf)
! if(.not.pert_2rdm)then
call fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf)
! else
! call fill_buffer_double_rdm(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf,fullminilist, coef_fullminilist_rev, fullinteresting(0))
! endif
end if end if
enddo enddo
if(s1 /= s2) monoBdo = .false. if(s1 /= s2) monoBdo = .false.
enddo enddo
deallocate(fullminilist,minilist) deallocate(fullminilist,minilist)
! if(pert_2rdm)then
! deallocate(coef_fullminilist_rev)
! endif
enddo enddo
enddo enddo
deallocate(preinteresting, prefullinteresting, interesting, fullinteresting) deallocate(preinteresting, prefullinteresting, interesting, fullinteresting)
deallocate(banned, bannedOrb,mat) deallocate(banned, bannedOrb,mat)
end subroutine end subroutine
subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf) subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2_data, mat, buf)
use bitmasks use bitmasks
use selection_types use selection_types
@ -606,18 +580,6 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
! to a determinant of the future. In that case, the determinant will be ! to a determinant of the future. In that case, the determinant will be
! detected as already generated when generating in the future with a ! detected as already generated when generating in the future with a
! double excitation. ! double excitation.
!
! if (.not.do_singles) then
! if ((h1 == p1) .or. (h2 == p2)) then
! cycle
! endif
! endif
!
! if (.not.do_doubles) then
! if ((h1 /= p1).and.(h2 /= p2)) then
! cycle
! endif
! endif
! ----- ! -----
if(bannedOrb(p2, s2)) cycle if(bannedOrb(p2, s2)) cycle
@ -974,13 +936,10 @@ subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, intere
call get_mask_phase(psi_det_sorted(1,1,interesting(i)), phasemask,N_int) call get_mask_phase(psi_det_sorted(1,1,interesting(i)), phasemask,N_int)
if(nt == 4) then if(nt == 4) then
! call get_d2_reference(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
call get_d2(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i))) call get_d2(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
else if(nt == 3) then else if(nt == 3) then
! call get_d1_reference(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
call get_d1(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i))) call get_d1(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
else else
! call get_d0_reference(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
call get_d0(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i))) call get_d0(det(1,1,i), phasemask, bannedOrb, banned, mat, mask, h, p, sp, psi_selectors_coef_transp(1, interesting(i)))
end if end if
else if(nt == 4) then else if(nt == 4) then
@ -1540,8 +1499,6 @@ subroutine past_d2(banned, p, sp)
end if end if
end end
subroutine spot_isinwf(mask, det, i_gen, N, banned, fullMatch, interesting) subroutine spot_isinwf(mask, det, i_gen, N, banned, fullMatch, interesting)
use bitmasks use bitmasks
implicit none implicit none

View File

@ -64,7 +64,7 @@ subroutine run_cipsi
endif endif
if (N_det > N_det_max) then if (N_det > N_det_max) then
psi_det(1:N_int,1:2,1:N_det) = psi_det_sorted_tc_gen(1:N_int,1:2,1:N_det) psi_det(1:N_int,1:2,1:N_det) = psi_det_generators(1:N_int,1:2,1:N_det)
psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states) psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states)
N_det = N_det_max N_det = N_det_max
soft_touch N_det psi_det psi_coef soft_touch N_det psi_det psi_coef

View File

@ -52,7 +52,7 @@ subroutine pt2_tc_bi_ortho
! call routine_save_right ! call routine_save_right
if (N_det > N_det_max) then if (N_det > N_det_max) then
psi_det(1:N_int,1:2,1:N_det) = psi_det_sorted_tc_gen(1:N_int,1:2,1:N_det) psi_det(1:N_int,1:2,1:N_det) = psi_det_generators(1:N_int,1:2,1:N_det)
psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states) psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states)
N_det = N_det_max N_det = N_det_max
soft_touch N_det psi_det psi_coef soft_touch N_det psi_det psi_coef

View File

@ -134,7 +134,6 @@ subroutine ZMQ_pt2(E, pt2_data, pt2_data_err, relative_error, N_in)
PROVIDE psi_det_hii selection_weight pseudo_sym PROVIDE psi_det_hii selection_weight pseudo_sym
PROVIDE n_act_orb n_inact_orb n_core_orb n_virt_orb n_del_orb seniority_max PROVIDE n_act_orb n_inact_orb n_core_orb n_virt_orb n_del_orb seniority_max
PROVIDE excitation_beta_max excitation_alpha_max excitation_max PROVIDE excitation_beta_max excitation_alpha_max excitation_max
PROVIDE psi_selectors_rcoef_bi_orth_transp psi_selectors_lcoef_bi_orth_transp
if (h0_type == 'CFG') then if (h0_type == 'CFG') then
PROVIDE psi_configuration_hii det_to_configuration PROVIDE psi_configuration_hii det_to_configuration

View File

@ -181,7 +181,6 @@ subroutine select_singles_and_doubles(i_generator, hole_mask,particle_mask, fock
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_tc_order psi_bilinear_matrix_order PROVIDE psi_bilinear_matrix_rows psi_det_sorted_tc_order psi_bilinear_matrix_order
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp_tc PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp_tc
PROVIDE psi_selectors_rcoef_bi_orth_transp psi_selectors_lcoef_bi_orth_transp
PROVIDE banned_excitation PROVIDE banned_excitation
@ -464,15 +463,15 @@ subroutine select_singles_and_doubles(i_generator, hole_mask,particle_mask, fock
do i = 1, fullinteresting(0) do i = 1, fullinteresting(0)
do k = 1, N_int do k = 1, N_int
fullminilist(k,1,i) = psi_det_sorted_tc(k,1,fullinteresting(i)) fullminilist(k,1,i) = psi_selectors(k,1,fullinteresting(i))
fullminilist(k,2,i) = psi_det_sorted_tc(k,2,fullinteresting(i)) fullminilist(k,2,i) = psi_selectors(k,2,fullinteresting(i))
enddo enddo
enddo enddo
do i = 1, interesting(0) do i = 1, interesting(0)
do k = 1, N_int do k = 1, N_int
minilist(k,1,i) = psi_det_sorted_tc(k,1,interesting(i)) minilist(k,1,i) = psi_selectors(k,1,interesting(i))
minilist(k,2,i) = psi_det_sorted_tc(k,2,interesting(i)) minilist(k,2,i) = psi_selectors(k,2,interesting(i))
enddo enddo
enddo enddo
@ -616,7 +615,6 @@ subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, intere
PROVIDE psi_selectors_coef_transp_tc psi_det_sorted_tc PROVIDE psi_selectors_coef_transp_tc psi_det_sorted_tc
PROVIDE psi_selectors_rcoef_bi_orth_transp psi_selectors_lcoef_bi_orth_transp
mat = 0d0 mat = 0d0
@ -628,7 +626,10 @@ subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, intere
negMask(i,2) = not(mask(i,2)) negMask(i,2) = not(mask(i,2))
end do end do
! print*,'in selection '
do i = 1, N_sel do i = 1, N_sel
! call debug_det(det(1,1,i),N_int)
! print*,i,dabs(psi_selectors_coef_transp_tc(1,2,i) * psi_selectors_coef_transp_tc(1,1,i))
if(interesting(i) < 0) then if(interesting(i) < 0) then
stop 'prefetch interesting(i) and det(i)' stop 'prefetch interesting(i) and det(i)'
endif endif
@ -674,9 +675,6 @@ subroutine splash_pq(mask, sp, det, i_gen, N_sel, bannedOrb, banned, mat, intere
perMask(j,1) = iand(mask(j,1), not(det(j,1,i))) perMask(j,1) = iand(mask(j,1), not(det(j,1,i)))
perMask(j,2) = iand(mask(j,2), not(det(j,2,i))) perMask(j,2) = iand(mask(j,2), not(det(j,2,i)))
end do end do
! call get_d3_h ( det(1,1,i), bannedOrb, banned, mat , mask, p, sp, psi_selectors_coef_transp_tc (1, interesting(i)) )
! call get_d3_htc( det(1,1,i), bannedOrb, banned, mat_r, mat_l, mask, p, sp, psi_selectors_rcoef_bi_orth_transp(1, interesting(i)) &
! , psi_selectors_lcoef_bi_orth_transp(1, interesting(i)) )
call bitstring_to_list_in_selection(perMask(1,1), h(1,1), h(0,1), N_int) call bitstring_to_list_in_selection(perMask(1,1), h(1,1), h(0,1), N_int)
call bitstring_to_list_in_selection(perMask(1,2), h(1,2), h(0,2), N_int) call bitstring_to_list_in_selection(perMask(1,2), h(1,2), h(0,2), N_int)
@ -918,16 +916,27 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
endif endif
val = 4.d0 * psi_h_alpha * alpha_h_psi val = 4.d0 * psi_h_alpha * alpha_h_psi
tmp = dsqrt(delta_E * delta_E + val) tmp = dsqrt(delta_E * delta_E + val)
if (delta_E < 0.d0) then ! if (delta_E < 0.d0) then
tmp = -tmp ! tmp = -tmp
endif ! endif
e_pert(istate) = 0.5d0 * (tmp - delta_E) e_pert(istate) = 0.25 * val / delta_E
! e_pert(istate) = 0.5d0 * (tmp - delta_E)
if(dsqrt(dabs(tmp)).gt.1.d-4.and.dabs(alpha_h_psi).gt.1.d-4)then if(dsqrt(dabs(tmp)).gt.1.d-4.and.dabs(alpha_h_psi).gt.1.d-4)then
coef(istate) = e_pert(istate) / alpha_h_psi coef(istate) = e_pert(istate) / psi_h_alpha
else else
coef(istate) = alpha_h_psi / delta_E coef(istate) = alpha_h_psi / delta_E
endif endif
if(selection_tc == 1)then
if(e_pert(istate).lt.0.d0)then
e_pert(istate)=0.d0
else
e_pert(istate)=-e_pert(istate)
endif
else if(selection_tc == -1)then
if(e_pert(istate).gt.0.d0)e_pert(istate)=0.d0
endif
! if(selection_tc == 1 )then ! if(selection_tc == 1 )then
! if(e_pert(istate).lt.0.d0)then ! if(e_pert(istate).lt.0.d0)then
! e_pert(istate) = 0.d0 ! e_pert(istate) = 0.d0
@ -940,7 +949,6 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
enddo enddo
do_diag = sum(dabs(coef)) > 0.001d0 .and. N_states > 1
do istate = 1, N_states do istate = 1, N_states

View File

@ -125,7 +125,11 @@ subroutine merge_selection_buffers(b1, b2)
enddo enddo
b2%det => detmp b2%det => detmp
b2%val => val b2%val => val
b2%mini = min(b2%mini,b2%val(b2%N)) ! if(selection_tc == 1)then
! b2%mini = max(b2%mini,b2%val(b2%N))
! else
b2%mini = min(b2%mini,b2%val(b2%N))
! endif
b2%cur = nmwen b2%cur = nmwen
end end
@ -157,7 +161,11 @@ subroutine sort_selection_buffer(b)
end do end do
deallocate(b%det,iorder) deallocate(b%det,iorder)
b%det => detmp b%det => detmp
b%mini = min(b%mini,b%val(b%N)) ! if(selection_tc == 1)then
! b%mini = max(b%mini,b%val(b%N))
! else
b%mini = min(b%mini,b%val(b%N))
! endif
b%cur = nmwen b%cur = nmwen
end subroutine end subroutine

View File

@ -17,7 +17,6 @@ end
subroutine provide_everything subroutine provide_everything
PROVIDE H_apply_buffer_allocated mo_two_e_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context N_states_diag PROVIDE H_apply_buffer_allocated mo_two_e_integrals_in_map psi_det_generators psi_coef_generators psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context N_states_diag
PROVIDE psi_selectors_rcoef_bi_orth_transp psi_selectors_lcoef_bi_orth_transp
PROVIDE pt2_e0_denominator mo_num N_int ci_energy mpi_master zmq_state zmq_context PROVIDE pt2_e0_denominator mo_num N_int ci_energy mpi_master zmq_state zmq_context
PROVIDE psi_det psi_coef threshold_generators state_average_weight PROVIDE psi_det psi_coef threshold_generators state_average_weight
@ -312,7 +311,6 @@ subroutine run_slave_main
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_tc_order psi_bilinear_matrix_order PROVIDE psi_bilinear_matrix_rows psi_det_sorted_tc_order psi_bilinear_matrix_order
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted_tc PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp psi_det_sorted_tc
PROVIDE psi_selectors_rcoef_bi_orth_transp psi_selectors_lcoef_bi_orth_transp
PROVIDE psi_det_hii selection_weight pseudo_sym pt2_min_parallel_tasks PROVIDE psi_det_hii selection_weight pseudo_sym pt2_min_parallel_tasks

View File

@ -54,7 +54,7 @@ subroutine run_stochastic_cipsi
! if (N_det > N_det_max) then ! if (N_det > N_det_max) then
! psi_det(1:N_int,1:2,1:N_det) = psi_det_sorted_tc_gen(1:N_int,1:2,1:N_det) ! psi_det(1:N_int,1:2,1:N_det) = psi_det_generators(1:N_int,1:2,1:N_det)
! psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states) ! psi_coef(1:N_det,1:N_states) = psi_coef_sorted_tc_gen(1:N_det,1:N_states)
! N_det = N_det_max ! N_det = N_det_max
! soft_touch N_det psi_det psi_coef ! soft_touch N_det psi_det psi_coef
@ -108,6 +108,7 @@ subroutine run_stochastic_cipsi
ept2(N_iter-1) = E_tc + nuclear_repulsion + (pt2_data % pt2(1))/norm ept2(N_iter-1) = E_tc + nuclear_repulsion + (pt2_data % pt2(1))/norm
pt1(N_iter-1) = dsqrt(pt2_data % overlap(1,1)) pt1(N_iter-1) = dsqrt(pt2_data % overlap(1,1))
call diagonalize_CI_tc_bi_ortho(ndet, E_tc,norm,pt2_data,print_pt2) call diagonalize_CI_tc_bi_ortho(ndet, E_tc,norm,pt2_data,print_pt2)
! stop
if (qp_stop()) exit if (qp_stop()) exit
enddo enddo
! print*,'data to extrapolate ' ! print*,'data to extrapolate '

View File

@ -49,9 +49,8 @@ subroutine diagonalize_CI_tc_bi_ortho(ndet, E_tc,norm,pt2_data,print_pt2)
psi_coef(i,j) = dabs(psi_l_coef_bi_ortho(i,j) * psi_r_coef_bi_ortho(i,j)) psi_coef(i,j) = dabs(psi_l_coef_bi_ortho(i,j) * psi_r_coef_bi_ortho(i,j))
enddo enddo
enddo enddo
SOFT_TOUCH eigval_left_tc_bi_orth eigval_right_tc_bi_orth leigvec_tc_bi_orth reigvec_tc_bi_orth norm_ground_left_right_bi_orth psi_coef psi_l_coef_bi_ortho psi_r_coef_bi_ortho SOFT_TOUCH eigval_left_tc_bi_orth eigval_right_tc_bi_orth leigvec_tc_bi_orth reigvec_tc_bi_orth norm_ground_left_right_bi_orth
SOFT_TOUCH psi_l_coef_bi_ortho psi_r_coef_bi_ortho psi_coef
call save_tc_bi_ortho_wavefunction call save_tc_bi_ortho_wavefunction
end end

View File

@ -43,9 +43,14 @@ END_PROVIDER
! For Single reference wave functions, the generator is the ! For Single reference wave functions, the generator is the
! Hartree-Fock determinant ! Hartree-Fock determinant
END_DOC END_DOC
psi_det_sorted_tc_gen = psi_det_sorted_tc psi_det_sorted_tc_gen = psi_det_sorted_tc
psi_coef_sorted_tc_gen = psi_coef_sorted_tc psi_coef_sorted_tc_gen = psi_coef_sorted_tc
psi_det_sorted_tc_gen_order = psi_det_sorted_tc_order psi_det_sorted_tc_gen_order = psi_det_sorted_tc_order
integer :: i
! do i = 1,N_det
! print*,'i = ',i
! call debug_det(psi_det_sorted_tc(1,1,i),N_int)
! enddo
END_PROVIDER END_PROVIDER

View File

@ -18,15 +18,6 @@ BEGIN_PROVIDER [ integer, N_det_selectors]
double precision :: norm, norm_max double precision :: norm, norm_max
call write_time(6) call write_time(6)
N_det_selectors = N_det N_det_selectors = N_det
! norm = 1.d0
! do i=1,N_det
! norm = norm - psi_average_norm_contrib_tc(i)
! if (norm - 1.d-10 < 1.d0 - threshold_selectors) then
! N_det_selectors = i
! exit
! endif
! enddo
N_det_selectors = max(N_det_selectors,N_det_generators)
call write_int(6,N_det_selectors,'Number of selectors') call write_int(6,N_det_selectors,'Number of selectors')
END_PROVIDER END_PROVIDER
@ -47,11 +38,9 @@ END_PROVIDER
enddo enddo
do k=1,N_states do k=1,N_states
do i=1,N_det_selectors do i=1,N_det_selectors
psi_selectors_coef(i,k) = psi_coef_sorted_tc_gen(i,k) psi_selectors_coef(i,k) = psi_coef_sorted_tc_gen(i,k)
psi_selectors_coef_tc(i,1,k) = psi_l_coef_sorted_bi_ortho(i,k) psi_selectors_coef_tc(i,1,k) = psi_l_coef_sorted_bi_ortho(i,k)
psi_selectors_coef_tc(i,2,k) = psi_r_coef_sorted_bi_ortho(i,k) psi_selectors_coef_tc(i,2,k) = psi_r_coef_sorted_bi_ortho(i,k)
! psi_selectors_coef_tc(i,1,k) = 1.d0
! psi_selectors_coef_tc(i,2,k) = 1.d0
enddo enddo
enddo enddo
@ -74,25 +63,6 @@ END_PROVIDER
enddo enddo
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ double precision, psi_selectors_rcoef_bi_orth_transp, (N_states, psi_det_size) ]
&BEGIN_PROVIDER [ double precision, psi_selectors_lcoef_bi_orth_transp, (N_states, psi_det_size) ]
implicit none
integer :: i, k
psi_selectors_rcoef_bi_orth_transp = 0.d0
psi_selectors_lcoef_bi_orth_transp = 0.d0
print*,'N_det,N_det_selectors',N_det,N_det_selectors
do i = 1, N_det_selectors
do k = 1, N_states
psi_selectors_rcoef_bi_orth_transp(k,i) = psi_r_coef_sorted_bi_ortho(i,k)
psi_selectors_lcoef_bi_orth_transp(k,i) = psi_l_coef_sorted_bi_ortho(i,k)
enddo
enddo
END_PROVIDER
BEGIN_PROVIDER [ integer, psi_selectors_size ] BEGIN_PROVIDER [ integer, psi_selectors_size ]
implicit none implicit none
psi_selectors_size = psi_det_size psi_selectors_size = psi_det_size

View File

@ -11,7 +11,7 @@ BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_tc, (psi_det_size) ]
psi_average_norm_contrib_tc(:) = 0.d0 psi_average_norm_contrib_tc(:) = 0.d0
do k=1,N_states do k=1,N_states
do i=1,N_det do i=1,N_det
psi_average_norm_contrib_tc(i) = psi_average_norm_contrib_tc(i) + & psi_average_norm_contrib_tc(i) = &
dabs(psi_l_coef_bi_ortho(i,k)*psi_r_coef_bi_ortho(i,k))*state_average_weight(k) dabs(psi_l_coef_bi_ortho(i,k)*psi_r_coef_bi_ortho(i,k))*state_average_weight(k)
enddo enddo
enddo enddo
@ -26,33 +26,39 @@ END_PROVIDER
&BEGIN_PROVIDER [ double precision, psi_coef_sorted_tc, (psi_det_size,N_states) ] &BEGIN_PROVIDER [ double precision, psi_coef_sorted_tc, (psi_det_size,N_states) ]
&BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted_tc, (psi_det_size) ] &BEGIN_PROVIDER [ double precision, psi_average_norm_contrib_sorted_tc, (psi_det_size) ]
&BEGIN_PROVIDER [ integer, psi_det_sorted_tc_order, (psi_det_size) ] &BEGIN_PROVIDER [ integer, psi_det_sorted_tc_order, (psi_det_size) ]
&BEGIN_PROVIDER [double precision, psi_r_coef_sorted_bi_ortho, (psi_det_size, N_states)]
&BEGIN_PROVIDER [double precision, psi_l_coef_sorted_bi_ortho, (psi_det_size, N_states)]
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Wave function sorted by determinants contribution to the norm (state-averaged) ! Wave function sorted by determinants contribution to the norm (state-averaged)
! !
! psi_det_sorted_tc_order(i) -> k : index in psi_det ! psi_det_sorted_tc_order(i) -> k : index in psi_det
!
! psi_r_coef_sorted_bi_ortho : right coefficients corresponding to psi_det_sorted_tc
!
! psi_l_coef_sorted_bi_ortho : left coefficients corresponding to psi_det_sorted_tc
END_DOC END_DOC
integer :: i,j,k integer :: i,j,k
integer, allocatable :: iorder(:) integer, allocatable :: iorder(:)
allocate ( iorder(N_det) ) allocate ( iorder(N_det) )
do i=1,N_det do i=1,N_det
psi_average_norm_contrib_sorted_tc(i) = -psi_average_norm_contrib_tc(i)
iorder(i) = i iorder(i) = i
psi_average_norm_contrib_sorted_tc(i) = -psi_average_norm_contrib_tc(i)
enddo enddo
! call dsort(psi_average_norm_contrib_sorted_tc,iorder,N_det) call dsort(psi_average_norm_contrib_sorted_tc,iorder,N_det)
do i=1,N_det do i=1,N_det
psi_average_norm_contrib_sorted_tc(i) = -psi_average_norm_contrib_sorted_tc(i)
do j=1,N_int do j=1,N_int
psi_det_sorted_tc(j,1,i) = psi_det(j,1,iorder(i)) psi_det_sorted_tc(j,1,i) = psi_det(j,1,iorder(i))
psi_det_sorted_tc(j,2,i) = psi_det(j,2,iorder(i)) psi_det_sorted_tc(j,2,i) = psi_det(j,2,iorder(i))
enddo enddo
psi_average_norm_contrib_sorted_tc(i) = -psi_average_norm_contrib_sorted_tc(i) psi_det_sorted_tc_order(iorder(i)) = i
psi_det_sorted_tc_order(iorder(i)) = i
enddo enddo
double precision :: accu double precision :: accu
do k=1,N_states do k=1,N_states
accu = 0.d0 accu = 0.d0
do i=1,N_det do i=1,N_det
psi_coef_sorted_tc(i,k) = dsqrt(dabs(psi_l_coef_bi_ortho(iorder(i),k)*psi_r_coef_bi_ortho(iorder(i),k))) psi_coef_sorted_tc(i,k) = dsqrt(psi_average_norm_contrib_sorted_tc(i))
accu += psi_coef_sorted_tc(i,k)**2 accu += psi_coef_sorted_tc(i,k)**2
enddo enddo
accu = 1.d0/dsqrt(accu) accu = 1.d0/dsqrt(accu)
@ -66,28 +72,16 @@ END_PROVIDER
psi_average_norm_contrib_sorted_tc(N_det+1:psi_det_size) = 0.d0 psi_average_norm_contrib_sorted_tc(N_det+1:psi_det_size) = 0.d0
psi_det_sorted_tc_order(N_det+1:psi_det_size) = 0 psi_det_sorted_tc_order(N_det+1:psi_det_size) = 0
deallocate(iorder)
END_PROVIDER
BEGIN_PROVIDER [double precision, psi_r_coef_sorted_bi_ortho, (psi_det_size, N_states)]
&BEGIN_PROVIDER [double precision, psi_l_coef_sorted_bi_ortho, (psi_det_size, N_states)]
BEGIN_DOC
! psi_r_coef_sorted_bi_ortho : right coefficients corresponding to psi_det_sorted_tc
! psi_l_coef_sorted_bi_ortho : left coefficients corresponding to psi_det_sorted_tc
END_DOC
implicit none
integer :: i, j, k
psi_r_coef_sorted_bi_ortho = 0.d0 psi_r_coef_sorted_bi_ortho = 0.d0
psi_l_coef_sorted_bi_ortho = 0.d0 psi_l_coef_sorted_bi_ortho = 0.d0
do i = 1, N_det do i = 1, N_det
psi_r_coef_sorted_bi_ortho(i,1) = psi_r_coef_bi_ortho(psi_det_sorted_tc_order(i),1) psi_r_coef_sorted_bi_ortho(i,1:N_states) = psi_r_coef_bi_ortho(iorder(i),1:N_states)
psi_l_coef_sorted_bi_ortho(i,1) = psi_l_coef_bi_ortho(psi_det_sorted_tc_order(i),1) psi_l_coef_sorted_bi_ortho(i,1:N_states) = psi_l_coef_bi_ortho(iorder(i),1:N_states)
enddo enddo
deallocate(iorder)
END_PROVIDER END_PROVIDER
BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_tc_bit, (N_int,2,psi_det_size) ] BEGIN_PROVIDER [ integer(bit_kind), psi_det_sorted_tc_bit, (N_int,2,psi_det_size) ]
&BEGIN_PROVIDER [ double precision, psi_coef_sorted_tc_bit, (psi_det_size,N_states) ] &BEGIN_PROVIDER [ double precision, psi_coef_sorted_tc_bit, (psi_det_size,N_states) ]
implicit none implicit none

View File

@ -136,15 +136,15 @@ BEGIN_PROVIDER [ double precision, psi_r_coef_bi_ortho, (psi_det_size,N_states)
END_PROVIDER END_PROVIDER
subroutine save_tc_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psilcoef,psircoef) subroutine save_tc_wavefunction_general(ndet,nstates,psidet,sze,dim_psicoef,psilcoef,psircoef)
implicit none implicit none
BEGIN_DOC BEGIN_DOC
! Save the wave function into the |EZFIO| file ! Save the wave function into the |EZFIO| file
END_DOC END_DOC
use bitmasks use bitmasks
include 'constants.include.F' include 'constants.include.F'
integer, intent(in) :: ndet,nstates,dim_psicoef integer, intent(in) :: ndet,nstates,dim_psicoef,sze
integer(bit_kind), intent(in) :: psidet(N_int,2,ndet) integer(bit_kind), intent(in) :: psidet(N_int,2,sze)
double precision, intent(in) :: psilcoef(dim_psicoef,nstates) double precision, intent(in) :: psilcoef(dim_psicoef,nstates)
double precision, intent(in) :: psircoef(dim_psicoef,nstates) double precision, intent(in) :: psircoef(dim_psicoef,nstates)
integer*8, allocatable :: psi_det_save(:,:,:) integer*8, allocatable :: psi_det_save(:,:,:)
@ -188,23 +188,17 @@ subroutine save_tc_wavefunction_general(ndet,nstates,psidet,dim_psicoef,psilcoef
call ezfio_set_tc_bi_ortho_psi_r_coef_bi_ortho(psir_coef_save) call ezfio_set_tc_bi_ortho_psi_r_coef_bi_ortho(psir_coef_save)
deallocate (psil_coef_save,psir_coef_save) deallocate (psil_coef_save,psir_coef_save)
! allocate (psi_coef_save(ndet_qp_edit,nstates))
! do k=1,nstates
! do i=1,ndet_qp_edit
! psi_coef_save(i,k) = psicoef(i,k)
! enddo
! enddo
!
! call ezfio_set_determinants_psi_coef_qp_edit(psi_coef_save)
! deallocate (psi_coef_save)
call write_int(6,ndet,'Saved determinantsi and psi_r/psi_l coef') call write_int(6,ndet,'Saved determinantsi and psi_r/psi_l coef')
endif endif
end end
subroutine save_tc_bi_ortho_wavefunction subroutine save_tc_bi_ortho_wavefunction
implicit none implicit none
call save_tc_wavefunction_general(N_det,N_states,psi_det,size(psi_l_coef_bi_ortho, 1),psi_l_coef_bi_ortho,psi_r_coef_bi_ortho) 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 call routine_save_right_bi_ortho
end end
@ -214,9 +208,9 @@ subroutine routine_save_right_bi_ortho
integer :: i integer :: i
allocate(coef_tmp(N_det, N_states)) allocate(coef_tmp(N_det, N_states))
do i = 1, N_det do i = 1, N_det
coef_tmp(i,1:N_states) = psi_r_coef_bi_ortho(i,1:N_states) coef_tmp(i,1:N_states) = psi_r_coef_sorted_bi_ortho(i,1:N_states)
enddo enddo
call save_wavefunction_general_unormalized(N_det,N_states,psi_det,size(coef_tmp,1),coef_tmp(1,1)) call save_wavefunction_general_unormalized(N_det,N_states,psi_det_sorted_tc,size(coef_tmp,1),coef_tmp(1,1))
end end
subroutine routine_save_left_right_bi_ortho subroutine routine_save_left_right_bi_ortho

View File

@ -11,7 +11,7 @@ program tc_bi_ortho
touch read_wf touch read_wf
touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid touch my_grid_becke my_n_pt_r_grid my_n_pt_a_grid
call routine_diag call routine_diag
! call test call save_tc_bi_ortho_wavefunction
end end
subroutine test subroutine test
@ -19,18 +19,19 @@ subroutine test
integer :: i,j integer :: i,j
double precision :: hmono,htwoe,hthree,htot double precision :: hmono,htwoe,hthree,htot
use bitmasks use bitmasks
print*,'reading the wave function '
print*,'test' do i = 1, N_det
! call htilde_mu_mat_bi_ortho(psi_det(1,1,1), psi_det(1,1,2), N_int, hmono, htwoe, hthree, htot) call debug_det(psi_det(1,1,i),N_int)
call double_htilde_mu_mat_bi_ortho(N_int,psi_det(1,1,1), psi_det(1,1,2), hmono, htwoe, htot) print*,i,psi_l_coef_bi_ortho(i,1)*psi_r_coef_bi_ortho(i,1)
print*,hmono, htwoe, htot print*,i,psi_l_coef_bi_ortho(i,1),psi_r_coef_bi_ortho(i,1)
enddo
end end
subroutine routine_diag subroutine routine_diag
implicit none implicit none
! provide eigval_right_tc_bi_orth ! provide eigval_right_tc_bi_orth
provide overlap_bi_ortho ! provide overlap_bi_ortho
! provide htilde_matrix_elmt_bi_ortho ! provide htilde_matrix_elmt_bi_ortho
integer ::i,j integer ::i,j
print*,'eigval_right_tc_bi_orth = ',eigval_right_tc_bi_orth(1) print*,'eigval_right_tc_bi_orth = ',eigval_right_tc_bi_orth(1)
@ -46,16 +47,7 @@ subroutine routine_diag
print*,'e_corr_double_bi_orth = ',e_corr_double_bi_orth print*,'e_corr_double_bi_orth = ',e_corr_double_bi_orth
print*,'Left/right eigenvectors' print*,'Left/right eigenvectors'
do i = 1,N_det 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) 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 enddo
do j=1,N_states
do i=1,N_det
psi_l_coef_bi_ortho(i,j) = leigvec_tc_bi_orth(i,j)
psi_r_coef_bi_ortho(i,j) = reigvec_tc_bi_orth(i,j)
enddo
enddo
SOFT_TOUCH psi_l_coef_bi_ortho psi_r_coef_bi_ortho
call save_tc_bi_ortho_wavefunction
! call routine_save_left_right_bi_ortho
end end

View File

@ -12,6 +12,25 @@
enddo enddo
END_PROVIDER END_PROVIDER
subroutine diagonalize_CI_tc
implicit none
BEGIN_DOC
! Replace the coefficients of the |CI| states by the coefficients of the
! eigenstates of the |CI| matrix.
END_DOC
integer :: i,j
do j=1,N_states
do i=1,N_det
psi_l_coef_bi_ortho(i,j) = leigvec_tc_bi_orth(i,j)
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
BEGIN_PROVIDER [double precision, eigval_right_tc_bi_orth, (N_states)] BEGIN_PROVIDER [double precision, eigval_right_tc_bi_orth, (N_states)]

View File

@ -207,3 +207,11 @@ type: logical
doc: If |true|, only the right part of WF is used to compute spin dens doc: If |true|, only the right part of WF is used to compute spin dens
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml
default: False default: False
[save_sorted_tc_wf]
type: logical
doc: If |true|, save the bi-ortho wave functions in a sorted way
interface: ezfio,provider,ocaml
default: True