diff --git a/plugins/FOBOCI/H_apply_dressed_autonom.irp.f b/plugins/FOBOCI/H_apply_dressed_autonom.irp.f index 69929afd..abe6ef2e 100644 --- a/plugins/FOBOCI/H_apply_dressed_autonom.irp.f +++ b/plugins/FOBOCI/H_apply_dressed_autonom.irp.f @@ -273,7 +273,7 @@ subroutine H_apply_dressed_pert_monoexc(key_in, hole_1,particl_1,i_generator,ipr integer,parameter :: size_max = 3072 integer, intent(in) :: Ndet_generators - double precision, intent(in) :: E_ref + double precision, intent(inout) :: E_ref double precision, intent(inout) :: delta_ij_generators_(Ndet_generators,Ndet_generators) integer(bit_kind), intent(in) :: psi_det_generators_input(N_int,2,Ndet_generators) @@ -438,7 +438,7 @@ subroutine H_apply_dressed_pert(delta_ij_generators_, Ndet_generators,psi_det_g integer, intent(in) :: Ndet_generators - double precision, intent(in) :: E_ref + double precision, intent(inout) :: E_ref double precision, intent(inout) :: delta_ij_generators_(Ndet_generators,Ndet_generators) integer(bit_kind), intent(in) :: psi_det_generators_input(N_int,2,Ndet_generators) diff --git a/plugins/FOBOCI/NEEDED_CHILDREN_MODULES b/plugins/FOBOCI/NEEDED_CHILDREN_MODULES index e40934be..16fce081 100644 --- a/plugins/FOBOCI/NEEDED_CHILDREN_MODULES +++ b/plugins/FOBOCI/NEEDED_CHILDREN_MODULES @@ -1 +1 @@ -Perturbation Selectors_no_sorted Hartree_Fock Davidson +Perturbation Selectors_no_sorted Hartree_Fock Davidson CISD diff --git a/plugins/FOBOCI/hcc_1h1p.irp.f b/plugins/FOBOCI/hcc_1h1p.irp.f index 66cf2fd4..bad073db 100644 --- a/plugins/FOBOCI/hcc_1h1p.irp.f +++ b/plugins/FOBOCI/hcc_1h1p.irp.f @@ -15,11 +15,10 @@ subroutine routine call diagonalize_CI call test_hcc call test_mulliken -! call SC2_1h1p(psi_det,psi_coef,energies, & -! diag_H_elements,size(psi_coef,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) allocate(H_matrix(N_det,N_det)) - call SC2_1h1p_full(psi_det,psi_coef,energies, & - H_matrix,size(psi_coef,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) + stop 'SC2_1h1p_full is not in the git!' +! call SC2_1h1p_full(psi_det,psi_coef,energies, & +! H_matrix,size(psi_coef,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) deallocate(H_matrix) integer :: i,j double precision :: accu,coef_hf diff --git a/plugins/MRCC_CASSD/.gitignore b/plugins/MRCC_CASSD/.gitignore deleted file mode 100644 index 97bd070c..00000000 --- a/plugins/MRCC_CASSD/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Automatically created by $QP_ROOT/scripts/module/module_handler.py -.ninja_deps -.ninja_log -AO_Basis -Bitmask -Determinants -Electrons -Ezfio_files -Generators_full -Hartree_Fock -IRPF90_man -IRPF90_temp -Integrals_Bielec -Integrals_Monoelec -MOGuess -MO_Basis -MRCC_Utils -Makefile -Makefile.depend -Nuclei -Perturbation -Properties -Pseudo -Psiref_CAS -Psiref_Utils -Selectors_full -Utils -ZMQ -ezfio_interface.irp.f -irpf90.make -irpf90_entities -mrcc_cassd -mrcc_noiter -tags \ No newline at end of file diff --git a/plugins/MRCC_CASSD/EZFIO.cfg b/plugins/MRCC_CASSD/EZFIO.cfg deleted file mode 100644 index 17ee7f29..00000000 --- a/plugins/MRCC_CASSD/EZFIO.cfg +++ /dev/null @@ -1,17 +0,0 @@ -[energy] -type: double precision -doc: Calculated energy -interface: ezfio - -[thresh_mrcc] -type: Threshold -doc: Threshold on the convergence of the MRCC energy -interface: ezfio,provider,ocaml -default: 1.e-5 - -[n_it_mrcc_max] -type: Strictly_positive_int -doc: Maximum number of MRCC iterations -interface: ezfio,provider,ocaml -default: 10 - diff --git a/plugins/MRCC_CASSD/NEEDED_CHILDREN_MODULES b/plugins/MRCC_CASSD/NEEDED_CHILDREN_MODULES deleted file mode 100644 index a8404d62..00000000 --- a/plugins/MRCC_CASSD/NEEDED_CHILDREN_MODULES +++ /dev/null @@ -1 +0,0 @@ -Perturbation Selectors_full Generators_full Psiref_CAS MRCC_Utils diff --git a/plugins/MRCC_CASSD/README.rst b/plugins/MRCC_CASSD/README.rst deleted file mode 100644 index 0e38fe4c..00000000 --- a/plugins/MRCC_CASSD/README.rst +++ /dev/null @@ -1,80 +0,0 @@ -=========== -MRCC Module -=========== - -MRCC as a coupled cluster on a CAS+SD wave function. - -Needed Modules -============== - -.. Do not edit this section. It was auto-generated from the -.. by the `update_README.py` script. - -.. image:: tree_dependency.png - -* `Perturbation `_ -* `Selectors_full `_ -* `Generators_full `_ -* `Psiref_CAS `_ -* `MRCC_Utils `_ - -Documentation -============= - -.. Do not edit this section. It was auto-generated from the -.. by the `update_README.py` script. - -`mrcc `_ - Undocumented - - -`print_cas_coefs `_ - Undocumented - -Needed Modules -============== -.. Do not edit this section It was auto-generated -.. by the `update_README.py` script. - - -.. image:: tree_dependency.png - -* `Perturbation `_ -* `Selectors_full `_ -* `Generators_full `_ -* `Psiref_CAS `_ -* `MRCC_Utils `_ - -Documentation -============= -.. Do not edit this section It was auto-generated -.. by the `update_README.py` script. - - -`mrcc `_ - Undocumented - - -`mrcc_noiter `_ - Undocumented - - -`n_it_mrcc_max `_ - Maximum number of MRCC iterations - - -`print_cas_coefs `_ - Undocumented - - -`run `_ - Undocumented - - -`run_pt2 `_ - Undocumented - - -`thresh_mrcc `_ - Threshold on the convergence of the MRCC energy - diff --git a/plugins/MRCC_CASSD/mrcc_cassd.irp.f b/plugins/MRCC_CASSD/mrcc_cassd.irp.f deleted file mode 100644 index 4fef815d..00000000 --- a/plugins/MRCC_CASSD/mrcc_cassd.irp.f +++ /dev/null @@ -1,120 +0,0 @@ -program mrcc - implicit none - double precision, allocatable :: energy(:) - allocate (energy(N_states)) - - read_wf = .True. - SOFT_TOUCH read_wf - call print_cas_coefs - call set_generators_bitmasks_as_holes_and_particles - call run(N_states,energy) - if(do_pt2_end)then - call run_pt2(N_states,energy) - endif - deallocate(energy) -end - -subroutine run(N_st,energy) - implicit none - - integer, intent(in) :: N_st - double precision, intent(out) :: energy(N_st) - - integer :: i - - double precision :: E_new, E_old, delta_e - integer :: iteration - double precision :: E_past(4), lambda - E_new = 0.d0 - delta_E = 1.d0 - iteration = 0 - lambda = 1.d0 - do while (delta_E > thresh_mrcc) - iteration += 1 - print *, '===========================' - print *, 'MRCC Iteration', iteration - print *, '===========================' - print *, '' - E_old = sum(ci_energy_dressed(1:N_st)) - call write_double(6,ci_energy_dressed(1),"MRCC energy") - call diagonalize_ci_dressed(lambda) - E_new = sum(ci_energy_dressed(1:N_st)) - delta_E = dabs(E_new - E_old) - call save_wavefunction - call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) - if (iteration > n_it_mrcc_max) then - exit - endif - enddo - call write_double(6,ci_energy_dressed(1),"Final MRCC energy") - energy(1:N_st) = ci_energy_dressed(1:N_st) - -end - - -subroutine run_pt2(N_st,energy) - implicit none - integer :: i,j,k - double precision, allocatable :: pt2(:), norm_pert(:), H_pert_diag(:) - integer, intent(in) :: N_st - double precision, intent(in) :: energy(N_st) - allocate (pt2(N_st), norm_pert(N_st),H_pert_diag(N_st)) - pt2 = 0.d0 - - print*,'Last iteration only to compute the PT2' - threshold_selectors = 1.d0 - threshold_generators = 0.999d0 - - N_det_generators = lambda_mrcc_pt2(0) + N_det_cas - do i=1,N_det_cas - do k=1,N_int - psi_det_generators(k,1,i) = psi_ref(k,1,i) - psi_det_generators(k,2,i) = psi_ref(k,2,i) - enddo - do k=1,N_st - psi_coef_generators(i,k) = psi_ref_coef(i,k) - enddo - enddo - do i=N_det_cas+1,N_det_generators - j = lambda_mrcc_pt2(i) - do k=1,N_int - psi_det_generators(k,1,i) = psi_non_ref(k,1,j) - psi_det_generators(k,2,i) = psi_non_ref(k,2,j) - enddo - do k=1,N_st - psi_coef_generators(i,k) = psi_non_ref_coef(j,k) - enddo - enddo - SOFT_TOUCH N_det_generators psi_det_generators psi_coef_generators ci_eigenvectors_dressed ci_eigenvectors_s2_dressed ci_electronic_energy_dressed - - - call H_apply_mrcc_PT2(pt2, norm_pert, H_pert_diag, N_st) - print *, 'Final step' - print *, 'N_det = ', N_det - print *, 'N_states = ', N_states - print *, 'PT2 = ', pt2 - print *, 'E = ', energy - print *, 'E+PT2 = ', energy+pt2 - print *, '-----' - - - call ezfio_set_full_ci_energy_pt2(energy+pt2) - deallocate(pt2,norm_pert) - -end - - -subroutine print_cas_coefs - implicit none - - integer :: i,j - print *, 'CAS' - print *, '===' - do i=1,N_det_cas - print *, psi_cas_coef(i,:) - call debug_det(psi_cas(1,1,i),N_int) - enddo - call write_double(6,ci_energy(1),"Initial CI energy") - -end - diff --git a/plugins/MRCC_CASSD/mrcc_noiter.irp.f b/plugins/MRCC_CASSD/mrcc_noiter.irp.f deleted file mode 100644 index 8d95cea9..00000000 --- a/plugins/MRCC_CASSD/mrcc_noiter.irp.f +++ /dev/null @@ -1,91 +0,0 @@ -program mrcc_noiter - implicit none - double precision, allocatable :: energy(:) - allocate (energy(N_states)) - read_wf = .True. - threshold_generators = .9999d0 - SOFT_TOUCH read_wf threshold_generators - call print_cas_coefs - call set_generators_bitmasks_as_holes_and_particles - call run(N_states,energy) - if(do_pt2_end)then - call run_pt2(N_states,energy) - endif - deallocate(energy) -end - -subroutine run(N_st,energy) - implicit none - - integer, intent(in) :: N_st - double precision, intent(out) :: energy(N_st) - integer :: i,j - do j=1,N_states_diag - do i=1,N_det - psi_coef(i,j) = CI_eigenvectors_dressed(i,j) - enddo - enddo - SOFT_TOUCH psi_coef ci_energy_dressed - call write_double(6,ci_energy_dressed(1),"Final MRCC energy") - call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) - call save_wavefunction - energy(:) = ci_energy_dressed(:) -end - - -subroutine run_pt2(N_st,energy) - implicit none - integer :: i,j,k - double precision, allocatable :: pt2(:), norm_pert(:), H_pert_diag(:) - integer, intent(in) :: N_st - double precision, intent(in) :: energy(N_st) - allocate (pt2(N_st), norm_pert(N_st),H_pert_diag(N_st)) - pt2 = 0.d0 - - print*,'Last iteration only to compute the PT2' - threshold_selectors = 1.d0 - threshold_generators = 0.999d0 - - N_det_generators = lambda_mrcc_pt2(0) - do i=1,N_det_generators - j = lambda_mrcc_pt2(i) - do k=1,N_int - psi_det_generators(k,1,i) = psi_non_ref(k,1,j) - psi_det_generators(k,2,i) = psi_non_ref(k,2,j) - enddo - do k=1,N_st - psi_coef_generators(i,k) = psi_non_ref_coef(j,k) - enddo - enddo - SOFT_TOUCH N_det_generators psi_det_generators psi_coef_generators ci_eigenvectors_dressed ci_eigenvectors_s2_dressed ci_electronic_energy_dressed - - - call H_apply_mrcc_PT2(pt2, norm_pert, H_pert_diag, N_st) - print *, 'Final step' - print *, 'N_det = ', N_det - print *, 'N_states = ', N_states - print *, 'PT2 = ', pt2 - print *, 'E = ', energy - print *, 'E+PT2 = ', energy+pt2 - print *, '-----' - - call ezfio_set_full_ci_energy_pt2(energy+pt2) - deallocate(pt2,norm_pert) - -end - - -subroutine print_cas_coefs - implicit none - - integer :: i,j - print *, 'CAS' - print *, '===' - do i=1,N_det_cas - print *, psi_cas_coef(i,:) - call debug_det(psi_cas(1,1,i),N_int) - enddo - call write_double(6,ci_energy(1),"Initial CI energy") - -end - diff --git a/plugins/MRCC_CASSD/tree_dependency.png b/plugins/MRCC_CASSD/tree_dependency.png deleted file mode 100644 index e73ff165..00000000 Binary files a/plugins/MRCC_CASSD/tree_dependency.png and /dev/null differ diff --git a/plugins/QmcChem/dressed_dmc.irp.f b/plugins/QmcChem/dressed_dmc.irp.f index 1437ed31..803e55dc 100644 --- a/plugins/QmcChem/dressed_dmc.irp.f +++ b/plugins/QmcChem/dressed_dmc.irp.f @@ -57,7 +57,7 @@ program dressed_dmc enddo - call davidson_diag_hjj(psi_det,psi_coef,H_jj,energies,size(psi_coef,1),N_det,N_states,N_states_diag,,N_int,6) + call davidson_diag_hjj(psi_det,psi_coef,H_jj,energies,size(psi_coef,1),N_det,N_states,N_states_diag,N_int,6) call save_wavefunction call write_spindeterminants diff --git a/plugins/Selectors_full/zmq.irp.f b/plugins/Selectors_full/zmq.irp.f index dfa94884..f3dea8f5 100644 --- a/plugins/Selectors_full/zmq.irp.f +++ b/plugins/Selectors_full/zmq.irp.f @@ -114,7 +114,7 @@ subroutine zmq_get_psi(zmq_to_qp_run_socket, worker_id, energy, size_energy) if (N_det_selectors_read > 0) then N_det_selectors = N_det_selectors_read endif - SOFT_TOUCH psi_det psi_coef N_det_selectors N_det_generators + SOFT_TOUCH psi_det psi_coef N_det_selectors N_det_generators psi_coef_generators psi_det_generators end diff --git a/plugins/mrcepa0/EZFIO.cfg b/plugins/mrcepa0/EZFIO.cfg index 7580f028..d792390d 100644 --- a/plugins/mrcepa0/EZFIO.cfg +++ b/plugins/mrcepa0/EZFIO.cfg @@ -3,3 +3,31 @@ type: Positive_int doc: lambda type interface: ezfio,provider,ocaml default: 0 + +[energy] +type: double precision +doc: Calculated energy +interface: ezfio + +[energy_pt2] +type: double precision +doc: Calculated energy with PT2 contribution +interface: ezfio + +[energy] +type: double precision +doc: Calculated energy +interface: ezfio + +[thresh_dressed_ci] +type: Threshold +doc: Threshold on the convergence of the dressed CI energy +interface: ezfio,provider,ocaml +default: 1.e-4 + +[n_it_max_dressed_ci] +type: Strictly_positive_int +doc: Maximum number of dressed CI iterations +interface: ezfio,provider,ocaml +default: 10 + diff --git a/plugins/mrcepa0/mrcepa0_general.irp.f b/plugins/mrcepa0/mrcepa0_general.irp.f index b82bc613..1e7ad68d 100644 --- a/plugins/mrcepa0/mrcepa0_general.irp.f +++ b/plugins/mrcepa0/mrcepa0_general.irp.f @@ -17,8 +17,8 @@ subroutine run(N_st,energy) - thresh_mrcc = 1d-7 - n_it_mrcc_max = 10 + thresh_mrcc = thresh_dressed_ci + n_it_mrcc_max = n_it_max_dressed_ci if(n_it_mrcc_max == 1) then do j=1,N_states_diag @@ -48,8 +48,8 @@ subroutine run(N_st,energy) E_new = sum(ci_energy_dressed) delta_E = dabs(E_new - E_old) call save_wavefunction - call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) - if (iteration > n_it_mrcc_max) then + call ezfio_set_mrcepa0_energy(ci_energy_dressed(1)) + if (iteration >= n_it_mrcc_max) then exit endif enddo @@ -184,7 +184,7 @@ subroutine run_pt2_old(N_st,energy) print *, '-----' -! call ezfio_set_full_ci_energy_pt2(energy+pt2) + call ezfio_set_mrcepa0_energy_pt2(energy(1)+pt2(1)) end @@ -238,5 +238,7 @@ subroutine run_pt2(N_st,energy) print *, 'E+PT2 = ', energy+pt2 print *, '-----' + call ezfio_set_mrcepa0_energy_pt2(energy(1)+pt2(1)) + end diff --git a/src/Davidson/diagonalize_CI_SC2.irp.f b/src/Davidson/diagonalize_CI_SC2.irp.f deleted file mode 100644 index 498792d9..00000000 --- a/src/Davidson/diagonalize_CI_SC2.irp.f +++ /dev/null @@ -1,62 +0,0 @@ -BEGIN_PROVIDER [ double precision, CI_SC2_energy, (N_states_diag) ] - implicit none - BEGIN_DOC - ! N_states_diag lowest eigenvalues of the CI matrix - END_DOC - - integer :: j - character*(8) :: st - call write_time(output_determinants) - do j=1,N_states_diag - CI_SC2_energy(j) = CI_SC2_electronic_energy(j) + nuclear_repulsion - write(st,'(I4)') j - call write_double(output_determinants,CI_SC2_energy(j),'Energy of state '//trim(st)) - enddo - -END_PROVIDER - - BEGIN_PROVIDER [ double precision, threshold_convergence_SC2] - implicit none - BEGIN_DOC - ! convergence of the correlation energy of SC2 iterations - END_DOC - threshold_convergence_SC2 = 1.d-10 - - END_PROVIDER - - BEGIN_PROVIDER [ double precision, CI_SC2_electronic_energy, (N_states_diag) ] -&BEGIN_PROVIDER [ double precision, CI_SC2_eigenvectors, (N_det,N_states_diag) ] -&BEGIN_PROVIDER [ double precision, Diag_H_elements_SC2, (N_det) ] - implicit none - BEGIN_DOC - ! Eigenvectors/values of the CI matrix - END_DOC - integer :: i,j - - do j=1,N_states_diag - do i=1,N_det - CI_SC2_eigenvectors(i,j) = psi_coef(i,j) - enddo - CI_SC2_electronic_energy(j) = CI_electronic_energy(j) - enddo - - call CISD_SC2(psi_det,CI_SC2_eigenvectors,CI_SC2_electronic_energy, & -! size(CI_SC2_eigenvectors,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) - diag_H_elements_SC2,size(CI_SC2_eigenvectors,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) -END_PROVIDER - -subroutine diagonalize_CI_SC2 - implicit none - BEGIN_DOC -! Replace the coefficients of the CI states_diag by the coefficients of the -! eigenstates of the CI matrix - END_DOC - integer :: i,j - do j=1,N_states_diag - do i=1,N_det - psi_coef(i,j) = CI_SC2_eigenvectors(i,j) - enddo - enddo - SOFT_TOUCH psi_coef CI_SC2_electronic_energy CI_SC2_energy CI_SC2_eigenvectors diag_h_elements_sc2 -! SOFT_TOUCH psi_coef CI_SC2_electronic_energy CI_SC2_energy CI_SC2_eigenvectors -end diff --git a/tests/bats/cassd.bats b/tests/bats/cassd.bats new file mode 100644 index 00000000..a21b58ac --- /dev/null +++ b/tests/bats/cassd.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +@test "CAS_SD H2O cc-pVDZ" { + test_exe cas_sd_selected || skip + INPUT=h2o.ezfio + qp_edit -c $INPUT + ezfio set_file $INPUT + ezfio set perturbation do_pt2_end False + ezfio set determinants n_det_max 1000 + qp_set_mo_class $INPUT -core "[1]" -inact "[2,5]" -act "[3,4,6,7]" -virt "[8-24]" + qp_run cas_sd_selected $INPUT + energy="$(ezfio get cas_sd energy)" + eq $energy -76.22213389282479 1.E-5 +} + diff --git a/tests/bats/common.bats.sh b/tests/bats/common.bats.sh new file mode 100644 index 00000000..2aaff591 --- /dev/null +++ b/tests/bats/common.bats.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bats + +# floating point number comparison +# Compare two numbers ($1, $2) with a given precision ($3) +# If the numbers are not equal, the exit code is 1 else it is 0 +# So we strip the "-", is the abs value of the poor +function eq() { + declare -a diff + diff=($(awk -v d1=$1 -v d2=$2 -v n1=${1#-} -v n2=${2#-} -v p=$3 'BEGIN{ if ((n1-n2)^2 < p^2) print 0; print 1 " " (d1-d2) " " d1 " " d2 }')) + if [[ "${diff[0]}" == "0" ]] + then + return 0 + else + echo "Test : " ${BATS_TEST_DESCRIPTION} + echo "Error : " ${diff[1]} + echo "Reference : " ${diff[3]} + echo "Computed : " ${diff[2]} + exit 1 + fi +} + + +# ___ +# | ._ o _|_ +# _|_ | | | |_ +# +source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh +TEST_DIR=${QP_ROOT}/tests/work/ + +mkdir -p "${TEST_DIR}" + +cd "${TEST_DIR}" || exit 1 + +function test_exe() { + l_EXE=$(awk "/^$1 / { print \$2 }" < "${QP_ROOT}"/data/executables) + l_EXE=$(echo $l_EXE | sed "s|\$QP_ROOT|$QP_ROOT|") + if [[ -x "$l_EXE" ]] + then + return 0 + else + return 127 + fi +} + diff --git a/tests/bats/convert.bats b/tests/bats/convert.bats new file mode 100644 index 00000000..a1fbd7ce --- /dev/null +++ b/tests/bats/convert.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +#=== Convert +@test "gamess convert HBO.out" { + cp ${QP_ROOT}/tests/input/HBO.out . + qp_convert_output_to_ezfio.py HBO.out + qp_edit -c HBO.out.ezfio + ezfio set_file HBO.out.ezfio + qp_run SCF HBO.out.ezfio + # Check energy + energy="$(ezfio get hartree_fock energy)" + eq $energy -100.0185822590964 1.e-10 +} + +@test "g09 convert H2O.log" { + cp ${QP_ROOT}/tests/input/h2o.log . + qp_convert_output_to_ezfio.py h2o.log + qp_edit -c h2o.log.ezfio + ezfio set_file h2o.log.ezfio + qp_run SCF h2o.log.ezfio + # Check energy + energy="$(ezfio get hartree_fock energy)" + eq $energy -76.0270218704265 1E-10 +} + diff --git a/tests/bats/fci.bats b/tests/bats/fci.bats new file mode 100644 index 00000000..174c8f61 --- /dev/null +++ b/tests/bats/fci.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +function run_FCI() { + thresh=5.e-5 + test_exe full_ci || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set perturbation do_pt2_end True + ezfio set determinants n_det_max $2 + ezfio set davidson threshold_davidson 1.e-10 + + qp_run full_ci $1 + energy="$(ezfio get full_ci energy)" + eq $energy $3 $thresh + energy_pt2="$(ezfio get full_ci energy_pt2)" + eq $energy_pt2 $4 $thresh +} + +function run_FCI_ZMQ() { + thresh=5.e-5 + test_exe full_ci || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set perturbation do_pt2_end True + ezfio set determinants n_det_max $2 + ezfio set davidson threshold_davidson 1.e-10 + + qp_run fci_zmq $1 + energy="$(ezfio get full_ci energy)" + eq $energy $3 $thresh + energy_pt2="$(ezfio get full_ci energy_pt2)" + eq $energy_pt2 $4 $thresh +} + + + +#=== H2O + +@test "qp_set_mo_class H2O cc-pVDZ" { + qp_set_mo_class h2o.ezfio -core "[1]" -act "[2-12]" -del "[13-24]" +} +@test "FCI H2O cc-pVDZ" { + run_FCI h2o.ezfio 2000 -0.761255633582109E+02 -0.761258377850042E+02 +} + +@test "FCI-ZMQ H2O cc-pVDZ" { + run_FCI_ZMQ h2o.ezfio 2000 -0.761255633582109E+02 -0.761258377850042E+02 +} + + diff --git a/tests/bats/foboci.bats b/tests/bats/foboci.bats new file mode 100644 index 00000000..98255969 --- /dev/null +++ b/tests/bats/foboci.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +function run_all_1h_1p() { + thresh=1.e-6 + test_exe all_1h_1p || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set determinants n_det_max $2 + ezfio set perturbation pt2_max $3 + ezfio set davidson threshold_davidson 1.e-10 + + qp_run all_1h_1p $1 | tee $1.F1h1p.out + energy="$(ezfio get all_singles energy)" + eq $energy $4 $thresh +} + + +#=== DHNO + +@test "all_1h_1p DHNO chipman-dzp" { + qp_set_mo_class -inact "[1-8]" -act "[9]" -virt "[10-64]" dhno.ezfio + run_all_1h_1p dhno.ezfio 10000 0.0000000001 -130.4466283766202 +} + + diff --git a/tests/bats/hf.bats b/tests/bats/hf.bats new file mode 100644 index 00000000..e280c986 --- /dev/null +++ b/tests/bats/hf.bats @@ -0,0 +1,52 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +function run_init() { + cp "${QP_ROOT}/tests/input/$1" . + qp_create_ezfio_from_xyz $1 -o $3 $2 + qp_edit -c $3 +} + + +function run_HF() { + thresh=1.e-7 + test_exe SCF || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set hartree_fock thresh_scf 1.e-11 + qp_run SCF $1 + energy="$(ezfio get hartree_fock energy)" + eq $energy $2 $thresh +} + + + +#=== DHNO +@test "init DHNO chipman-dzp" { + run_init dhno.xyz "-b chipman-dzp -m 2" dhno.ezfio +} + +@test "SCF DHNO chipman-dzp" { + run_HF dhno.ezfio -130.4278777822 +} + +#=== HBO +@test "init HBO STO-3G" { + run_init HBO.xyz "-b STO-3G" hbo.ezfio +} + +@test "SCF HBO STO-3G" { + run_HF hbo.ezfio -98.8251985678084 +} + + +#=== H2O +@test "init H2O cc-pVDZ" { + run_init h2o.xyz "-b cc-pvdz" h2o.ezfio +} + +@test "SCF H2O cc-pVDZ" { + run_HF h2o.ezfio -0.760270218692179E+02 +} + diff --git a/tests/bats/mrcepa0.bats b/tests/bats/mrcepa0.bats new file mode 100644 index 00000000..8b56c606 --- /dev/null +++ b/tests/bats/mrcepa0.bats @@ -0,0 +1,70 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +#=== H2O +@test "MRCC-lambda H2O cc-pVDZ" { + INPUT=h2o.ezfio + EXE=mrcc + test_exe $EXE || skip + qp_edit -c $INPUT + ezfio set_file $INPUT + ezfio set determinants threshold_generators 1. + ezfio set determinants threshold_selectors 1. + ezfio set determinants read_wf True + ezfio set mrcepa0 lambda_type 1 + ezfio set mrcepa0 n_it_max_dressed_ci 3 + qp_run $EXE $INPUT + energy="$(ezfio get mrcepa0 energy)" + eq $energy -76.22903276183061 1.e-4 +} + +@test "MRCC H2O cc-pVDZ" { + INPUT=h2o.ezfio + EXE=mrcc + test_exe $EXE || skip + qp_edit -c $INPUT + ezfio set_file $INPUT + ezfio set determinants threshold_generators 1. + ezfio set determinants threshold_selectors 1. + ezfio set determinants read_wf True + ezfio set determinants read_wf True + ezfio set mrcepa0 lambda_type 0 + ezfio set mrcepa0 n_it_max_dressed_ci 3 + qp_run $EXE $INPUT + energy="$(ezfio get mrcepa0 energy)" + eq $energy -76.22899302846875 1.e-4 +} + +@test "MRSC2 H2O cc-pVDZ" { + INPUT=h2o.ezfio + EXE=mrsc2 + test_exe $EXE || skip + qp_edit -c $INPUT + ezfio set_file $INPUT + ezfio set determinants threshold_generators 1. + ezfio set determinants threshold_selectors 1. + ezfio set determinants read_wf True + ezfio set mrcepa0 lambda_type 0 + ezfio set mrcepa0 n_it_max_dressed_ci 3 + qp_run $EXE $INPUT + energy="$(ezfio get mrcepa0 energy)" + eq $energy -76.22647345292708 1.e-4 +} + +@test "MRCEPA0 H2O cc-pVDZ" { + INPUT=h2o.ezfio + EXE=mrcepa0 + test_exe $EXE || skip + qp_edit -c $INPUT + ezfio set_file $INPUT + ezfio set determinants threshold_generators 1. + ezfio set determinants threshold_selectors 1. + ezfio set determinants read_wf True + ezfio set mrcepa0 lambda_type 0 + ezfio set mrcepa0 n_it_max_dressed_ci 3 + qp_run $EXE $INPUT + energy="$(ezfio get mrcepa0 energy)" + eq $energy -76.23199784430074 1.e-4 +} + diff --git a/tests/bats/pseudo.bats b/tests/bats/pseudo.bats new file mode 100644 index 00000000..8cccf229 --- /dev/null +++ b/tests/bats/pseudo.bats @@ -0,0 +1,53 @@ +#!/usr/bin/env bats + +source $QP_ROOT/tests/bats/common.bats.sh + +function run_init() { + cp "${QP_ROOT}/tests/input/$1" . + qp_create_ezfio_from_xyz $1 -o $3 $2 + qp_edit -c $3 +} + + +function run_HF() { + thresh=1.e-7 + test_exe SCF || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set hartree_fock thresh_scf 1.e-11 + qp_run SCF $1 + energy="$(ezfio get hartree_fock energy)" + eq $energy $2 $thresh +} + + +function run_FCI_ZMQ() { + thresh=5.e-5 + test_exe full_ci || skip + qp_edit -c $1 + ezfio set_file $1 + ezfio set perturbation do_pt2_end True + ezfio set determinants n_det_max $2 + ezfio set davidson threshold_davidson 1.e-10 + + qp_run fci_zmq $1 + energy="$(ezfio get full_ci energy)" + eq $energy $3 $thresh + energy_pt2="$(ezfio get full_ci energy_pt2)" + eq $energy_pt2 $4 $thresh +} + +#=== H2O Pseudo +@test "init H2O VDZ pseudo" { + run_init h2o.xyz "-p bfd -b vdz-bfd" h2o_pseudo.ezfio +} + +@test "SCF H2O VDZ pseudo" { + run_HF h2o_pseudo.ezfio -16.9483703905461 +} + +@test "FCI H2O VDZ pseudo" { + qp_set_mo_class h2o_pseudo.ezfio -core "[1]" -act "[2-12]" -del "[13-23]" + run_FCI_ZMQ h2o_pseudo.ezfio 2000 -0.170399597228904E+02 -0.170400168816800E+02 +} + diff --git a/tests/bats/qp.bats b/tests/bats/qp.bats deleted file mode 100644 index aa283916..00000000 --- a/tests/bats/qp.bats +++ /dev/null @@ -1,205 +0,0 @@ -#!/usr/bin/env bats - -# -# |\/| o _ _ -# | | | _> (_ -# -# floating point number comparison -# Compare two numbers ($1, $2) with a given precision ($3) -# If the numbers are not equal, the exit code is 1 else it is 0 -# So we strip the "-", is the abs value of the poor -function eq() { - declare -a diff - diff=($(awk -v d1=$1 -v d2=$2 -v n1=${1#-} -v n2=${2#-} -v p=$3 'BEGIN{ if ((n1-n2)^2 < p^2) print 0; print 1 " " (d1-d2) " " d1 " " d2 }')) - if [[ "${diff[0]}" == "0" ]] - then - return 0 - else - echo "Test : " ${BATS_TEST_DESCRIPTION} - echo "Error : " ${diff[1]} - echo "Reference : " ${diff[3]} - echo "Computed : " ${diff[2]} - exit 1 - fi -} - - -# ___ -# | ._ o _|_ -# _|_ | | | |_ -# -source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh -TEST_DIR=${QP_ROOT}/tests/work/ - -mkdir -p "${TEST_DIR}" - -cd "${TEST_DIR}" || exit 1 - -function run_init() { - cp "${QP_ROOT}/tests/input/$1" . - qp_create_ezfio_from_xyz $1 -o $3 $2 - qp_edit -c $3 -} - -function test_exe() { - EXE=$(awk "/^$1 / { print \$2 }" < "${QP_ROOT}"/data/executables) - EXE=$(echo $EXE | sed "s|\$QP_ROOT|$QP_ROOT|") - if [[ -x "$EXE" ]] - then - return 0 - else - return 127 - fi -} - -function run_HF() { - thresh=1.e-7 - test_exe SCF || skip - ezfio set_file $1 - ezfio set hartree_fock thresh_scf 1.e-11 - qp_run SCF $1 - energy="$(ezfio get hartree_fock energy)" - eq $energy $2 $thresh -} - -function run_FCI() { - thresh=5.e-5 - test_exe full_ci || skip - ezfio set_file $1 - ezfio set perturbation do_pt2_end True - ezfio set determinants n_det_max $2 - ezfio set davidson threshold_davidson 1.e-10 - - qp_run full_ci $1 - energy="$(ezfio get full_ci energy)" - eq $energy $3 $thresh - energy_pt2="$(ezfio get full_ci energy_pt2)" - eq $energy_pt2 $4 $thresh -} - -function run_all_1h_1p() { - thresh=1.e-6 - test_exe all_1h_1p || skip - ezfio set_file $1 - ezfio set determinants n_det_max $2 - ezfio set perturbation pt2_max $3 - ezfio set davidson threshold_davidson 1.e-10 - - qp_run all_1h_1p $1 | tee $1.F1h1p.out - energy="$(ezfio get all_singles energy)" - eq $energy $4 $thresh -} - -# ___ -# | _ _ _|_ -# | (/_ _> |_ -# - - -#=== DHNO -@test "init DHNO chipman-dzp" { - run_init dhno.xyz "-b chipman-dzp -m 2" dhno.ezfio -} - -@test "SCF DHNO chipman-dzp" { - run_HF dhno.ezfio -130.4278777822 -} - -@test "all_1h_1p DHNO chipman-dzp" { - qp_set_mo_class -inact "[1-8]" -act "[9]" -virt "[10-64]" dhno.ezfio - run_all_1h_1p dhno.ezfio 10000 0.0000000001 -130.4466283766202 -} - -#=== HBO -@test "init HBO STO-3G" { - run_init HBO.xyz "-b STO-3G" hbo.ezfio -} - -@test "SCF HBO STO-3G" { - run_HF hbo.ezfio -98.8251985678084 -} - - -#=== H2O -@test "init H2O cc-pVDZ" { - run_init h2o.xyz "-b cc-pvdz" h2o.ezfio -} - -@test "SCF H2O cc-pVDZ" { - run_HF h2o.ezfio -0.760270218692179E+02 -} - -@test "FCI H2O cc-pVDZ" { - qp_set_mo_class h2o.ezfio -core "[1]" -act "[2-12]" -del "[13-24]" - run_FCI h2o.ezfio 2000 -0.761255633582109E+02 -0.761258377850042E+02 -} - -@test "CAS_SD H2O cc-pVDZ" { - test_exe cas_sd_selected || skip - INPUT=h2o.ezfio - ezfio set_file $INPUT - ezfio set perturbation do_pt2_end False - ezfio set determinants n_det_max 1000 - qp_set_mo_class $INPUT -core "[1]" -inact "[2,5]" -act "[3,4,6,7]" -virt "[8-24]" - qp_run cas_sd_selected $INPUT - energy="$(ezfio get cas_sd energy)" - eq $energy -0.762219854008117E+02 1.E-5 -} - -@test "MRCC H2O cc-pVDZ" { - test_exe mrcc_cassd || skip - INPUT=h2o.ezfio - ezfio set_file $INPUT - ezfio set determinants threshold_generators 1. - ezfio set determinants threshold_selectors 1. - ezfio set determinants read_wf True - qp_run mrcc_cassd $INPUT - energy="$(ezfio get mrcc_cassd energy)" - eq $energy -76.2288648023833 1.e-4 - -} - - -#=== H2O Pseudo -@test "init H2O VDZ pseudo" { - run_init h2o.xyz "-p bfd -b vdz-bfd" h2o_pseudo.ezfio -} - -@test "SCF H2O VDZ pseudo" { - run_HF h2o_pseudo.ezfio -16.9483703905461 -} - -@test "FCI H2O VDZ pseudo" { - qp_set_mo_class h2o_pseudo.ezfio -core "[1]" -act "[2-12]" -del "[13-23]" - run_FCI h2o_pseudo.ezfio 2000 -0.170399597228904E+02 -0.170400168816800E+02 -} - -#=== Convert -@test "gamess convert HBO.out" { - cp ${QP_ROOT}/tests/input/HBO.out . - qp_convert_output_to_ezfio.py HBO.out - ezfio set_file HBO.out.ezfio - qp_run SCF HBO.out.ezfio - # Check energy - energy="$(ezfio get hartree_fock energy)" - eq $energy -100.0185822590964 1.e-10 -} - -@test "g09 convert H2O.log" { - cp ${QP_ROOT}/tests/input/h2o.log . - qp_convert_output_to_ezfio.py h2o.log - ezfio set_file h2o.log.ezfio - qp_run SCF h2o.log.ezfio - # Check energy - energy="$(ezfio get hartree_fock energy)" - eq $energy -76.0270218704265 1E-10 -} - - -# TODO N_int = 1,2,3,4,5 -# TODO mod(64) MOs -# TODO All G2 SCF energies -# TODO Long and short tests -# TODO MP2 -# TODO CISD_selected - diff --git a/tests/bats_to_sh.py b/tests/bats_to_sh.py index 2c6b4a05..8feb9272 100755 --- a/tests/bats_to_sh.py +++ b/tests/bats_to_sh.py @@ -1,6 +1,8 @@ #!/usr/bin/env python -with open('bats/qp.bats','r') as f: +import sys + +with open(sys.argv[1],'r') as f: raw_data = f.read() output = [] diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 2436c60c..4664ce82 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -1,18 +1,39 @@ #!/bin/bash +LIST=" + +convert.bats +hf.bats +foboci.bats +pseudo.bats +fci.bats +cassd.bats +mrcepa0.bats + +" + + export QP_PREFIX="timeout -s 9 300" export QP_TASK_DEBUG=1 -BATS_FILE=bats/qp.bats - rm -rf work output -if [[ "$1" == "-v" ]] -then - echo "Verbose mode" - ./bats_to_sh.py $BATS_FILE | bash -else - bats $BATS_FILE -fi + +for BATS_FILE in $LIST +do + echo + echo "-~-~-~-~-~-~" + echo + echo "Running tests for ${BATS_FILE%.bats}" + echo + BATS_FILE=bats/$BATS_FILE + if [[ "$1" == "-v" ]] + then + echo "Verbose mode" + ./bats_to_sh.py $BATS_FILE | bash + else + bats $BATS_FILE + fi +done