10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-12-23 04:43:50 +01:00

Fixed tests

This commit is contained in:
Anthony Scemama 2016-10-07 19:21:04 +02:00
parent a10c1f144b
commit 2b5c93a58a
26 changed files with 418 additions and 634 deletions

View File

@ -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,parameter :: size_max = 3072
integer, intent(in) :: Ndet_generators 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) 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) 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 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) 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) integer(bit_kind), intent(in) :: psi_det_generators_input(N_int,2,Ndet_generators)

View File

@ -1 +1 @@
Perturbation Selectors_no_sorted Hartree_Fock Davidson Perturbation Selectors_no_sorted Hartree_Fock Davidson CISD

View File

@ -15,11 +15,10 @@ subroutine routine
call diagonalize_CI call diagonalize_CI
call test_hcc call test_hcc
call test_mulliken 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)) allocate(H_matrix(N_det,N_det))
call SC2_1h1p_full(psi_det,psi_coef,energies, & stop 'SC2_1h1p_full is not in the git!'
H_matrix,size(psi_coef,1),N_det,N_states_diag,N_int,threshold_convergence_SC2) ! 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) deallocate(H_matrix)
integer :: i,j integer :: i,j
double precision :: accu,coef_hf double precision :: accu,coef_hf

View File

@ -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

View File

@ -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

View File

@ -1 +0,0 @@
Perturbation Selectors_full Generators_full Psiref_CAS MRCC_Utils

View File

@ -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 <http://github.com/LCPQ/quantum_package/tree/master/src/Perturbation>`_
* `Selectors_full <http://github.com/LCPQ/quantum_package/tree/master/src/Selectors_full>`_
* `Generators_full <http://github.com/LCPQ/quantum_package/tree/master/src/Generators_full>`_
* `Psiref_CAS <http://github.com/LCPQ/quantum_package/tree/master/src/Psiref_CAS>`_
* `MRCC_Utils <http://github.com/LCPQ/quantum_package/tree/master/src/MRCC_Utils>`_
Documentation
=============
.. Do not edit this section. It was auto-generated from the
.. by the `update_README.py` script.
`mrcc <http://github.com/LCPQ/quantum_package/tree/master/src/MRCC_CASSD/mrcc_cassd.irp.f#L1>`_
Undocumented
`print_cas_coefs <http://github.com/LCPQ/quantum_package/tree/master/src/MRCC_CASSD/mrcc_cassd.irp.f#L11>`_
Undocumented
Needed Modules
==============
.. Do not edit this section It was auto-generated
.. by the `update_README.py` script.
.. image:: tree_dependency.png
* `Perturbation <http://github.com/LCPQ/quantum_package/tree/master/plugins/Perturbation>`_
* `Selectors_full <http://github.com/LCPQ/quantum_package/tree/master/plugins/Selectors_full>`_
* `Generators_full <http://github.com/LCPQ/quantum_package/tree/master/plugins/Generators_full>`_
* `Psiref_CAS <http://github.com/LCPQ/quantum_package/tree/master/plugins/Psiref_CAS>`_
* `MRCC_Utils <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_Utils>`_
Documentation
=============
.. Do not edit this section It was auto-generated
.. by the `update_README.py` script.
`mrcc <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/mrcc_cassd.irp.f#L1>`_
Undocumented
`mrcc_noiter <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/mrcc_noiter.irp.f#L1>`_
Undocumented
`n_it_mrcc_max <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/ezfio_interface.irp.f#L6>`_
Maximum number of MRCC iterations
`print_cas_coefs <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/mrcc_noiter.irp.f#L78>`_
Undocumented
`run <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/mrcc_noiter.irp.f#L17>`_
Undocumented
`run_pt2 <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/mrcc_noiter.irp.f#L36>`_
Undocumented
`thresh_mrcc <http://github.com/LCPQ/quantum_package/tree/master/plugins/MRCC_CASSD/ezfio_interface.irp.f#L25>`_
Threshold on the convergence of the MRCC energy

View File

@ -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

View File

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

View File

@ -57,7 +57,7 @@ program dressed_dmc
enddo 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 save_wavefunction
call write_spindeterminants call write_spindeterminants

View File

@ -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 if (N_det_selectors_read > 0) then
N_det_selectors = N_det_selectors_read N_det_selectors = N_det_selectors_read
endif 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 end

View File

@ -3,3 +3,31 @@ type: Positive_int
doc: lambda type doc: lambda type
interface: ezfio,provider,ocaml interface: ezfio,provider,ocaml
default: 0 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

View File

@ -17,8 +17,8 @@ subroutine run(N_st,energy)
thresh_mrcc = 1d-7 thresh_mrcc = thresh_dressed_ci
n_it_mrcc_max = 10 n_it_mrcc_max = n_it_max_dressed_ci
if(n_it_mrcc_max == 1) then if(n_it_mrcc_max == 1) then
do j=1,N_states_diag do j=1,N_states_diag
@ -48,8 +48,8 @@ subroutine run(N_st,energy)
E_new = sum(ci_energy_dressed) E_new = sum(ci_energy_dressed)
delta_E = dabs(E_new - E_old) delta_E = dabs(E_new - E_old)
call save_wavefunction call save_wavefunction
call ezfio_set_mrcc_cassd_energy(ci_energy_dressed(1)) call ezfio_set_mrcepa0_energy(ci_energy_dressed(1))
if (iteration > n_it_mrcc_max) then if (iteration >= n_it_mrcc_max) then
exit exit
endif endif
enddo enddo
@ -184,7 +184,7 @@ subroutine run_pt2_old(N_st,energy)
print *, '-----' print *, '-----'
! call ezfio_set_full_ci_energy_pt2(energy+pt2) call ezfio_set_mrcepa0_energy_pt2(energy(1)+pt2(1))
end end
@ -238,5 +238,7 @@ subroutine run_pt2(N_st,energy)
print *, 'E+PT2 = ', energy+pt2 print *, 'E+PT2 = ', energy+pt2
print *, '-----' print *, '-----'
call ezfio_set_mrcepa0_energy_pt2(energy(1)+pt2(1))
end end

View File

@ -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

17
tests/bats/cassd.bats Normal file
View File

@ -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
}

44
tests/bats/common.bats.sh Normal file
View File

@ -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
}

27
tests/bats/convert.bats Normal file
View File

@ -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
}

52
tests/bats/fci.bats Normal file
View File

@ -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
}

27
tests/bats/foboci.bats Normal file
View File

@ -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
}

52
tests/bats/hf.bats Normal file
View File

@ -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
}

70
tests/bats/mrcepa0.bats Normal file
View File

@ -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
}

53
tests/bats/pseudo.bats Normal file
View File

@ -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
}

View File

@ -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

View File

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/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() raw_data = f.read()
output = [] output = []

View File

@ -1,18 +1,39 @@
#!/bin/bash #!/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_PREFIX="timeout -s 9 300"
export QP_TASK_DEBUG=1 export QP_TASK_DEBUG=1
BATS_FILE=bats/qp.bats
rm -rf work output rm -rf work output
if [[ "$1" == "-v" ]]
then 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" echo "Verbose mode"
./bats_to_sh.py $BATS_FILE | bash ./bats_to_sh.py $BATS_FILE | bash
else else
bats $BATS_FILE bats $BATS_FILE
fi fi
done