mirror of
https://github.com/QuantumPackage/qp2.git
synced 2024-11-14 01:53:49 +01:00
working on complex cipsi
This commit is contained in:
parent
17b9b423a9
commit
299243e2ce
@ -20,7 +20,7 @@ subroutine run_cipsi
|
||||
logical :: has
|
||||
double precision :: relative_error
|
||||
|
||||
PROVIDE H_apply_buffer_allocated
|
||||
PROVIDE h_apply_buffer_allocated
|
||||
|
||||
relative_error=PT2_relative_error
|
||||
|
||||
@ -34,7 +34,7 @@ subroutine run_cipsi
|
||||
call make_s2_eigenfunction
|
||||
endif
|
||||
if (is_complex) then
|
||||
call diagonalize_CI_complex
|
||||
call diagonalize_ci_complex
|
||||
else
|
||||
call diagonalize_CI
|
||||
endif
|
||||
@ -94,13 +94,13 @@ subroutine run_cipsi
|
||||
norm = 0.d0
|
||||
threshold_generators = 1.d0
|
||||
SOFT_TOUCH threshold_generators
|
||||
if (is_complex) then
|
||||
call zmq_pt2_complex(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm, 0) ! Stochastic PT2
|
||||
else
|
||||
! if (is_complex) then
|
||||
! call zmq_pt2_complex(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
! norm, 0) ! Stochastic PT2
|
||||
! else
|
||||
call zmq_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm, 0) ! Stochastic PT2
|
||||
endif
|
||||
! endif
|
||||
threshold_generators = threshold_generators_save
|
||||
SOFT_TOUCH threshold_generators
|
||||
endif
|
||||
@ -127,11 +127,12 @@ subroutine run_cipsi
|
||||
n_det_before = N_det
|
||||
to_select = int(sqrt(dble(N_states))*dble(N_det)*selection_factor)
|
||||
to_select = max(N_states_diag, to_select)
|
||||
call zmq_selection(to_select, pt2, variance, norm)
|
||||
if (is_complex) then
|
||||
call zmq_selection_complex(to_select, pt2, variance, norm)
|
||||
! call zmq_selection_complex(to_select, pt2, variance, norm)
|
||||
PROVIDE psi_coef_complex
|
||||
else
|
||||
call zmq_selection(to_select, pt2, variance, norm)
|
||||
! call zmq_selection(to_select, pt2, variance, norm)
|
||||
PROVIDE psi_coef
|
||||
endif
|
||||
PROVIDE psi_det
|
||||
@ -168,13 +169,13 @@ print *, (correlation_energy_ratio <= correlation_energy_ratio_max)
|
||||
norm(:) = 0.d0
|
||||
threshold_generators = 1d0
|
||||
SOFT_TOUCH threshold_generators
|
||||
if (is_complex) then
|
||||
call zmq_pt2_complex(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
else
|
||||
! if (is_complex) then
|
||||
! call zmq_pt2_complex(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
! norm,0) ! Stochastic PT2
|
||||
! else
|
||||
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
endif
|
||||
! endif
|
||||
SOFT_TOUCH threshold_generators
|
||||
endif
|
||||
print *, 'N_det = ', N_det
|
||||
|
@ -63,11 +63,19 @@ logical function testTeethBuilding(minF, N)
|
||||
|
||||
norm = 0.d0
|
||||
double precision :: norm
|
||||
do i=N_det_generators,1,-1
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate) * &
|
||||
psi_coef_sorted_gen(i,pt2_stoch_istate)
|
||||
norm = norm + tilde_w(i)
|
||||
enddo
|
||||
if (is_complex) then
|
||||
do i=N_det_generators,1,-1
|
||||
tilde_w(i) = cdabs(psi_coef_sorted_gen_complex(i,pt2_stoch_istate) * &
|
||||
psi_coef_sorted_gen_complex(i,pt2_stoch_istate))
|
||||
norm = norm + tilde_w(i)
|
||||
enddo
|
||||
else
|
||||
do i=N_det_generators,1,-1
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate) * &
|
||||
psi_coef_sorted_gen(i,pt2_stoch_istate)
|
||||
norm = norm + tilde_w(i)
|
||||
enddo
|
||||
endif
|
||||
|
||||
f = 1.d0/norm
|
||||
tilde_w(:) = tilde_w(:) * f
|
||||
@ -126,11 +134,19 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
|
||||
integer(ZMQ_PTR), external :: new_zmq_to_qp_run_socket
|
||||
type(selection_buffer) :: b
|
||||
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
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
|
||||
PROVIDE psi_det_hii selection_weight pseudo_sym
|
||||
if (is_complex) then
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
PROVIDE psi_bilinear_matrix_transp_order psi_selectors_coef_transp_complex psi_det_sorted
|
||||
PROVIDE psi_det_hii selection_weight pseudo_sym
|
||||
else
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
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
|
||||
PROVIDE psi_det_hii selection_weight pseudo_sym
|
||||
endif
|
||||
|
||||
if (h0_type == 'SOP') then
|
||||
PROVIDE psi_occ_pattern_hii det_to_occ_pattern
|
||||
@ -159,8 +175,15 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
|
||||
state_average_weight(pt2_stoch_istate) = 1.d0
|
||||
TOUCH state_average_weight pt2_stoch_istate selection_weight
|
||||
|
||||
PROVIDE nproc pt2_F mo_two_e_integrals_in_map mo_one_e_integrals pt2_w
|
||||
PROVIDE psi_selectors pt2_u pt2_J pt2_R
|
||||
if (is_complex) then
|
||||
!todo: psi_selectors isn't linked to psi_selectors_coef anymore; should we provide both?
|
||||
PROVIDE nproc pt2_F mo_two_e_integrals_in_map mo_one_e_integrals_complex pt2_w
|
||||
PROVIDE psi_selectors pt2_u pt2_J pt2_R
|
||||
else
|
||||
PROVIDE nproc pt2_F mo_two_e_integrals_in_map mo_one_e_integrals pt2_w
|
||||
PROVIDE psi_selectors pt2_u pt2_J pt2_R
|
||||
endif
|
||||
|
||||
call new_parallel_job(zmq_to_qp_run_socket, zmq_socket_pull, 'pt2')
|
||||
|
||||
integer, external :: zmq_put_psi
|
||||
@ -242,6 +265,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in)
|
||||
|
||||
double precision :: mem_collector, mem, rss
|
||||
|
||||
!todo: check memory allocation for complex
|
||||
call resident_memory(rss)
|
||||
|
||||
mem_collector = 8.d0 * & ! bytes
|
||||
@ -751,10 +775,16 @@ END_PROVIDER
|
||||
allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators))
|
||||
|
||||
tilde_cW(0) = 0d0
|
||||
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
|
||||
enddo
|
||||
|
||||
if (is_complex) then
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = cdabs(psi_coef_sorted_gen_complex(i,pt2_stoch_istate))**2 !+ 1.d-20
|
||||
enddo
|
||||
else
|
||||
do i=1,N_det_generators
|
||||
tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20
|
||||
enddo
|
||||
endif
|
||||
|
||||
double precision :: norm
|
||||
norm = 0.d0
|
||||
@ -773,7 +803,7 @@ END_PROVIDER
|
||||
pt2_n_0(1) = 0
|
||||
do
|
||||
pt2_u_0 = tilde_cW(pt2_n_0(1))
|
||||
r = tilde_cW(pt2_n_0(1) + pt2_minDetInFirstTeeth)
|
||||
r = tilde_cW(pt2_n_0(1) + pt2_mindetinfirstteeth)
|
||||
pt2_W_T = (1d0 - pt2_u_0) / dble(pt2_N_teeth)
|
||||
if(pt2_W_T >= r - pt2_u_0) then
|
||||
exit
|
||||
@ -799,7 +829,7 @@ END_PROVIDER
|
||||
endif
|
||||
ASSERT(tooth_width > 0.d0)
|
||||
do i=pt2_n_0(t)+1, pt2_n_0(t+1)
|
||||
pt2_w(i) = tilde_w(i) * pt2_W_T / tooth_width
|
||||
pt2_w(i) = tilde_w(i) * pt2_w_t / tooth_width
|
||||
end do
|
||||
end do
|
||||
|
||||
|
@ -21,7 +21,8 @@ subroutine run_selection_slave(thread,iproc,energy)
|
||||
double precision :: pt2(N_states)
|
||||
double precision :: variance(N_states)
|
||||
double precision :: norm(N_states)
|
||||
|
||||
|
||||
!todo: check for providers that are now unlinked for real/complex
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
PROVIDE psi_bilinear_matrix_transp_rows_loc psi_bilinear_matrix_transp_columns
|
||||
|
@ -758,7 +758,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d
|
||||
if (.not.is_a_1h1p(det)) cycle
|
||||
endif
|
||||
|
||||
Hii = diag_H_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int)
|
||||
Hii = diag_h_mat_elem_fock(psi_det_generators(1,1,i_generator),det,fock_diag_tmp,N_int)
|
||||
|
||||
w = 0d0
|
||||
|
||||
|
@ -14,10 +14,17 @@ subroutine run_slave_cipsi
|
||||
end
|
||||
|
||||
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 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 N_det_selectors pt2_stoch_istate N_det selection_weight pseudo_sym
|
||||
if (is_complex) then
|
||||
PROVIDE H_apply_buffer_allocated mo_two_e_integrals_in_map psi_det_generators psi_coef_generators_complex psi_det_sorted_bit psi_selectors n_det_generators n_states generators_bitmask zmq_context N_states_diag
|
||||
PROVIDE pt2_e0_denominator mo_num N_int ci_energy mpi_master zmq_state zmq_context
|
||||
PROVIDE psi_det psi_coef_complex threshold_generators state_average_weight
|
||||
PROVIDE N_det_selectors pt2_stoch_istate N_det selection_weight pseudo_sym
|
||||
else
|
||||
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 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 N_det_selectors pt2_stoch_istate N_det selection_weight pseudo_sym
|
||||
endif
|
||||
end
|
||||
|
||||
subroutine run_slave_main
|
||||
@ -51,9 +58,15 @@ subroutine run_slave_main
|
||||
|
||||
zmq_to_qp_run_socket = new_zmq_to_qp_run_socket()
|
||||
|
||||
PROVIDE psi_det psi_coef threshold_generators state_average_weight mpi_master
|
||||
PROVIDE zmq_state N_det_selectors pt2_stoch_istate N_det pt2_e0_denominator
|
||||
PROVIDE N_det_generators N_states N_states_diag pt2_e0_denominator mpi_rank
|
||||
if (is_complex) then
|
||||
PROVIDE psi_det psi_coef_complex threshold_generators state_average_weight mpi_master
|
||||
PROVIDE zmq_state N_det_selectors pt2_stoch_istate N_det pt2_e0_denominator
|
||||
PROVIDE N_det_generators N_states N_states_diag pt2_e0_denominator mpi_rank
|
||||
else
|
||||
PROVIDE psi_det psi_coef threshold_generators state_average_weight mpi_master
|
||||
PROVIDE zmq_state N_det_selectors pt2_stoch_istate N_det pt2_e0_denominator
|
||||
PROVIDE N_det_generators N_states N_states_diag pt2_e0_denominator mpi_rank
|
||||
endif
|
||||
|
||||
IRP_IF MPI
|
||||
call MPI_BARRIER(MPI_COMM_WORLD, ierr)
|
||||
|
@ -36,7 +36,11 @@ subroutine run_stochastic_cipsi
|
||||
if (s2_eig) then
|
||||
call make_s2_eigenfunction
|
||||
endif
|
||||
call diagonalize_ci
|
||||
if (is_complex) then
|
||||
call diagonalize_ci_complex
|
||||
else
|
||||
call diagonalize_ci
|
||||
endif
|
||||
call save_wavefunction
|
||||
|
||||
call ezfio_has_hartree_fock_energy(has)
|
||||
@ -60,7 +64,11 @@ subroutine run_stochastic_cipsi
|
||||
if (s2_eig) then
|
||||
call make_s2_eigenfunction
|
||||
endif
|
||||
call diagonalize_CI
|
||||
if (is_complex) then
|
||||
call diagonalize_ci_complex
|
||||
else
|
||||
call diagonalize_CI
|
||||
endif
|
||||
call save_wavefunction
|
||||
endif
|
||||
|
||||
@ -84,8 +92,13 @@ subroutine run_stochastic_cipsi
|
||||
pt2 = 0.d0
|
||||
variance = 0.d0
|
||||
norm = 0.d0
|
||||
call zmq_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm, to_select) ! Stochastic PT2 and selection
|
||||
if (is_complex) then
|
||||
call zmq_pt2_complex(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm, to_select) ! Stochastic PT2 and selection
|
||||
else
|
||||
call zmq_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, &
|
||||
norm, to_select) ! Stochastic PT2 and selection
|
||||
endif
|
||||
|
||||
do k=1,N_states
|
||||
rpt2(k) = pt2(k)/(1.d0 + norm(k))
|
||||
@ -107,14 +120,22 @@ subroutine run_stochastic_cipsi
|
||||
if (qp_stop()) exit
|
||||
|
||||
! Add selected determinants
|
||||
call copy_H_apply_buffer_to_wf()
|
||||
call copy_h_apply_buffer_to_wf()
|
||||
! call save_wavefunction
|
||||
|
||||
PROVIDE psi_coef
|
||||
if (is_complex) then
|
||||
PROVIDE psi_coef_complex
|
||||
else
|
||||
PROVIDE psi_coef
|
||||
endif
|
||||
PROVIDE psi_det
|
||||
PROVIDE psi_det_sorted
|
||||
|
||||
call diagonalize_CI
|
||||
if (is_complex) then
|
||||
call diagonalize_ci_complex
|
||||
else
|
||||
call diagonalize_CI
|
||||
endif
|
||||
call save_wavefunction
|
||||
call save_energy(psi_energy_with_nucl_rep, zeros)
|
||||
if (qp_stop()) exit
|
||||
@ -122,7 +143,11 @@ subroutine run_stochastic_cipsi
|
||||
|
||||
if (.not.qp_stop()) then
|
||||
if (N_det < N_det_max) then
|
||||
call diagonalize_CI
|
||||
if (is_complex) then
|
||||
call diagonalize_ci_complex
|
||||
else
|
||||
call diagonalize_CI
|
||||
endif
|
||||
call save_wavefunction
|
||||
call save_energy(psi_energy_with_nucl_rep, zeros)
|
||||
endif
|
||||
@ -130,8 +155,13 @@ subroutine run_stochastic_cipsi
|
||||
pt2(:) = 0.d0
|
||||
variance(:) = 0.d0
|
||||
norm(:) = 0.d0
|
||||
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
if (is_complex) then
|
||||
call zmq_pt2_complex(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
else
|
||||
call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, &
|
||||
norm,0) ! Stochastic PT2
|
||||
endif
|
||||
|
||||
do k=1,N_states
|
||||
rpt2(k) = pt2(k)/(1.d0 + norm(k))
|
||||
|
@ -17,6 +17,7 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm)
|
||||
|
||||
N = max(N_in,1)
|
||||
if (.True.) then
|
||||
!todo: some providers have becom unlinked for real/complex (det/coef); do these need to be provided?
|
||||
PROVIDE pt2_e0_denominator nproc
|
||||
PROVIDE psi_bilinear_matrix_columns_loc psi_det_alpha_unique psi_det_beta_unique
|
||||
PROVIDE psi_bilinear_matrix_rows psi_det_sorted_order psi_bilinear_matrix_order
|
||||
@ -105,9 +106,16 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm)
|
||||
f(:) = 1.d0
|
||||
if (.not.do_pt2) then
|
||||
double precision :: f(N_states), u_dot_u
|
||||
do k=1,min(N_det,N_states)
|
||||
f(k) = 1.d0 / u_dot_u(psi_selectors_coef(1,k), N_det_selectors)
|
||||
enddo
|
||||
if (is_complex) then
|
||||
double precision :: u_dot_u_complex
|
||||
do k=1,min(N_det,N_states)
|
||||
f(k) = 1.d0 / u_dot_u_complex(psi_selectors_coef_complex(1,k), N_det_selectors)
|
||||
enddo
|
||||
else
|
||||
do k=1,min(N_det,N_states)
|
||||
f(k) = 1.d0 / u_dot_u(psi_selectors_coef(1,k), N_det_selectors)
|
||||
enddo
|
||||
endif
|
||||
endif
|
||||
|
||||
!$OMP PARALLEL DEFAULT(shared) SHARED(b, pt2, variance, norm) PRIVATE(i) NUM_THREADS(nproc_target+1)
|
||||
|
@ -1,14 +1,41 @@
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
current:
|
||||
select_connected
|
||||
select_singles_and_doubles (this should be separated real/complex)
|
||||
spot_isinwf (same for real/complex)
|
||||
splash_pq (separate real/complex)
|
||||
get_d{0,1,2} (separate real/complex)
|
||||
fill_buffer_double (separate real/complex)
|
||||
|
||||
fci
|
||||
run_cipsi
|
||||
zmq_pt2_complex
|
||||
selection buffer? (val, mini)?
|
||||
selection_slave_inproc
|
||||
zmq_selection_complex
|
||||
run_{,stochastic_}cipsi
|
||||
everything okay except:
|
||||
zmq_pt2{,_complex} (todo: combine real/complex)
|
||||
selection buffer? (val, mini)?
|
||||
selection_slave_inproc
|
||||
run_selection_slave
|
||||
select_connected
|
||||
|
||||
pt2_slave_inproc
|
||||
run_pt2_slave{,_large,_small}
|
||||
select_connected
|
||||
|
||||
zmq_selection_complex
|
||||
selection_collector
|
||||
pull_selection_results
|
||||
add_to_selection_buffer
|
||||
selection_slave_inproc
|
||||
run_selection_slave (has split for complex?)
|
||||
select_connected
|
||||
run_slave_cipsi
|
||||
run_stochastic_cipsi
|
||||
run_slave_main
|
||||
change memory allocation for complex (first see how many arrays will need to change type)
|
||||
run_pt2_slave (large/small?)
|
||||
select_connected
|
||||
selection_buffer:
|
||||
if anything complex, need to change zmq calls
|
||||
{push,pull}_pt2_results
|
||||
|
||||
-------------------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user