mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-03 01:56:05 +01:00
Amelioration of unit test
This commit is contained in:
parent
88db8c9ae6
commit
780b0276ee
@ -19,4 +19,4 @@ default: Huckel
|
|||||||
[energy]
|
[energy]
|
||||||
type: double precision
|
type: double precision
|
||||||
doc: Calculated HF energy
|
doc: Calculated HF energy
|
||||||
interface: output
|
interface: output
|
||||||
|
@ -31,8 +31,10 @@ precision = 5.e-8
|
|||||||
global has_hf_alredy
|
global has_hf_alredy
|
||||||
has_hf_alredy = False
|
has_hf_alredy = False
|
||||||
|
|
||||||
|
global filename_check
|
||||||
|
|
||||||
def init_folder(geo, basis, mult=1):
|
|
||||||
|
def init_folder(geo, basis, mult=1, ezfio_name=None):
|
||||||
'''
|
'''
|
||||||
Take a geo in arg (aka a existing geo.xyz in test/)
|
Take a geo in arg (aka a existing geo.xyz in test/)
|
||||||
And create the geo.ezfio with the adeguate basis and multipliciti
|
And create the geo.ezfio with the adeguate basis and multipliciti
|
||||||
@ -42,10 +44,12 @@ def init_folder(geo, basis, mult=1):
|
|||||||
cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, geo)
|
cmd = "cp {0}/tests/{1}.xyz .".format(qpackage_root, geo)
|
||||||
subprocess.check_call([cmd], shell=True)
|
subprocess.check_call([cmd], shell=True)
|
||||||
|
|
||||||
cmd = "qp_create_ezfio_from_xyz -b {0} -m {1} {2}.xyz".format(basis,
|
if not ezfio_name:
|
||||||
mult,
|
ezfio_name = geo
|
||||||
geo)
|
|
||||||
subprocess.check_call([cmd], shell=True)
|
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):
|
def get_error_message(l_exepected, l_cur):
|
||||||
@ -54,11 +58,98 @@ def get_error_message(l_exepected, l_cur):
|
|||||||
return "\n".join(l_msg)
|
return "\n".join(l_msg)
|
||||||
|
|
||||||
|
|
||||||
def check_hf(geo, basis):
|
# _
|
||||||
ezfio.bielec_integrals_disk_access_ao_integrals = "None"
|
# / |_ _ _ | 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.bielec_integrals_disk_access_ao_integrals = "Write"
|
||||||
|
cmd = "qp_edit -c {0}.ezfio".format(filename)
|
||||||
|
subprocess.check_call([cmd], shell=True)
|
||||||
|
|
||||||
|
# Test 2
|
||||||
|
ezfio.bielec_integrals_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 run_hf(geo, basis):
|
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):
|
||||||
"""
|
"""
|
||||||
Run a simle by default hf
|
Run a simle by default hf
|
||||||
EZFIO path = geo.ezfio
|
EZFIO path = geo.ezfio
|
||||||
@ -82,7 +173,7 @@ def run_hf(geo, basis):
|
|||||||
# I n i t #
|
# I n i t #
|
||||||
# ~#~#~#~ #
|
# ~#~#~#~ #
|
||||||
|
|
||||||
init_folder(geo, basis)
|
init_folder(geo, basis, mult)
|
||||||
ezfio.set_file("{0}.ezfio".format(geo))
|
ezfio.set_file("{0}.ezfio".format(geo))
|
||||||
|
|
||||||
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
|
# ~#~#~#~#~#~#~#~#~#~#~#~#~ #
|
||||||
@ -176,18 +267,43 @@ def run_full_ci_10k_pt2_end(geo, basis):
|
|||||||
[cur_var, cur_pt2]))
|
[cur_var, cur_pt2]))
|
||||||
|
|
||||||
|
|
||||||
def run_big_test(geo, basis):
|
def hf_then_10k_test(geo, basis):
|
||||||
if not has_hf_alredy:
|
if not has_hf_alredy:
|
||||||
run_hf(geo, basis)
|
run_hf(geo, basis)
|
||||||
|
|
||||||
run_full_ci_10k_pt2_end(geo, basis)
|
try:
|
||||||
return True
|
run_full_ci_10k_pt2_end(geo, basis)
|
||||||
|
return_code = True
|
||||||
|
except:
|
||||||
|
return_code = False
|
||||||
|
|
||||||
|
# ~#~#~#~#~#~#~#~ #
|
||||||
|
# F i n a l i z e #
|
||||||
|
# ~#~#~#~#~#~#~#~ #
|
||||||
|
|
||||||
|
if return_code:
|
||||||
|
subprocess.call(["rm -R {0}.ezfio".format(geo)], shell=True)
|
||||||
|
return return_code
|
||||||
|
|
||||||
|
|
||||||
class SimplisticTest(unittest.TestCase):
|
# ___
|
||||||
|
# | _ _ _|_
|
||||||
|
# | (/_ _> |_
|
||||||
|
#
|
||||||
|
class ValueTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_full_ci_10k_pt2_end(self):
|
def test_full_ci_10k_pt2_end(self):
|
||||||
self.assertTrue(run_big_test("methane", "sto-3g"))
|
self.assertTrue(hf_then_10k_test("methane", "sto-3g"))
|
||||||
|
|
||||||
|
|
||||||
|
class InputTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_check_disk_acess(self):
|
||||||
|
self.assertTrue(check_disk_acess("methane", "un-ccemd-ref"))
|
||||||
|
|
||||||
|
def test_check_mo_guess(self):
|
||||||
|
self.assertTrue(check_mo_guess("methane", "maug-cc-pVDZ"))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user