From 253ec57ae0118fba44a3a31fca2ade621d0296a5 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Fri, 7 Aug 2020 19:33:02 +0200 Subject: [PATCH 1/9] Revert tests in travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eeeafd6c..c7730ed7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,5 +36,5 @@ python: script: - ./configure --install all --config ./config/travis.cfg -# - source ./quantum_package.rc ; ninja -j 1 -v -# - source ./quantum_package.rc ; qp_test -a + - source ./quantum_package.rc ; ninja -j 1 -v + - source ./quantum_package.rc ; qp_test -a From 770b4f6628f920848fbd2b599c53ff11a41456b2 Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Fri, 21 Aug 2020 12:30:14 -0500 Subject: [PATCH 2/9] compute s_z2_sz in diag_S_mat_elem --- src/determinants/s2.irp.f | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index 391d0073..c1dd06c0 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -8,24 +8,35 @@ double precision function diag_S_mat_elem(key_i,Nint) BEGIN_DOC ! Returns END_DOC - integer :: nup, i - integer(bit_kind) :: xorvec(N_int_max) + integer :: nup, ntot, i + integer(bit_kind) :: xorvec(N_int_max), upvec(N_int_max) do i=1,Nint xorvec(i) = xor(key_i(i,1),key_i(i,2)) enddo do i=1,Nint - xorvec(i) = iand(xorvec(i),key_i(i,1)) + upvec(i) = iand(xorvec(i),key_i(i,1)) enddo + ! nup is number of alpha unpaired + ! ntot is total number of unpaired nup = 0 + ntot = 0 do i=1,Nint if (xorvec(i) /= 0_bit_kind) then - nup += popcnt(xorvec(i)) + ntot += popcnt(xorvec(i)) + if (upvec(i) /= 0_bit_kind) then + nup += popcnt(upvec(i)) + endif endif enddo - diag_S_mat_elem = dble(nup) + + double precision :: sz + sz = nup - 0.5d0*ntot + + ! = + Sz(Sz-1) + diag_S_mat_elem = nup + sz*(sz-1) end From 233f9d8f2800d7ed52cb7fee76992be34f4e0f28 Mon Sep 17 00:00:00 2001 From: Kevin Gasperich Date: Fri, 21 Aug 2020 12:42:08 -0500 Subject: [PATCH 3/9] remove shift by `S_z2_Sz` (now included in `diag_S_mat_elem`) --- src/davidson/diagonalization_hs2_dressed.irp.f | 4 ++-- src/davidson/diagonalize_ci.irp.f | 2 +- src/determinants/s2.irp.f | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/davidson/diagonalization_hs2_dressed.irp.f b/src/davidson/diagonalization_hs2_dressed.irp.f index a5e85777..aa748628 100644 --- a/src/davidson/diagonalization_hs2_dressed.irp.f +++ b/src/davidson/diagonalization_hs2_dressed.irp.f @@ -450,7 +450,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ if (s2_eig) then h_p = s_ do k=1,shift2 - h_p(k,k) = h_p(k,k) + S_z2_Sz - expected_s2 + h_p(k,k) = h_p(k,k) - expected_s2 enddo if (only_expected_s2) then alpha = 0.1d0 @@ -496,7 +496,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ 0.d0, s_, size(s_,1)) do k=1,shift2 - s2(k) = s_(k,k) + S_z2_Sz + s2(k) = s_(k,k) enddo if (only_expected_s2) then diff --git a/src/davidson/diagonalize_ci.irp.f b/src/davidson/diagonalize_ci.irp.f index 996011cd..33e9478a 100644 --- a/src/davidson/diagonalize_ci.irp.f +++ b/src/davidson/diagonalize_ci.irp.f @@ -107,7 +107,7 @@ END_PROVIDER H_prime(1:N_det,1:N_det) = H_matrix_all_dets(1:N_det,1:N_det) + & alpha * S2_matrix_all_dets(1:N_det,1:N_det) do j=1,N_det - H_prime(j,j) = H_prime(j,j) + alpha*(S_z2_Sz - expected_s2) + H_prime(j,j) = H_prime(j,j) - alpha*expected_s2 enddo call lapack_diag(eigenvalues,eigenvectors,H_prime,size(H_prime,1),N_det) CI_electronic_energy(:) = 0.d0 diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index c1dd06c0..d73b2dbf 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -136,7 +136,7 @@ subroutine u_0_S2_u_0(e_0,u_0,n,keys_tmp,Nint,N_st,sze_8) call S2_u_0_nstates(v_0,u_0,n,keys_tmp,Nint,N_st,sze_8) do i=1,N_st - e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n)/u_dot_u(u_0(1,i),n) + S_z2_Sz + e_0(i) = u_dot_v(v_0(1,i),u_0(1,i),n)/u_dot_u(u_0(1,i),n) enddo end From 7cb492ef3c72f352b6e3768562d459113df07646 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sun, 23 Aug 2020 02:07:20 +0200 Subject: [PATCH 4/9] Norm -> Norm^2 --- src/cipsi/pt2_stoch_routines.irp.f | 40 +++++++++++++++--------------- src/cipsi/selection.irp.f | 26 +++++++++---------- src/cipsi/stochastic_cipsi.irp.f | 26 +++++++++---------- src/cipsi/zmq_selection.irp.f | 28 ++++++++++----------- src/fci/pt2.irp.f | 10 ++++---- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index b81eecda..52831c16 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -61,15 +61,15 @@ logical function testTeethBuilding(minF, N) allocate(tilde_w(N_det_generators), tilde_cW(0:N_det_generators)) - norm = 0.d0 - double precision :: norm + double precision :: norm2 + norm2 = 0.d0 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) + norm2 = norm2 + tilde_w(i) enddo - f = 1.d0/norm + f = 1.d0/norm2 tilde_w(:) = tilde_w(:) * f tilde_cW(0) = -1.d0 @@ -107,7 +107,7 @@ end function -subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) +subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm2, N_in) use f77_zmq use selection_types @@ -118,7 +118,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) ! integer, intent(inout) :: N_in double precision, intent(in) :: relative_error, E(N_states) double precision, intent(out) :: pt2(N_states),error(N_states) - double precision, intent(out) :: variance(N_states),norm(N_states) + double precision, intent(out) :: variance(N_states),norm2(N_states) integer :: i, N @@ -140,8 +140,8 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) if (N_det <= max(4,N_states) .or. pt2_N_teeth < 2) then pt2=0.d0 variance=0.d0 - norm=0.d0 - call ZMQ_selection(N_in, pt2, variance, norm) + norm2=0.d0 + call ZMQ_selection(N_in, pt2, variance, norm2) error(:) = 0.d0 else @@ -264,7 +264,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) nproc_target * 8.d0 * & ! bytes ( 0.5d0*pt2_n_tasks_max & ! task_id + 64.d0*pt2_n_tasks_max & ! task - + 3.d0*pt2_n_tasks_max*N_states & ! pt2, variance, norm + + 3.d0*pt2_n_tasks_max*N_states & ! pt2, variance, norm2 + 1.d0*pt2_n_tasks_max & ! i_generator, subset + 1.d0*(N_int*2.d0*ii+ ii) & ! selection buffer + 1.d0*(N_int*2.d0*ii+ ii) & ! sort selection buffer @@ -294,7 +294,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) print '(A)', '========== ================= =========== =============== =============== =================' - print '(A)', ' Samples Energy Stat. Err Variance Norm Seconds ' + print '(A)', ' Samples Energy Stat. Err Variance Norm^2 Seconds ' print '(A)', '========== ================= =========== =============== =============== =================' PROVIDE global_selection_buffer @@ -307,7 +307,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) pt2(pt2_stoch_istate) = w(pt2_stoch_istate,1) error(pt2_stoch_istate) = w(pt2_stoch_istate,2) variance(pt2_stoch_istate) = w(pt2_stoch_istate,3) - norm(pt2_stoch_istate) = w(pt2_stoch_istate,4) + norm2(pt2_stoch_istate) = w(pt2_stoch_istate,4) else call pt2_slave_inproc(i) @@ -338,7 +338,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) pt2(k) = 0.d0 enddo - call update_pt2_and_variance_weights(pt2, variance, norm, N_states) + call update_pt2_and_variance_weights(pt2, variance, norm2, N_states) end subroutine @@ -352,7 +352,7 @@ subroutine pt2_slave_inproc(i) end -subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, variance, norm, b, N_) +subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, variance, norm2, b, N_) use f77_zmq use selection_types use bitmasks @@ -362,7 +362,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc integer(ZMQ_PTR), intent(in) :: zmq_socket_pull double precision, intent(in) :: relative_error, E double precision, intent(out) :: pt2(N_states), error(N_states) - double precision, intent(out) :: variance(N_states), norm(N_states) + double precision, intent(out) :: variance(N_states), norm2(N_states) type(selection_buffer), intent(inout) :: b integer, intent(in) :: N_ @@ -421,7 +421,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc pt2(:) = -huge(1.) error(:) = huge(1.) variance(:) = huge(1.) - norm(:) = 0.d0 + norm2(:) = 0.d0 S(:) = 0d0 S2(:) = 0d0 T2(:) = 0d0 @@ -497,7 +497,7 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, varianc endif pt2(pt2_stoch_istate) = avg variance(pt2_stoch_istate) = avg2 - norm(pt2_stoch_istate) = avg3 + norm2(pt2_stoch_istate) = avg3 call wall_time(time) ! 1/(N-1.5) : see Brugger, The American Statistician (23) 4 p. 32 (1969) if(c > 2) then @@ -757,13 +757,13 @@ END_PROVIDER tilde_w(i) = psi_coef_sorted_gen(i,pt2_stoch_istate)**2 !+ 1.d-20 enddo - double precision :: norm - norm = 0.d0 + double precision :: norm2 + norm2 = 0.d0 do i=N_det_generators,1,-1 - norm += tilde_w(i) + norm2 += tilde_w(i) enddo - tilde_w(:) = tilde_w(:) / norm + tilde_w(:) = tilde_w(:) / norm2 tilde_cW(0) = -1.d0 do i=1,N_det_generators diff --git a/src/cipsi/selection.irp.f b/src/cipsi/selection.irp.f index f6350a66..0ca08a0f 100644 --- a/src/cipsi/selection.irp.f +++ b/src/cipsi/selection.irp.f @@ -19,7 +19,7 @@ BEGIN_PROVIDER [ double precision, variance_match_weight, (N_states) ] variance_match_weight(:) = 1.d0 END_PROVIDER -subroutine update_pt2_and_variance_weights(pt2, variance, norm, N_st) +subroutine update_pt2_and_variance_weights(pt2, variance, norm2, N_st) implicit none BEGIN_DOC ! Updates the PT2- and Variance- matching weights. @@ -27,7 +27,7 @@ subroutine update_pt2_and_variance_weights(pt2, variance, norm, N_st) integer, intent(in) :: N_st double precision, intent(in) :: pt2(N_st) double precision, intent(in) :: variance(N_st) - double precision, intent(in) :: norm(N_st) + double precision, intent(in) :: norm2(N_st) double precision :: avg, rpt2(N_st), element, dt, x integer :: k @@ -50,7 +50,7 @@ subroutine update_pt2_and_variance_weights(pt2, variance, norm, N_st) do k=1,N_st ! rPT2 - rpt2(k) = pt2(k)/(1.d0 + norm(k)) + rpt2(k) = pt2(k)/(1.d0 + norm2(k)) enddo avg = sum(pt2(1:N_st)) / dble(N_st) - 1.d-32 ! Avoid future division by zero @@ -179,7 +179,7 @@ subroutine get_mask_phase(det1, pm, Nint) end subroutine -subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset) +subroutine select_connected(i_generator,E0,pt2,variance,norm2,b,subset,csubset) use bitmasks use selection_types implicit none @@ -187,7 +187,7 @@ subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset) type(selection_buffer), intent(inout) :: b double precision, intent(inout) :: pt2(N_states) double precision, intent(inout) :: variance(N_states) - double precision, intent(inout) :: norm(N_states) + double precision, intent(inout) :: norm2(N_states) integer :: k,l double precision, intent(in) :: E0(N_states) @@ -205,7 +205,7 @@ subroutine select_connected(i_generator,E0,pt2,variance,norm,b,subset,csubset) particle_mask(k,1) = iand(generators_bitmask(k,1,s_part), not(psi_det_generators(k,1,i_generator)) ) particle_mask(k,2) = iand(generators_bitmask(k,2,s_part), not(psi_det_generators(k,2,i_generator)) ) enddo - call select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm,b,subset,csubset) + call select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm2,b,subset,csubset) deallocate(fock_diag_tmp) end subroutine @@ -254,7 +254,7 @@ double precision function get_phase_bi(phasemask, s1, s2, h1, p1, h2, p2, Nint) end -subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm,buf,subset,csubset) +subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_diag_tmp,E0,pt2,variance,norm2,buf,subset,csubset) use bitmasks use selection_types implicit none @@ -268,7 +268,7 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d double precision, intent(in) :: E0(N_states) double precision, intent(inout) :: pt2(N_states) double precision, intent(inout) :: variance(N_states) - double precision, intent(inout) :: norm(N_states) + double precision, intent(inout) :: norm2(N_states) type(selection_buffer), intent(inout) :: buf integer :: h1,h2,s1,s2,s3,i1,i2,ib,sp,k,i,j,nt,ii,sze @@ -644,9 +644,9 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d call splash_pq(mask, sp, minilist, i_generator, interesting(0), bannedOrb, banned, mat, interesting) if(.not.pert_2rdm)then - call fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf) + call fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat, buf) else - call fill_buffer_double_rdm(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf,fullminilist, coef_fullminilist_rev, fullinteresting(0)) + call fill_buffer_double_rdm(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat, buf,fullminilist, coef_fullminilist_rev, fullinteresting(0)) endif end if enddo @@ -664,7 +664,7 @@ end subroutine -subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf) +subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat, buf) use bitmasks use selection_types implicit none @@ -676,7 +676,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d double precision, intent(in) :: E0(N_states) double precision, intent(inout) :: pt2(N_states) double precision, intent(inout) :: variance(N_states) - double precision, intent(inout) :: norm(N_states) + double precision, intent(inout) :: norm2(N_states) type(selection_buffer), intent(inout) :: buf logical :: ok integer :: s1, s2, p1, p2, ib, j, istate @@ -787,7 +787,7 @@ subroutine fill_buffer_double(i_generator, sp, h1, h2, bannedOrb, banned, fock_d endif pt2(istate) = pt2(istate) + e_pert variance(istate) = variance(istate) + alpha_h_psi * alpha_h_psi - norm(istate) = norm(istate) + coef * coef + norm2(istate) = norm2(istate) + coef * coef !!!DEBUG ! pt2(istate) = pt2(istate) - e_pert + alpha_h_psi**2/delta_E diff --git a/src/cipsi/stochastic_cipsi.irp.f b/src/cipsi/stochastic_cipsi.irp.f index 98c78e88..b1534eae 100644 --- a/src/cipsi/stochastic_cipsi.irp.f +++ b/src/cipsi/stochastic_cipsi.irp.f @@ -4,13 +4,13 @@ subroutine run_stochastic_cipsi ! Selected Full Configuration Interaction with Stochastic selection and PT2. END_DOC integer :: i,j,k - double precision, allocatable :: pt2(:), variance(:), norm(:), rpt2(:), zeros(:) + double precision, allocatable :: pt2(:), variance(:), norm2(:), rpt2(:), zeros(:) integer :: to_select logical, external :: qp_stop double precision :: rss double precision, external :: memory_of_double - PROVIDE H_apply_buffer_allocated + PROVIDE H_apply_buffer_allocated N_iter = 1 threshold_generators = 1.d0 @@ -19,7 +19,7 @@ subroutine run_stochastic_cipsi rss = memory_of_double(N_states)*4.d0 call check_mem(rss,irp_here) - allocate (pt2(N_states), zeros(N_states), rpt2(N_states), norm(N_states), variance(N_states)) + allocate (pt2(N_states), zeros(N_states), rpt2(N_states), norm2(N_states), variance(N_states)) double precision :: hf_energy_ref logical :: has @@ -30,7 +30,7 @@ subroutine run_stochastic_cipsi zeros = 0.d0 pt2 = -huge(1.e0) rpt2 = -huge(1.e0) - norm = 0.d0 + norm2 = 0.d0 variance = huge(1.e0) if (s2_eig) then @@ -77,12 +77,12 @@ subroutine run_stochastic_cipsi pt2 = 0.d0 variance = 0.d0 - norm = 0.d0 + norm2 = 0.d0 call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, & - norm, to_select) ! Stochastic PT2 and selection + norm2, to_select) ! Stochastic PT2 and selection do k=1,N_states - rpt2(k) = pt2(k)/(1.d0 + norm(k)) + rpt2(k) = pt2(k)/(1.d0 + norm2(k)) enddo correlation_energy_ratio = (psi_energy_with_nucl_rep(1) - hf_energy_ref) / & @@ -90,7 +90,7 @@ subroutine run_stochastic_cipsi correlation_energy_ratio = min(1.d0,correlation_energy_ratio) call write_double(6,correlation_energy_ratio, 'Correlation ratio') - call print_summary(psi_energy_with_nucl_rep,pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2) + call print_summary(psi_energy_with_nucl_rep,pt2,error,variance,norm2,N_det,N_occ_pattern,N_states,psi_s2) call save_energy(psi_energy_with_nucl_rep, rpt2) @@ -111,7 +111,7 @@ subroutine run_stochastic_cipsi call diagonalize_CI call save_wavefunction call save_energy(psi_energy_with_nucl_rep, zeros) - if (qp_stop()) exit + if (qp_stop()) exit enddo if (.not.qp_stop()) then @@ -123,16 +123,16 @@ subroutine run_stochastic_cipsi pt2(:) = 0.d0 variance(:) = 0.d0 - norm(:) = 0.d0 + norm2(:) = 0.d0 call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, & - norm,0) ! Stochastic PT2 + norm2,0) ! Stochastic PT2 do k=1,N_states - rpt2(k) = pt2(k)/(1.d0 + norm(k)) + rpt2(k) = pt2(k)/(1.d0 + norm2(k)) enddo call save_energy(psi_energy_with_nucl_rep, rpt2) - call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2) + call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm2,N_det,N_occ_pattern,N_states,psi_s2) call save_iterations(psi_energy_with_nucl_rep(1:N_states),rpt2,N_det) call print_extrapolated_energy() endif diff --git a/src/cipsi/zmq_selection.irp.f b/src/cipsi/zmq_selection.irp.f index c0545aa1..22919117 100644 --- a/src/cipsi/zmq_selection.irp.f +++ b/src/cipsi/zmq_selection.irp.f @@ -1,4 +1,4 @@ -subroutine ZMQ_selection(N_in, pt2, variance, norm) +subroutine ZMQ_selection(N_in, pt2, variance, norm2) use f77_zmq use selection_types @@ -11,7 +11,7 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm) integer, external :: omp_get_thread_num double precision, intent(out) :: pt2(N_states) double precision, intent(out) :: variance(N_states) - double precision, intent(out) :: norm(N_states) + double precision, intent(out) :: norm2(N_states) ! PROVIDE psi_det psi_coef N_det qp_max_mem N_states pt2_F s2_eig N_det_generators @@ -112,10 +112,10 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm) enddo endif - !$OMP PARALLEL DEFAULT(shared) SHARED(b, pt2, variance, norm) PRIVATE(i) NUM_THREADS(nproc_target+1) + !$OMP PARALLEL DEFAULT(shared) SHARED(b, pt2, variance, norm2) PRIVATE(i) NUM_THREADS(nproc_target+1) i = omp_get_thread_num() if (i==0) then - call selection_collector(zmq_socket_pull, b, N, pt2, variance, norm) + call selection_collector(zmq_socket_pull, b, N, pt2, variance, norm2) else call selection_slave_inproc(i) endif @@ -124,7 +124,7 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm) do i=N_det+1,N_states pt2(i) = 0.d0 variance(i) = 0.d0 - norm(i) = 0.d0 + norm2(i) = 0.d0 enddo if (N_in > 0) then if (s2_eig) then @@ -136,10 +136,10 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm) do k=1,N_states pt2(k) = pt2(k) * f(k) variance(k) = variance(k) * f(k) - norm(k) = norm(k) * f(k) + norm2(k) = norm2(k) * f(k) enddo - call update_pt2_and_variance_weights(pt2, variance, norm, N_states) + call update_pt2_and_variance_weights(pt2, variance, norm2, N_states) end subroutine @@ -151,7 +151,7 @@ subroutine selection_slave_inproc(i) call run_selection_slave(1,i,pt2_e0_denominator) end -subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm) +subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm2) use f77_zmq use selection_types use bitmasks @@ -163,10 +163,10 @@ subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm) integer, intent(in) :: N double precision, intent(out) :: pt2(N_states) double precision, intent(out) :: variance(N_states) - double precision, intent(out) :: norm(N_states) + double precision, intent(out) :: norm2(N_states) double precision :: pt2_mwen(N_states) double precision :: variance_mwen(N_states) - double precision :: norm_mwen(N_states) + double precision :: norm2_mwen(N_states) integer(ZMQ_PTR),external :: new_zmq_to_qp_run_socket integer(ZMQ_PTR) :: zmq_to_qp_run_socket @@ -192,16 +192,16 @@ subroutine selection_collector(zmq_socket_pull, b, N, pt2, variance, norm) more = 1 pt2(:) = 0d0 variance(:) = 0.d0 - norm(:) = 0.d0 + norm2(:) = 0.d0 pt2_mwen(:) = 0.d0 variance_mwen(:) = 0.d0 - norm_mwen(:) = 0.d0 + norm2_mwen(:) = 0.d0 do while (more == 1) - call pull_selection_results(zmq_socket_pull, pt2_mwen, variance_mwen, norm_mwen, b2%val(1), b2%det(1,1,1), b2%cur, task_id, ntask) + call pull_selection_results(zmq_socket_pull, pt2_mwen, variance_mwen, norm2_mwen, b2%val(1), b2%det(1,1,1), b2%cur, task_id, ntask) pt2(:) += pt2_mwen(:) variance(:) += variance_mwen(:) - norm(:) += norm_mwen(:) + norm2(:) += norm2_mwen(:) do i=1, b2%cur call add_to_selection_buffer(b, b2%det(1,1,i), b2%val(i)) if (b2%val(i) > b%mini) exit diff --git a/src/fci/pt2.irp.f b/src/fci/pt2.irp.f index c916e0ef..83994781 100644 --- a/src/fci/pt2.irp.f +++ b/src/fci/pt2.irp.f @@ -36,7 +36,7 @@ subroutine run integer :: n_det_before, to_select double precision :: threshold_davidson_in - double precision :: E_CI_before(N_states), relative_error, error(N_states), variance(N_states), norm(N_states), rpt2(N_states) + double precision :: E_CI_before(N_states), relative_error, error(N_states), variance(N_states), norm2(N_states), rpt2(N_states) pt2(:) = 0.d0 @@ -45,16 +45,16 @@ subroutine run if (do_pt2) then call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, & - norm,0) ! Stochastic PT2 + norm2,0) ! Stochastic PT2 else - call ZMQ_selection(0, pt2, variance, norm) + call ZMQ_selection(0, pt2, variance, norm2) endif do k=1,N_states - rpt2(k) = pt2(k)/(1.d0 + norm(k)) + rpt2(k) = pt2(k)/(1.d0 + norm2(k)) enddo - call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm,N_det,N_occ_pattern,N_states,psi_s2) + call print_summary(psi_energy_with_nucl_rep(1:N_states),pt2,error,variance,norm2,N_det,N_occ_pattern,N_states,psi_s2) call save_energy(E_CI_before,pt2) end From 6c6070e81875f193156d93120ea143789761ba86 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 24 Aug 2020 14:01:56 +0200 Subject: [PATCH 5/9] Travis with stages (#128) * Travis in stages * Changed ubuntu to bionic * updated travis scripts --- .travis.yml | 23 +++++++++++++++++------ INSTALL.rst | 24 +++++++++++++++++++++++- travis/compilation.sh | 17 +++++++++++++++++ travis/configuration.sh | 10 ++++++++++ travis/testing.sh | 17 +++++++++++++++++ 5 files changed, 84 insertions(+), 7 deletions(-) create mode 100755 travis/compilation.sh create mode 100755 travis/configuration.sh create mode 100755 travis/testing.sh diff --git a/.travis.yml b/.travis.yml index c7730ed7..378c232e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ os: linux -dist: trusty +dist: bionic sudo: false @@ -29,12 +29,23 @@ env: cache: directories: - $HOME/.opam/ + - $HOME/cache language: python python: - - "2.7" + - "3.7" + +stages: + - configuration + - compilation + - testing + +jobs: + include: + - stage: configuration + script: travis/configuration.sh + - stage: compilation + script: travis/compilation.sh + - stage: testing + script: travis/testing.sh -script: - - ./configure --install all --config ./config/travis.cfg - - source ./quantum_package.rc ; ninja -j 1 -v - - source ./quantum_package.rc ; qp_test -a diff --git a/INSTALL.rst b/INSTALL.rst index f1657dbb..dd961950 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -36,7 +36,7 @@ Requirements - Fortran compiler : GNU Fortran, Intel Fortran or IBM XL Fortran - `GNU make`_ - `Autoconf`_ -- `Python`_ > 3.0 +- `Python`_ > 3.7 - |IRPF90| : Fortran code generator - |EZFIO| : Easy Fortran Input/Output library generator - |BLAS| and |LAPACK| @@ -142,6 +142,14 @@ IRPF90 *IRPF90* is a Fortran code generator for programming using the Implicit Reference to Parameters (IRP) method. +If you have *pip* for Python2, you can do + +.. code:: bash + + python2 -m pip install --user irpf90 + +Otherwise, + * Download the latest version of IRPF90 here : ``_ and move the downloaded archive in the :file:`${QP_ROOT}/external` directory @@ -385,3 +393,17 @@ Otherwise, * Copy :file:`docopt-0.6.2/docopt.py` in the :file:`${QP_ROOT}/scripts` directory +resultsFile +----------- + +*resultsFile* is a Python package to extract data from output files of quantum chemistry +codes. + +If you have *pip* for Python3, you can do + +.. code:: bash + + python3 -m pip install --user resultsFile + + + diff --git a/travis/compilation.sh b/travis/compilation.sh new file mode 100755 index 00000000..03505699 --- /dev/null +++ b/travis/compilation.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Stage 2 + +# Extract cache from config stage +cd ../ +tar -zxf $HOME/cache/config.tgz +rm $HOME/cache/config.tgz + +# Configure QP2 +cd qp2 +source ./quantum_package.rc +ninja -j 1 -v + +# Create cache +cd .. +tar -zcf $HOME/cache/compil.tgz qp2 + diff --git a/travis/configuration.sh b/travis/configuration.sh new file mode 100755 index 00000000..fa52e793 --- /dev/null +++ b/travis/configuration.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Stage 1 + +# Configure QP2 +./configure --install all --config ./config/travis.cfg + +# Create cache +cd ../ +tar -zcf $HOME/cache/config.tgz qp2 + diff --git a/travis/testing.sh b/travis/testing.sh new file mode 100755 index 00000000..d2eff9f0 --- /dev/null +++ b/travis/testing.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Stage 3 + +# Extract cache from compile stage +cd ../ +tar -zxf $HOME/cache/compil.tgz +rm $HOME/cache/compil.tgz + +# Configure QP2 +cd qp2 +source ./quantum_package.rc +qp_test -a + + + + + From 15535e6fa4717ce14b48cc47c6bbe5a15d4fd94e Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 25 Aug 2020 11:17:30 +0200 Subject: [PATCH 6/9] Keep travis cache on failure --- travis/compilation.sh | 3 +-- travis/testing.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/travis/compilation.sh b/travis/compilation.sh index 03505699..1aa26dda 100755 --- a/travis/compilation.sh +++ b/travis/compilation.sh @@ -4,7 +4,6 @@ # Extract cache from config stage cd ../ tar -zxf $HOME/cache/config.tgz -rm $HOME/cache/config.tgz # Configure QP2 cd qp2 @@ -13,5 +12,5 @@ ninja -j 1 -v # Create cache cd .. -tar -zcf $HOME/cache/compil.tgz qp2 +tar -zcf $HOME/cache/compil.tgz qp2 && rm $HOME/cache/config.tgz diff --git a/travis/testing.sh b/travis/testing.sh index d2eff9f0..b2122f5c 100755 --- a/travis/testing.sh +++ b/travis/testing.sh @@ -4,12 +4,11 @@ # Extract cache from compile stage cd ../ tar -zxf $HOME/cache/compil.tgz -rm $HOME/cache/compil.tgz # Configure QP2 cd qp2 source ./quantum_package.rc -qp_test -a +qp_test -a && rm $HOME/cache/compil.tgz From 628564b9b0c9d22ee51500c5fdefebbf4ccd73b6 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 26 Aug 2020 10:11:52 +0200 Subject: [PATCH 7/9] Use ATLAS on travis --- .travis.yml | 8 +++++--- config/travis.cfg | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 378c232e..a5001f33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,9 +19,11 @@ addons: packages: - gfortran - gcc + - libatlas-base-dev - liblapack-dev - libblas-dev - wget + - eatmydata env: - OPAMROOT=$HOME/.opam @@ -43,9 +45,9 @@ stages: jobs: include: - stage: configuration - script: travis/configuration.sh + script: eatmydata travis/configuration.sh - stage: compilation - script: travis/compilation.sh + script: eatmydata travis/compilation.sh - stage: testing - script: travis/testing.sh + script: eatmydata travis/testing.sh diff --git a/config/travis.cfg b/config/travis.cfg index 2be5d9a0..a609002e 100644 --- a/config/travis.cfg +++ b/config/travis.cfg @@ -11,9 +11,9 @@ # [COMMON] FC : gfortran -ffree-line-length-none -I . -g -fPIC -LAPACK_LIB : -llapack -lblas +LAPACK_LIB : -llapack -lblas IRPF90 : irpf90 -IRPF90_FLAGS : --ninja --align=32 --assert +IRPF90_FLAGS : --ninja --align=32 --assert # Global options ################ @@ -35,14 +35,14 @@ OPENMP : 1 ; Append OpenMP flags # -ffast-math and the Fortran-specific # -fno-protect-parens and -fstack-arrays. [OPT] -FCFLAGS : -Ofast -march=native +FCFLAGS : -Ofast -march=native # Profiling flags ################# # [PROFILE] -FC : -p -g +FC : -p -g FCFLAGS : -Ofast -fimplicit-none @@ -53,7 +53,7 @@ FCFLAGS : -Ofast -fimplicit-none # -g : Extra debugging information # [DEBUG] -FCFLAGS : -Ofast -fcheck=all -g -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant +FCFLAGS : -Ofast -fcheck=all -g -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant # OpenMP flags @@ -61,5 +61,5 @@ FCFLAGS : -Ofast -fcheck=all -g -Waliasing -Wampersand -Wconversion -Wsurprising # [OPENMP] FC : -fopenmp -IRPF90_FLAGS : --openmp +IRPF90_FLAGS : --openmp From fce69d05f1a168e2b30876461eb8901d767ba57d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 26 Aug 2020 10:19:40 +0200 Subject: [PATCH 8/9] Basis sex -> Basis set --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index a2ba4268..4f930a34 100755 --- a/configure +++ b/configure @@ -500,7 +500,7 @@ echo " ||----w | " echo " || || " echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "" -echo "If you have PIP, you can install the Basis Sex Exchange command-line tool:" +echo "If you have PIP, you can install the Basis Set Exchange command-line tool:" echo "" echo " ./configure -i bse" echo "" From 4ac514dd630b5c5d354e98fc36c61daa45b78f41 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 26 Aug 2020 10:58:28 +0200 Subject: [PATCH 9/9] Use ATLAS on travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5001f33..06fd4c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,8 @@ addons: - gfortran - gcc - libatlas-base-dev - - liblapack-dev - - libblas-dev +# - liblapack-dev +# - libblas-dev - wget - eatmydata