10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-05-29 01:15:30 +02:00
quantum_package/tests/bats/qp.bats

206 lines
4.8 KiB
Plaintext
Raw Normal View History

2015-10-28 13:51:11 +01:00
#!/usr/bin/env bats
2016-01-15 10:59:21 +01:00
#
# |\/| o _ _
# | | | _> (_
#
2016-01-05 01:04:46 +01:00
# 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
2015-10-28 13:51:11 +01:00
# So we strip the "-", is the abs value of the poor
function eq() {
2016-01-05 01:04:46 +01:00
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]}
2016-01-26 00:26:27 +01:00
exit 1
2016-01-05 01:04:46 +01:00
fi
2015-10-28 13:51:11 +01:00
}
2016-01-15 10:59:21 +01:00
# ___
# | ._ o _|_
# _|_ | | | |_
#
2015-10-28 14:46:19 +01:00
source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh
2016-01-14 17:12:37 +01:00
TEST_DIR=${QP_ROOT}/tests/work/
2015-10-28 13:51:11 +01:00
2016-01-05 01:04:46 +01:00
mkdir -p "${TEST_DIR}"
cd "${TEST_DIR}" || exit 1
function run_init() {
2016-01-14 17:12:37 +01:00
cp "${QP_ROOT}/tests/input/$1" .
2016-01-05 01:04:46 +01:00
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
2015-10-28 13:51:11 +01:00
}
2016-01-05 01:04:46 +01:00
function run_HF() {
2016-03-31 10:59:46 +02:00
thresh=1.e-7
2016-01-05 01:04:46 +01:00
test_exe SCF || skip
ezfio set_file $1
2016-03-31 11:05:39 +02:00
ezfio set hartree_fock thresh_scf 1.e-11
2016-02-19 00:20:28 +01:00
qp_run SCF $1
2015-10-28 13:51:11 +01:00
energy="$(ezfio get hartree_fock energy)"
2016-01-05 01:04:46 +01:00
eq $energy $2 $thresh
2015-10-28 13:51:11 +01:00
}
2016-01-05 01:04:46 +01:00
function run_FCI() {
2016-02-19 00:20:28 +01:00
thresh=5.e-5
2016-01-05 01:04:46 +01:00
test_exe full_ci || skip
ezfio set_file $1
ezfio set perturbation do_pt2_end True
2016-01-05 01:52:44 +01:00
ezfio set determinants n_det_max $2
2016-09-26 20:34:16 +02:00
ezfio set davidson threshold_davidson 1.e-10
2015-10-28 13:51:11 +01:00
2016-02-19 00:20:28 +01:00
qp_run full_ci $1
2015-10-28 13:51:11 +01:00
energy="$(ezfio get full_ci energy)"
2016-01-05 01:52:44 +01:00
eq $energy $3 $thresh
2015-10-28 13:51:11 +01:00
energy_pt2="$(ezfio get full_ci energy_pt2)"
2016-01-05 01:52:44 +01:00
eq $energy_pt2 $4 $thresh
2016-01-05 01:04:46 +01:00
}
2016-02-16 12:34:04 +01:00
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
2016-09-26 20:34:16 +02:00
ezfio set davidson threshold_davidson 1.e-10
2016-02-16 12:34:04 +01:00
qp_run all_1h_1p $1 | tee $1.F1h1p.out
energy="$(ezfio get all_singles energy)"
eq $energy $4 $thresh
}
2016-01-15 10:59:21 +01:00
# ___
# | _ _ _|_
# | (/_ _> |_
#
2016-01-05 01:04:46 +01:00
2016-02-16 12:34:04 +01:00
#=== 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
}
2016-01-15 10:59:21 +01:00
#=== HBO
2016-01-05 01:04:46 +01:00
@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
}
2016-01-15 10:59:21 +01:00
#=== H2O
2016-01-05 01:04:46 +01:00
@test "init H2O cc-pVDZ" {
run_init h2o.xyz "-b cc-pvdz" h2o.ezfio
}
@test "SCF H2O cc-pVDZ" {
2016-02-04 23:33:40 +01:00
run_HF h2o.ezfio -0.760270218692179E+02
2015-10-28 13:51:11 +01:00
}
2016-01-05 01:04:46 +01:00
@test "FCI H2O cc-pVDZ" {
2016-02-19 00:20:28 +01:00
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
2016-01-05 01:04:46 +01:00
}
@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
2015-10-28 13:51:11 +01:00
ezfio set determinants n_det_max 1000
2016-02-19 00:20:28 +01:00
qp_set_mo_class $INPUT -core "[1]" -inact "[2,5]" -act "[3,4,6,7]" -virt "[8-24]"
qp_run cas_sd_selected $INPUT
2015-10-28 13:51:11 +01:00
energy="$(ezfio get cas_sd energy)"
2016-02-04 23:33:40 +01:00
eq $energy -0.762219854008117E+02 1.E-5
2015-10-28 13:51:11 +01:00
}
2016-01-05 01:04:46 +01:00
@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
2016-02-19 00:20:28 +01:00
qp_run mrcc_cassd $INPUT
2015-10-28 13:51:11 +01:00
energy="$(ezfio get mrcc_cassd energy)"
2016-05-10 23:26:38 +02:00
eq $energy -76.2288648023833 1.e-4
2016-02-04 12:43:24 +01:00
2016-01-05 01:04:46 +01:00
}
2016-01-15 10:59:21 +01:00
#=== H2O Pseudo
2016-01-05 01:04:46 +01:00
@test "init H2O VDZ pseudo" {
2016-01-25 23:38:07 +01:00
run_init h2o.xyz "-p bfd -b vdz-bfd" h2o_pseudo.ezfio
2016-01-05 01:04:46 +01:00
}
@test "SCF H2O VDZ pseudo" {
2016-05-10 23:26:38 +02:00
run_HF h2o_pseudo.ezfio -16.9483703905461
2016-01-05 01:04:46 +01:00
}
@test "FCI H2O VDZ pseudo" {
2016-02-19 00:20:28 +01:00
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
2015-10-28 13:51:11 +01:00
}
2016-01-15 10:59:21 +01:00
#=== Convert
2016-01-05 01:04:46 +01:00
@test "gamess convert HBO.out" {
2016-01-14 17:12:37 +01:00
cp ${QP_ROOT}/tests/input/HBO.out .
2015-10-28 13:51:11 +01:00
qp_convert_output_to_ezfio.py HBO.out
ezfio set_file HBO.out.ezfio
2016-02-19 00:20:28 +01:00
qp_run SCF HBO.out.ezfio
2016-01-05 01:04:46 +01:00
# Check energy
2015-10-28 13:51:11 +01:00
energy="$(ezfio get hartree_fock energy)"
2016-01-05 01:04:46 +01:00
eq $energy -100.0185822590964 1.e-10
2015-10-28 13:51:11 +01:00
}
2016-01-05 01:04:46 +01:00
@test "g09 convert H2O.log" {
2016-01-14 17:12:37 +01:00
cp ${QP_ROOT}/tests/input/h2o.log .
2016-01-05 01:04:46 +01:00
qp_convert_output_to_ezfio.py h2o.log
ezfio set_file h2o.log.ezfio
2016-02-19 00:20:28 +01:00
qp_run SCF h2o.log.ezfio
2016-01-05 01:04:46 +01:00
# Check energy
energy="$(ezfio get hartree_fock energy)"
eq $energy -76.0270218704265 1E-10
}
2016-01-05 01:10:24 +01:00
# TODO N_int = 1,2,3,4,5
# TODO mod(64) MOs
# TODO All G2 SCF energies
# TODO Long and short tests
2016-01-05 01:43:41 +01:00
# TODO MP2
# TODO CISD_selected
2016-01-05 01:10:24 +01:00