From 5dc7810bdec377939bf79f9e7ff3bcd869696730 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 30 Sep 2015 13:19:45 +0200 Subject: [PATCH 01/15] Fix ezfio path and ocaml version --- configure | 2 +- install/scripts/install_ocaml.sh | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/configure b/configure index fa207f6e..e3aad8ca 100755 --- a/configure +++ b/configure @@ -453,7 +453,7 @@ def create_ninja_and_rc(l_installed): 'export IRPF90={0}'.format(path_irpf90), 'export NINJA={0}'.format(path_ninja), 'export QP_PYTHON={0}'.format(":".join(l_python)), "", - 'export PYTHONPATH="${QP_EZFIO}":"${QP_PYTHON}":"${PYTHONPATH}"', + 'export PYTHONPATH="${QP_EZFIO}/Python":"${QP_PYTHON}":"${PYTHONPATH}"', 'export PATH="${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml:"${PATH}"', 'export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}"', 'export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}"', "", diff --git a/install/scripts/install_ocaml.sh b/install/scripts/install_ocaml.sh index 5c9bb89e..4ac295cd 100755 --- a/install/scripts/install_ocaml.sh +++ b/install/scripts/install_ocaml.sh @@ -7,9 +7,18 @@ cd - # Normal installation PACKAGES="core cryptokit ocamlfind sexplib" -declare -i i -i=$(gcc -dumpversion | cut -d '.' -f 2) -if [[ i -lt 6 ]] +# return 0 if program version is equal or greater than check version +check_version() +{ + local version=$1 check=$2 + local winner=$(echo -e "$version\n$check" | sed '/^$/d' | sort -nr | head -1) + [[ "$winner" = "$version" ]] && return 0 + return 1 +} + +i=$(gcc -dumpversion) + +if check_version i 4.6 then echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required." exit 1 From ebb3d391bdcc5292b91938561449f11e0111be33 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 30 Sep 2015 13:36:53 +0200 Subject: [PATCH 02/15] qp_install_module -> qp_module --- .travis.yml | 2 +- README.md | 16 ++++++++-------- scripts/compilation/qp_create_ninja.py | 2 +- .../{qp_install_module.py => qp_module.py} | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) rename scripts/module/{qp_install_module.py => qp_module.py} (95%) diff --git a/.travis.yml b/.travis.yml index 0e78a8c6..b763532c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ python: script: - ./configure --production ./config/gfortran.cfg - source ./quantum_package.rc - - qp_install_module.py install Full_CI Hartree_Fock + - qp_module.py install Full_CI Hartree_Fock - ninja - cd ocaml ; make ; cd - - cd testing_no_regression ; ./unit_test.py diff --git a/README.md b/README.md index 4b288d85..5cfcf184 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ For more information, you can visit the [wiki of the project](http://github.com/ * Python >= 2.6 * GNU make * Bash +* Blast/Lapack +* unzip ## Standard installation @@ -51,19 +53,17 @@ This file contains all the environment variables needed by the quantum package b ### Optional) Add some new module - Usage: qp_install_module.py list (--installed|--avalaible-local|--avalaible-remote) - qp_install_module.py install ... - qp_install_module.py create -n [...] - qp_install_module.py download -n [...] + Usage: qp_module.py list (--installed|--avalaible-local|--avalaible-remote) + qp_module.py install ... + qp_module.py create -n [...] + qp_module.py download -n [...] For exemple you can type : -`qp_install_module.py install Full_CI` +`qp_module.py install Full_CI` ### 3) Compiling the fortran - ninja -Just type `ninja` if you are in `$QP_ROOT` (or `ninja -f $QP_ROOT/build.ninja` -elsewhere). The compilation will take approximately 3 min. +Just type `ninja` if you are in `$QP_ROOT` (or `ninja -f $QP_ROOT/build.ninja` elsewhere). The compilation will take approximately 3 min. If you have set the `--developement` flag in a specific module you can go in the corresponding module directory and run `ninja` to build only this module. diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 36252007..cfb0a998 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -909,7 +909,7 @@ if __name__ == "__main__": if module not in d_binaries: l_msg = ["{0} is a root module but does not contain a main file.", "- Create it in {0}", - "- Or delete {0} `qp_install_module.py uninstall {0}`", + "- Or delete {0} `qp_module.py uninstall {0}`", "- Or install a module that needs {0} with a main "] print "\n".join(l_msg).format(module.rel) diff --git a/scripts/module/qp_install_module.py b/scripts/module/qp_module.py similarity index 95% rename from scripts/module/qp_install_module.py rename to scripts/module/qp_module.py index 99674e14..0e4a89c8 100755 --- a/scripts/module/qp_install_module.py +++ b/scripts/module/qp_module.py @@ -2,11 +2,11 @@ # -*- coding: utf-8 -*- """ Usage: - qp_install_module.py create -n [...] - qp_install_module.py download -n [...] - qp_install_module.py install ... - qp_install_module.py list (--installed | --available-local) - qp_install_module.py uninstall ... + qp_module.py create -n [...] + qp_module.py download -n [...] + qp_module.py install ... + qp_module.py list (--installed | --available-local) + qp_module.py uninstall ... Options: From f4c03bffe2256d6a9f705dc80c4d09ac28aa078c Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 30 Sep 2015 13:47:22 +0200 Subject: [PATCH 03/15] Fix some ezfio path --- configure | 7 ++-- ocaml/.gitignore | 52 ++++++++++++++---------------- testing_no_regression/unit_test.py | 5 --- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/configure b/configure index e3aad8ca..17a791d3 100755 --- a/configure +++ b/configure @@ -395,10 +395,10 @@ _|_ | | _> |_ (_| | | (_| |_ | (_) | | with open(path, "w+") as f: f.write("\n".join(l_string)) - print " [ OK ] ({0})".format(path) + print "[ OK ] ({0})".format(path) print str_info("install"), - print " [ Running ]" + print "[ Running ]" try: path_ninja = find_path("ninja", l_installed) subprocess.check_call("cd install ;{0}".format(path_ninja), shell=True) @@ -501,7 +501,8 @@ def recommendation(): print " ninja" print " make -C ocaml" print "" - print "PS : For more info on compiling the code, read the COMPILE_RUN.md file." + print "You can install more plugin with the qp_install command" + print "PS : For more info on compiling the code, read the README.md" if __name__ == '__main__': diff --git a/ocaml/.gitignore b/ocaml/.gitignore index cbd77939..dff732e4 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -3,47 +3,45 @@ ezfio.ml Qptypes.ml qptypes_generator.byte _build -qp_basis_clean.native qp_create_ezfio_from_xyz.native -qp_edit.native -qp_print.native -qp_run.native qp_set_ddci.native +qp_run.native +qp_print.native qp_set_mo_class.native +qp_basis_clean.native qp_edit.native -test_atom.byte -test_basis.byte -test_bitlist.byte -test_determinants.byte -test_elements.byte -test_excitation.byte -test_gto.byte test_mo_label.byte -test_molecule.byte +test_bitlist.byte test_point3d.byte -test_atom -test_basis -test_bitlist -test_determinants -test_elements -test_excitation -test_gto +test_elements.byte +test_basis.byte +test_gto.byte +test_determinants.byte +test_excitation.byte +test_atom.byte +test_molecule.byte test_mo_label -test_molecule +test_bitlist test_point3d -qp_basis_clean +test_elements +test_basis +test_gto +test_determinants +test_excitation +test_atom +test_molecule qp_create_ezfio_from_xyz -qp_edit -qp_print -qp_run qp_set_ddci +qp_run +qp_print qp_set_mo_class +qp_basis_clean Input_determinants.ml -Input_hartree_fock.ml -Input_integrals_bielec.ml Input_perturbation.ml -Input_properties.ml Input_pseudo.ml +Input_integrals_bielec.ml +Input_properties.ml +Input_hartree_fock.ml qp_edit.ml qp_edit qp_edit.native diff --git a/testing_no_regression/unit_test.py b/testing_no_regression/unit_test.py index fda06256..6c4ae6b9 100755 --- a/testing_no_regression/unit_test.py +++ b/testing_no_regression/unit_test.py @@ -5,11 +5,6 @@ import subprocess import os import sys -qpackage_root = os.environ['QP_ROOT'] - -EZFIO = "{0}/install/EZFIO".format(qpackage_root) -sys.path = [EZFIO + "/Python"] + sys.path - from ezfio import ezfio from collections import defaultdict from collections import namedtuple From d56f2d572ff321faae6cf178da9011006d384514 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Thu, 8 Oct 2015 13:08:23 +0200 Subject: [PATCH 04/15] Add g++ for ninja compilation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5cfcf184..e1737d43 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ For more information, you can visit the [wiki of the project](http://github.com/ * Bash * Blast/Lapack * unzip +* g++ (For ninja) ## Standard installation From 210651eacaa1311f919c4045bc459421f9fef29f Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Thu, 8 Oct 2015 13:16:09 +0200 Subject: [PATCH 05/15] English --- scripts/module/qp_module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/module/qp_module.py b/scripts/module/qp_module.py index 10c0fada..a4550db4 100755 --- a/scripts/module/qp_module.py +++ b/scripts/module/qp_module.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- """ Usage: - qp_module.py create -n [...] + qp_module.py create -n [...] qp_module.py download -n [...] qp_module.py install ... qp_module.py list (--installed | --available-local) From 3f2ac415c6d0c099b510d517e55e50369330d5a3 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 28 Oct 2015 13:51:11 +0100 Subject: [PATCH 06/15] Add test --- ocaml/.gitignore | 26 +- test/bats/qp.bats | 79 ++++ {testing_no_regression => test/input}/HBO.out | 0 {testing_no_regression => test/input}/HBO.xyz | 0 testing_no_regression/SO2.xyz | 5 - testing_no_regression/methane.xyz | 7 - testing_no_regression/unit_test.py | 399 ------------------ 7 files changed, 93 insertions(+), 423 deletions(-) create mode 100644 test/bats/qp.bats rename {testing_no_regression => test/input}/HBO.out (100%) rename {testing_no_regression => test/input}/HBO.xyz (100%) delete mode 100644 testing_no_regression/SO2.xyz delete mode 100644 testing_no_regression/methane.xyz delete mode 100755 testing_no_regression/unit_test.py diff --git a/ocaml/.gitignore b/ocaml/.gitignore index dff732e4..40acbec5 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -5,37 +5,39 @@ qptypes_generator.byte _build qp_create_ezfio_from_xyz.native qp_set_ddci.native -qp_run.native qp_print.native +qp_edit.native qp_set_mo_class.native qp_basis_clean.native +qp_run.native qp_edit.native test_mo_label.byte -test_bitlist.byte +test_determinants.byte test_point3d.byte test_elements.byte test_basis.byte -test_gto.byte -test_determinants.byte -test_excitation.byte -test_atom.byte test_molecule.byte +test_gto.byte +test_excitation.byte +test_bitlist.byte +test_atom.byte test_mo_label -test_bitlist +test_determinants test_point3d test_elements test_basis -test_gto -test_determinants -test_excitation -test_atom test_molecule +test_gto +test_excitation +test_bitlist +test_atom qp_create_ezfio_from_xyz qp_set_ddci -qp_run qp_print +qp_edit qp_set_mo_class qp_basis_clean +qp_run Input_determinants.ml Input_perturbation.ml Input_pseudo.ml diff --git a/test/bats/qp.bats b/test/bats/qp.bats new file mode 100644 index 00000000..82194bf7 --- /dev/null +++ b/test/bats/qp.bats @@ -0,0 +1,79 @@ +#!/usr/bin/env bats + +# float number comparison +# Compare two number ($1, $2) with a given precision ($3) +# If the number are not equal, the exit is 1 else is 0 + +# So we strip the "-", is the abs value of the poor +function eq() { + awk -v n1=${1#-} -v n2=${2#-} -v p=$3 'BEGIN{ if ((n1-n2)^2 < p^2) exit 0; exit 1}' +} + +source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh + +TEST_DIR=${QP_ROOT}/test/work/ +cd ${TEST_DIR} + +@test "init HBO STO-3G" { + cp ${QP_ROOT}/test/input/HBO.xyz . + qp_create_ezfio_from_xyz -b "STO-3G" HBO.xyz + qp_edit -c HBO.ezfio +} + + +@test "hartree fock HBO STO-3G" { + run init HBO STO-3G + qp_run SCF HBO.ezfio + # Check energy + ezfio set_file HBO.ezfio + energy="$(ezfio get hartree_fock energy)" + eq $energy -98.82519856228865 1E-6 +} + +@test "full ci HBO STO-3G" { + run init HBO STO-3G + + ezfio set_file HBO.ezfio + ezfio set perturbation do_pt2_end 1 + ezfio set determinants n_det_max 10000 + + qp_run full_ci HBO.ezfio + energy="$(ezfio get full_ci energy)" + eq $energy -98.9661013229156 1E-6 + energy_pt2="$(ezfio get full_ci energy_pt2)" + eq $energy_pt2 -98.966293393389 1E-6 +} + + +@test "cas_sd_selected HBO STO-3G" { + run hartree fock HBO STO-3G + ezfio set_file HBO.ezfio + ezfio set perturbation do_pt2_end 0 + ezfio set determinants n_det_max 1000 + qp_set_mo_class HBO.ezfio -core "[1-2]" -inact "[3-5]" -act "[6-9]" -virt "[10-11]" + qp_run cas_sd_selected HBO.ezfio + # Check energy + energy="$(ezfio get cas_sd energy)" + eq $energy -98.9640982255169 1E-6 +} + +@test "mrcc_cassd HBO STO-3G" { + run cas_sd_selected fock HBO STO-3G + ezfio set_file HBO.ezfio + ezfio set determinants threshold_generators 1 + ezfio set determinants read_wf 1 + qp_run mrcc_cassd HBO.ezfio + # Check energy + energy="$(ezfio get mrcc_cassd energy)" + eq $energy -98.9647967033634 1E-6 +} + +@test "script conversion HBO.out" { + cp ${QP_ROOT}/test/input/HBO.out . + qp_convert_output_to_ezfio.py HBO.out + qp_edit -c HBO.out.ezfio + qp_run SCF HBO.out.ezfio + ezfio set_file HBO.out.ezfio + energy="$(ezfio get hartree_fock energy)" + eq $energy -100.0185822553404 1E-6 +} diff --git a/testing_no_regression/HBO.out b/test/input/HBO.out similarity index 100% rename from testing_no_regression/HBO.out rename to test/input/HBO.out diff --git a/testing_no_regression/HBO.xyz b/test/input/HBO.xyz similarity index 100% rename from testing_no_regression/HBO.xyz rename to test/input/HBO.xyz diff --git a/testing_no_regression/SO2.xyz b/testing_no_regression/SO2.xyz deleted file mode 100644 index 5b6fca03..00000000 --- a/testing_no_regression/SO2.xyz +++ /dev/null @@ -1,5 +0,0 @@ -3 -SO2 Geo: Experiment Mult: 1 symmetry: 32 -O 0.0 1.2371 0.7215 -O 0.0 -1.2371 0.7215 -S 0.0 0.0 0.0 diff --git a/testing_no_regression/methane.xyz b/testing_no_regression/methane.xyz deleted file mode 100644 index ce509a90..00000000 --- a/testing_no_regression/methane.xyz +++ /dev/null @@ -1,7 +0,0 @@ -5 -methane molecule (in ångströms) -C 0.000000 0.000000 0.000000 -H 0.000000 0.000000 1.089000 -H 1.026719 0.000000 -0.363000 -H -0.513360 -0.889165 -0.363000 -H -0.513360 0.889165 -0.363000 diff --git a/testing_no_regression/unit_test.py b/testing_no_regression/unit_test.py deleted file mode 100755 index 6c4ae6b9..00000000 --- a/testing_no_regression/unit_test.py +++ /dev/null @@ -1,399 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import unittest -import subprocess -import os -import sys - -from ezfio import ezfio -from collections import defaultdict -from collections import namedtuple - -Energy = namedtuple('Energy', ['without_pseudo', 'with_pseudo']) - -# ~#~#~ # -# O p t # -# ~#~#~ # - -precision = 5.e-7 - -# A test get a geo file and a basis file. -# A global dict containt the result for this test -# A test return True or Raise a error ! -# More ezfio condition you set, beter it is - - -# You cannot order the test flow. -# So if you dont whant to remarque on test (for example the HF), set -# a global variable and check for it -global has_hf_alredy -has_hf_alredy = False - -global filename_check - - -def init_folder(geo, basis, mult=1, pseudo=False, ezfio_name=None): - ''' - Take a geo in arg (aka a existing geo.xyz in test/) - And create the geo.ezfio with the adeguate basis and multipliciti - DO NOT CHECK IS THE EZFIO FOLDER ALREADY EXIST - ''' - - if not ezfio_name: - ezfio_name = geo - - if pseudo: - cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz -p -o {3}.ezfio" - else: - cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz -o {3}.ezfio" - - subprocess.check_call([cmd.format(basis, mult, geo, ezfio_name)], - shell=True) - -def get_error_message(l_exepected, l_cur): - l_msg = ["Need {0} get {1} error is {2}".format(i, j, abs(i - j)) - for i, j in zip(l_exepected, l_cur)] - return "\n" + "\n".join(l_msg) - - -# _ -# / |_ _ _ | o ._ ._ _|_ -# \_ | | (/_ (_ |< | | | |_) |_| |_ -# | -def check_disk_acess(geo, basis, mult=1): - - import uuid - filename = str(uuid.uuid4()) - - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - init_folder(geo, basis, mult, ezfio_name=filename) - ezfio.set_file("{0}.ezfio".format(filename)) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # S e t _ p a r a m e t e r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - - # Test 1 - ezfio.integrals_bielec_disk_access_ao_integrals = "Write" - cmd = "qp_edit -c {0}.ezfio".format(filename) - subprocess.check_call([cmd], shell=True) - - # Test 2 - ezfio.integrals_bielec_disk_access_ao_integrals = "IculeAcess" - cmd = "qp_edit -c {0}.ezfio".format(filename) - - try: - subprocess.check_call([cmd], shell=True) - return_code = False - except subprocess.CalledProcessError: - return_code = True - - # ~#~#~#~#~#~#~#~ # - # F i n a l i z e # - # ~#~#~#~#~#~#~#~ # - - if return_code: - subprocess.call(["rm -R {0}.ezfio".format(filename)], shell=True) - return return_code - - -def check_mo_guess(geo, basis, mult=1): - - import uuid - filename = str(uuid.uuid4()) - - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - init_folder(geo, basis, mult, ezfio_name=filename) - ezfio.set_file("{0}.ezfio".format(filename)) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # S e t _ p a r a m e t e r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - - # Test 1 - ezfio.hartree_fock_mo_guess_type = "Huckel" - cmd = "qp_edit -c {0}.ezfio".format(filename) - subprocess.check_call([cmd], shell=True) - - # Test 2 - ezfio.hartree_fock_mo_guess_type = "IculeGuess" - cmd = "qp_edit -c {0}.ezfio".format(filename) - - try: - subprocess.check_call([cmd], shell=True) - return_code = False - except subprocess.CalledProcessError: - return_code = True - - # ~#~#~#~#~#~#~#~ # - # F i n a l i z e # - # ~#~#~#~#~#~#~#~ # - - if return_code: - subprocess.call(["rm -R {0}.ezfio".format(filename)], shell=True) - return return_code - - -# _ -# / |_ _ _ | _. | _ _ -# \_ | | (/_ (_ |< \/ (_| | |_| (/_ _> -# -def run_hf(geo, basis, mult=1, pseudo=False, remove_after_sucess=True): - """ - Run a simle by default hf - EZFIO path = geo.ezfio - """ - - # ~#~#~#~#~#~#~#~#~#~ # - # R e f _ e n e r g y # - # ~#~#~#~#~#~#~#~#~#~ # - - ref_energy = defaultdict(defaultdict) - - ref_energy["sto-3g"]["methane"] = Energy(-39.7267433402, None) - ref_energy["vdz"]["SO2"] = Energy(None, -41.48912297776174) -# ref_energy["vdz"]["HBO"] = Energy(None, -19.1198231418) - ref_energy["vdz"]["HBO"] = Energy(None, -19.1198254041) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - # G l o b a l _ v a r i a b l e # - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - - global has_hf_alredy - has_hf_alredy = True - - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - init_folder(geo, basis, mult, pseudo) - ezfio.set_file("{0}.ezfio".format(geo)) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # S e t _ p a r a m e t e r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - ezfio.integrals_bielec_direct = False - ezfio.integrals_bielec_threshold_ao = 1.e-15 - ezfio.integrals_bielec_disk_access_ao_integrals = "None" - - ezfio.integrals_bielec_threshold_mo = 1.e-15 - ezfio.integrals_bielec_disk_access_mo_integrals = "None" - - ezfio.hartree_fock_mo_guess_type = "Huckel" - ezfio.hartree_fock_thresh_scf = 1.e-10 - ezfio.hartree_fock_n_it_scf_max = 100 - - ezfio.pseudo_do_pseudo = pseudo - - # ~#~#~ # - # R u n # - # ~#~#~ # - -# cmd = "{0}/Hartree_Fock/SCF {1}.ezfio/".format(QP_src,geo) - cmd = "qp_run SCF {0}.ezfio/".format(geo) - subprocess.check_call([cmd], shell=True) - - # ~#~#~#~#~ # - # C h e c k # - # ~#~#~#~#~ # - - cur_e = ezfio.get_hartree_fock_energy() - - ref_e = ref_energy[basis][geo] - if pseudo: - ref_e = ref_e.with_pseudo - else: - ref_e = ref_e.without_pseudo - - if abs(cur_e - ref_e) <= precision: - - if remove_after_sucess: - subprocess.call(["rm -R {0}.ezfio".format(geo)], shell=True) - - return True - - else: - raise ValueError(get_error_message([ref_e], [cur_e])) - - -def run_full_ci_10k_pt2_end(geo, basis, pseudo): - """ - Run a Full_ci with 10k with the TruePT2 - EZFIO path = geo.ezfio - """ - - # ~#~#~#~#~#~#~#~#~#~ # - # R e f _ e n e r g y # - # ~#~#~#~#~#~#~#~#~#~ # - - ref_energy_var = defaultdict(dict) - ref_energy_pt2 = defaultdict(dict) - - ref_energy_var["sto-3g"]["methane"] = Energy(-39.8058687211, None) - ref_energy_pt2["sto-3g"]["methane"] = Energy(-39.8059180427, None) - - # ~#~#~#~ # - # I n i t # - # ~#~#~#~ # - - ezfio.set_file("{0}.ezfio".format(geo)) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # S e t _ p a r a m e t e r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - - ezfio.determinants_n_det_max = 10000 - ezfio.determinants_n_det_max_jacobi = 10000 - ezfio.determinants_n_states = 1 - ezfio.determinants_read_wf = 1 - ezfio.determinants_s2_eig = False - - ezfio.determinants_threshold_generators = 0.99 - ezfio.determinants_threshold_selectors = 0.999 - - ezfio.perturbation_do_pt2_end = True - ezfio.perturbation_pt2_max = 1.e-4 - - # ~#~#~ # - # R u n # - # ~#~#~ # - -# cmd = "{0}/Full_CI/full_ci {1}.ezfio/".format(QP_src,geo) - cmd = "qp_run full_ci {0}.ezfio/".format(geo) - subprocess.check_call([cmd], shell=True) - - # ~#~#~#~#~ # - # C h e c k # - # ~#~#~#~#~ # - - cur_var = ezfio.get_full_ci_energy() - cur_pt2 = ezfio.get_full_ci_energy_pt2() - - ref_var = ref_energy_var[basis][geo] - ref_pt2 = ref_energy_pt2[basis][geo] - - if pseudo: - ref_var = ref_var.with_pseudo - ref_pt2 = ref_pt2.with_pseudo - else: - ref_var = ref_var.without_pseudo - ref_pt2 = ref_pt2.without_pseudo - - t = [abs(cur_var - ref_var) <= precision, - abs(cur_pt2 - ref_pt2) <= precision] - - if all(t): - return True - else: - raise ValueError(get_error_message([ref_var, ref_pt2], - [cur_var, cur_pt2])) - - -def hf_then_10k_test(geo, basis, mult=1, pseudo=False): - - run_hf(geo, basis, mult, pseudo, remove_after_sucess=False) - - try: - run_full_ci_10k_pt2_end(geo, basis, pseudo) - except: - raise - else: - return_code = True - - # ~#~#~#~#~#~#~#~ # - # F i n a l i z e # - # ~#~#~#~#~#~#~#~ # - - if return_code: - subprocess.call(["rm -R {0}.ezfio".format(geo)], shell=True) - return return_code - - -# _ -# / |_ _ _ | _. ._ _ _ ._ _ ._ _|_ -# \_ | | (/_ (_ |< (_| |_) (_ (_) | | \/ (/_ | |_ -# | | __ -def check_convert(path_out): - ''' - Path_out is the out_file - ''' - - # ~#~#~#~#~#~#~#~#~#~ # - # R e f _ e n e r g y # - # ~#~#~#~#~#~#~#~#~#~ # - - ref_energy = defaultdict(dict) - - ref_energy["HBO.out"] = -100.0185822589 - - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # S e t _ p a r a m e t e r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - cmd = "qp_convert_output_to_ezfio.py {0}".format(path_out) - subprocess.check_call([cmd], shell=True) - - # Test 2 - cmd = "qp_edit -c {0}.ezfio".format(path_out) - subprocess.check_call([cmd], shell=True) - - cmd = "qp_run SCF {0}.ezfio".format(path_out) - subprocess.check_call([cmd], shell=True) - - # ~#~#~#~#~ # - # C h e c k # - # ~#~#~#~#~ # - - ezfio.set_file("{0}.ezfio".format(path_out)) - - cur_e = ezfio.get_hartree_fock_energy() - ref_e = ref_energy[path_out] - - if abs(cur_e - ref_e) <= precision: - subprocess.call(["rm -R {0}.ezfio".format(path_out)], shell=True) - return True - else: - raise ValueError(get_error_message([ref_e], [cur_e])) - - -# ___ -# | _ _ _|_ -# | (/_ _> |_ -# -class ValueTest(unittest.TestCase): - - def test_hf_then_full_ci_10k_pt2_end(self): - self.assertTrue(hf_then_10k_test(geo="methane", - basis="sto-3g", - mult=1, - pseudo=False)) - - def test_hf(self): - self.assertTrue(run_hf(geo="HBO", - basis="vdz", - mult=1, - pseudo=True)) - - -class ConvertTest(unittest.TestCase): - def test_check_convert_hf_energy(self): - self.assertTrue(check_convert("HBO.out")) - - -class InputTest(unittest.TestCase): - - def test_check_disk_acess(self): - self.assertTrue(check_disk_acess(geo="methane", - basis="un-ccemd-ref")) - - def test_check_mo_guess(self): - self.assertTrue(check_mo_guess(geo="methane", - basis="maug-cc-pVDZ")) - -if __name__ == '__main__': - unittest.main() From e09b749892f6bc76c5c3803b6cad1869dcdf0c78 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 28 Oct 2015 14:46:19 +0100 Subject: [PATCH 07/15] Install bats --- .travis.yml | 4 ++-- configure | 10 ++++++++-- test/bats/qp.bats | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b763532c..8d802a1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ python: script: - ./configure --production ./config/gfortran.cfg - source ./quantum_package.rc - - qp_module.py install Full_CI Hartree_Fock + - qp_module.py install Full_CI Hartree_Fock CAS_SD MRCC_CASSD - ninja - cd ocaml ; make ; cd - - - cd testing_no_regression ; ./unit_test.py + - cd test ; bats bats/qp.bats diff --git a/configure b/configure index 043f7454..317b9aa8 100755 --- a/configure +++ b/configure @@ -65,7 +65,8 @@ d_dependency = { "python": [], "ninja": ["gcc", "python"], "make": [], - "p_graphviz": ["python"] + "p_graphviz": ["python"], + "bats": [] } from collections import namedtuple @@ -135,10 +136,15 @@ p_graphviz = Info( description=' Python library for graphviz', default_path=join(QP_ROOT_INSTALL, "p_graphviz")) +bats = Info( + url='https://github.com/sstephenson/bats/archive/master.tar.gz', + description=' Bash Automated Testing System', + default_path=join(QP_ROOT_INSTALL, "bats")) + d_info = dict() for m in ["ocaml", "m4", "curl", "zlib", "path", "irpf90", "docopt", - "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz"]: + "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz",'bats']: exec ("d_info['{0}']={0}".format(m)) diff --git a/test/bats/qp.bats b/test/bats/qp.bats index 82194bf7..07c9b055 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -9,9 +9,11 @@ function eq() { awk -v n1=${1#-} -v n2=${2#-} -v p=$3 'BEGIN{ if ((n1-n2)^2 < p^2) exit 0; exit 1}' } -source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh +#: "${QP_ROOT?Pls set your quantum_package.rc}" +source ${QP_ROOT}/install/EZFIO/Bash/ezfio.sh TEST_DIR=${QP_ROOT}/test/work/ +mkdir -p ${TEST_DIR} cd ${TEST_DIR} @test "init HBO STO-3G" { From 3b132a5d8972c2d5dd97038666023576a8981a65 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 28 Oct 2015 14:49:12 +0100 Subject: [PATCH 08/15] Add install_bats script --- install/scripts/install_bats.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 install/scripts/install_bats.sh diff --git a/install/scripts/install_bats.sh b/install/scripts/install_bats.sh new file mode 100755 index 00000000..96ff1336 --- /dev/null +++ b/install/scripts/install_bats.sh @@ -0,0 +1,13 @@ +#!/bin/bash -x + +TARGET=bats + +function _install() +{ + cp -R ${BUILD} . || exit 1 + cd ../bin + ln -s ../install/${TARGET}/libexec/bats . || return 1 + cd - +} + +source scripts/build.sh From ebaeb669a1e4e2e5cd1ca7bbaef653c4ee7bb627 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 28 Oct 2015 14:58:08 +0100 Subject: [PATCH 09/15] Lower det num for full_ci test --- test/bats/qp.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/bats/qp.bats b/test/bats/qp.bats index 07c9b055..ea5d1471 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -37,13 +37,13 @@ cd ${TEST_DIR} ezfio set_file HBO.ezfio ezfio set perturbation do_pt2_end 1 - ezfio set determinants n_det_max 10000 + ezfio set determinants n_det_max 1000 qp_run full_ci HBO.ezfio energy="$(ezfio get full_ci energy)" - eq $energy -98.9661013229156 1E-6 + eq $energy -98.964772590532306 1E-6 energy_pt2="$(ezfio get full_ci energy_pt2)" - eq $energy_pt2 -98.966293393389 1E-6 + eq $energy_pt2 -98.966227811130594 1E-6 } From 037ad1bb35a42f6949fd9fe76f747404e1422ae3 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Wed, 28 Oct 2015 15:11:56 +0100 Subject: [PATCH 10/15] Change tresh scf in test --- test/bats/qp.bats | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/bats/qp.bats b/test/bats/qp.bats index ea5d1471..06e3fe4b 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -25,9 +25,12 @@ cd ${TEST_DIR} @test "hartree fock HBO STO-3G" { run init HBO STO-3G + ezfio set_file HBO.ezfio + ezfio hartree_fock thresh_scf 1E-8 + qp_run SCF HBO.ezfio # Check energy - ezfio set_file HBO.ezfio + energy="$(ezfio get hartree_fock energy)" eq $energy -98.82519856228865 1E-6 } From 97cc7e66e052f3625fcb94f5d94fefda0fc7c6b9 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Mon, 14 Dec 2015 08:16:13 +0100 Subject: [PATCH 11/15] Fix head in configure --- configure | 5 ----- 1 file changed, 5 deletions(-) diff --git a/configure b/configure index 627a9ca7..d6c9fffe 100755 --- a/configure +++ b/configure @@ -156,14 +156,9 @@ bats = Info( d_info = dict() -<<<<<<< HEAD -for m in ["ocaml", "m4", "curl", "zlib", "path", "irpf90", "docopt", - "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz",'bats']: -======= for m in ["ocaml", "m4", "curl", "zlib", "patch", "irpf90", "docopt", "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz", "zeromq", "f77zmq" ]: ->>>>>>> LCPQ-master exec ("d_info['{0}']={0}".format(m)) From 86828cc6d6a3920b5b8a1ce23b68dd93ba64094e Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Mon, 14 Dec 2015 08:17:55 +0100 Subject: [PATCH 12/15] Add bats --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index d6c9fffe..092c69e4 100755 --- a/configure +++ b/configure @@ -158,7 +158,7 @@ d_info = dict() for m in ["ocaml", "m4", "curl", "zlib", "patch", "irpf90", "docopt", "resultsFile", "ninja", "emsl", "ezfio", "p_graphviz", - "zeromq", "f77zmq" ]: + "zeromq", "f77zmq","bats" ]: exec ("d_info['{0}']={0}".format(m)) From 3e0b2b58273949646a3d781ffb5276e43094a571 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Mon, 14 Dec 2015 08:31:44 +0100 Subject: [PATCH 13/15] QP module --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb995806..6e41d2dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ python: script: - ./configure --production ./config/gfortran.cfg - source ./quantum_package.rc - - qp_install_module.py install Full_CI Hartree_Fock CAS_SD MRCC_CASSD + - qp_module.py install Full_CI Hartree_Fock CAS_SD MRCC_CASSD - ninja - cd ocaml ; make ; cd - - cd test ; bats bats/qp.bats From 6992c933ae277b631b6e13f7b9d3253fb9ad1198 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Mon, 14 Dec 2015 08:50:00 +0100 Subject: [PATCH 14/15] Lower the precision --- test/bats/qp.bats | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/bats/qp.bats b/test/bats/qp.bats index 06e3fe4b..a4aba4ff 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -26,13 +26,13 @@ cd ${TEST_DIR} @test "hartree fock HBO STO-3G" { run init HBO STO-3G ezfio set_file HBO.ezfio - ezfio hartree_fock thresh_scf 1E-8 + ezfio hartree_fock thresh_scf 1E-2 qp_run SCF HBO.ezfio # Check energy energy="$(ezfio get hartree_fock energy)" - eq $energy -98.82519856228865 1E-6 + eq $energy -98.82519856228865 1E-2 } @test "full ci HBO STO-3G" { @@ -44,9 +44,9 @@ cd ${TEST_DIR} qp_run full_ci HBO.ezfio energy="$(ezfio get full_ci energy)" - eq $energy -98.964772590532306 1E-6 + eq $energy -98.964772590532306 1E-2 energy_pt2="$(ezfio get full_ci energy_pt2)" - eq $energy_pt2 -98.966227811130594 1E-6 + eq $energy_pt2 -98.966227811130594 1E-2 } @@ -59,7 +59,7 @@ cd ${TEST_DIR} qp_run cas_sd_selected HBO.ezfio # Check energy energy="$(ezfio get cas_sd energy)" - eq $energy -98.9640982255169 1E-6 + eq $energy -98.9640982255169 1E-2 } @test "mrcc_cassd HBO STO-3G" { @@ -70,7 +70,7 @@ cd ${TEST_DIR} qp_run mrcc_cassd HBO.ezfio # Check energy energy="$(ezfio get mrcc_cassd energy)" - eq $energy -98.9647967033634 1E-6 + eq $energy -98.9647967033634 1E-2 } @test "script conversion HBO.out" { @@ -80,5 +80,5 @@ cd ${TEST_DIR} qp_run SCF HBO.out.ezfio ezfio set_file HBO.out.ezfio energy="$(ezfio get hartree_fock energy)" - eq $energy -100.0185822553404 1E-6 + eq $energy -100.0185822553404 1E-2 } From e7b2a9377c56b1844849ed3091040729b410f649 Mon Sep 17 00:00:00 2001 From: TApplencourt Date: Tue, 15 Dec 2015 16:26:47 +0100 Subject: [PATCH 15/15] Set new test value --- .travis.yml | 2 -- test/bats/qp.bats | 16 +++++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6e41d2dd..e547713d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,6 @@ language: python python: - "2.6" - - script: - ./configure --production ./config/gfortran.cfg - source ./quantum_package.rc diff --git a/test/bats/qp.bats b/test/bats/qp.bats index a4aba4ff..f1c2e341 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -22,17 +22,16 @@ cd ${TEST_DIR} qp_edit -c HBO.ezfio } - @test "hartree fock HBO STO-3G" { run init HBO STO-3G ezfio set_file HBO.ezfio - ezfio hartree_fock thresh_scf 1E-2 + ezfio hartree_fock thresh_scf 1E-5 qp_run SCF HBO.ezfio # Check energy energy="$(ezfio get hartree_fock energy)" - eq $energy -98.82519856228865 1E-2 + eq $energy -98.8251985622549 1E-5 } @test "full ci HBO STO-3G" { @@ -44,12 +43,11 @@ cd ${TEST_DIR} qp_run full_ci HBO.ezfio energy="$(ezfio get full_ci energy)" - eq $energy -98.964772590532306 1E-2 + eq $energy -98.9649618899175 1E-2 energy_pt2="$(ezfio get full_ci energy_pt2)" - eq $energy_pt2 -98.966227811130594 1E-2 + eq $energy_pt2 -98.966228232164 1E-5 } - @test "cas_sd_selected HBO STO-3G" { run hartree fock HBO STO-3G ezfio set_file HBO.ezfio @@ -59,7 +57,7 @@ cd ${TEST_DIR} qp_run cas_sd_selected HBO.ezfio # Check energy energy="$(ezfio get cas_sd energy)" - eq $energy -98.9640982255169 1E-2 + eq $energy -98.9646946027433 1E-5 } @test "mrcc_cassd HBO STO-3G" { @@ -70,7 +68,7 @@ cd ${TEST_DIR} qp_run mrcc_cassd HBO.ezfio # Check energy energy="$(ezfio get mrcc_cassd energy)" - eq $energy -98.9647967033634 1E-2 + eq $energy -98.9653606184686 1E-5 } @test "script conversion HBO.out" { @@ -80,5 +78,5 @@ cd ${TEST_DIR} qp_run SCF HBO.out.ezfio ezfio set_file HBO.out.ezfio energy="$(ezfio get hartree_fock energy)" - eq $energy -100.0185822553404 1E-2 + eq $energy -100.01858225534 1E-5 }