diff --git a/.travis.yml b/.travis.yml index eeeafd6c..06fd4c96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ os: linux -dist: trusty +dist: bionic sudo: false @@ -19,9 +19,11 @@ addons: packages: - gfortran - gcc - - liblapack-dev - - libblas-dev + - libatlas-base-dev +# - liblapack-dev +# - libblas-dev - wget + - eatmydata env: - OPAMROOT=$HOME/.opam @@ -29,12 +31,23 @@ env: cache: directories: - $HOME/.opam/ + - $HOME/cache language: python python: - - "2.7" + - "3.7" + +stages: + - configuration + - compilation + - testing + +jobs: + include: + - stage: configuration + script: eatmydata travis/configuration.sh + - stage: compilation + script: eatmydata travis/compilation.sh + - stage: testing + script: eatmydata 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/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 diff --git a/configure b/configure index ff79eaac..4ad726f9 100755 --- a/configure +++ b/configure @@ -499,7 +499,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 "" diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index f05b64f0..7b84221b 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -61,23 +61,23 @@ 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 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) + norm2 = norm2 + 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) + norm2 = norm2 + tilde_w(i) enddo endif - f = 1.d0/norm + f = 1.d0/norm2 tilde_w(:) = tilde_w(:) * f tilde_cW(0) = -1.d0 @@ -115,7 +115,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 @@ -126,7 +126,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 @@ -156,8 +156,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 @@ -288,7 +288,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 @@ -322,7 +322,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 @@ -335,7 +335,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) @@ -366,7 +366,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 @@ -380,7 +380,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 @@ -390,7 +390,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_ @@ -449,7 +449,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 @@ -525,7 +525,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 @@ -791,13 +791,13 @@ END_PROVIDER enddo endif - 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 8bbf41c7..4513e9cf 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) !todo: simplify for kpts use bitmasks use selection_types @@ -188,7 +188,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) @@ -209,7 +209,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 @@ -258,7 +258,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 @@ -272,7 +272,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 @@ -746,19 +746,19 @@ subroutine select_singles_and_doubles(i_generator,hole_mask,particle_mask,fock_d call splash_pq_complex(mask, sp, minilist, i_generator, interesting(0), bannedOrb, banned, mat_complex, interesting) if(.not.pert_2rdm)then - call fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat_complex, buf) + call fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat_complex, buf) else print*,irp_here,' not implemented for complex (fill_buffer_double_rdm_complex)' stop -1 - !call fill_buffer_double_rdm_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat_complex, buf,fullminilist, coef_fullminilist_rev_complex, fullinteresting(0)) + !call fill_buffer_double_rdm_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat_complex, buf,fullminilist, coef_fullminilist_rev_complex, fullinteresting(0)) endif else 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 endif!complex end if @@ -787,7 +787,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 @@ -799,7 +799,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 @@ -910,7 +910,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 @@ -2049,7 +2049,7 @@ end ! ! !==============================================================================! -subroutine fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm, mat, buf) +subroutine fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned, fock_diag_tmp, E0, pt2, variance, norm2, mat, buf) !todo: should be okay for complex use bitmasks use selection_types @@ -2062,7 +2062,7 @@ subroutine fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned 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 @@ -2174,7 +2174,7 @@ subroutine fill_buffer_double_complex(i_generator, sp, h1, h2, bannedOrb, banned endif pt2(istate) = pt2(istate) + e_pert variance(istate) = variance(istate) + cdabs(alpha_h_psi * alpha_h_psi) - norm(istate) = norm(istate) + cdabs(coef * coef) + norm2(istate) = norm2(istate) + cdabs(coef * coef) !!!DEBUG ! integer :: k diff --git a/src/cipsi/stochastic_cipsi.irp.f b/src/cipsi/stochastic_cipsi.irp.f index ef108fe1..f9d0ea42 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 @@ -91,17 +91,12 @@ subroutine run_stochastic_cipsi pt2 = 0.d0 variance = 0.d0 - norm = 0.d0 -! 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 + norm2 = 0.d0 + call ZMQ_pt2(psi_energy_with_nucl_rep,pt2,relative_error,error, variance, & + 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) / & @@ -109,8 +104,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_debug_fci() + 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) @@ -139,7 +133,7 @@ subroutine run_stochastic_cipsi endif 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 @@ -155,21 +149,16 @@ subroutine run_stochastic_cipsi pt2(:) = 0.d0 variance(:) = 0.d0 - norm(:) = 0.d0 - ! 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 + norm2(:) = 0.d0 + call ZMQ_pt2(psi_energy_with_nucl_rep, pt2,relative_error,error,variance, & + 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 442018ee..4456b53e 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 @@ -120,10 +120,10 @@ subroutine ZMQ_selection(N_in, pt2, variance, norm) endif 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 @@ -132,7 +132,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 @@ -144,10 +144,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 @@ -159,7 +159,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 @@ -171,10 +171,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 @@ -200,16 +200,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/davidson/diagonalization_hs2_dressed.irp.f b/src/davidson/diagonalization_hs2_dressed.irp.f index 9926dd37..ccde8965 100644 --- a/src/davidson/diagonalization_hs2_dressed.irp.f +++ b/src/davidson/diagonalization_hs2_dressed.irp.f @@ -457,7 +457,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 @@ -503,7 +503,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 dcca2cf2..1dde4c63 100644 --- a/src/davidson/diagonalize_ci.irp.f +++ b/src/davidson/diagonalize_ci.irp.f @@ -120,7 +120,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_real(:) = 0.d0 diff --git a/src/determinants/s2.irp.f b/src/determinants/s2.irp.f index 813bd3d4..031334a5 100644 --- a/src/determinants/s2.irp.f +++ b/src/determinants/s2.irp.f @@ -9,24 +9,35 @@ double precision function diag_S_mat_elem(key_i,Nint) ! Returns ! returns = - S_z*(S_z-1) 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 @@ -130,7 +141,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 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 diff --git a/travis/compilation.sh b/travis/compilation.sh new file mode 100755 index 00000000..1aa26dda --- /dev/null +++ b/travis/compilation.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Stage 2 + +# Extract cache from config stage +cd ../ +tar -zxf $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 && rm $HOME/cache/config.tgz + 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..b2122f5c --- /dev/null +++ b/travis/testing.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Stage 3 + +# Extract cache from compile stage +cd ../ +tar -zxf $HOME/cache/compil.tgz + +# Configure QP2 +cd qp2 +source ./quantum_package.rc +qp_test -a && rm $HOME/cache/compil.tgz + + + + +