1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-11-04 21:24:11 +01:00
qmckl/python/test/test_api.py

53 lines
1.1 KiB
Python
Raw Normal View History

2022-05-02 17:52:11 +02:00
"""
This is the test of the Python API of the QMCkl library.
It is the `bench_mos.c` C code adapted from the `bench`
2022-05-02 17:52:11 +02:00
repo and translated into Python with some modifications.
"""
2022-05-02 16:46:34 +02:00
from os.path import join
2022-05-02 17:52:11 +02:00
import time
import qmckl as pq
2022-05-02 17:52:11 +02:00
from data.data import coord
walk_num = 100
elec_num = 158
ITERMAX = 10
2022-05-02 16:46:34 +02:00
ctx = pq.context_create()
2022-05-02 16:46:34 +02:00
2022-05-04 11:47:30 +02:00
try:
pq.trexio_read(ctx, 'fake.h5')
2022-05-04 11:47:30 +02:00
except RuntimeError:
print('Error handling check: passed')
2022-05-02 16:46:34 +02:00
fname = join('data', 'Alz_small.h5')
pq.trexio_read(ctx, fname)
2022-05-04 11:47:30 +02:00
print('trexio_read: passed')
2022-05-02 17:52:11 +02:00
mo_num = pq.get_mo_basis_mo_num(ctx)
2022-05-04 11:47:30 +02:00
assert mo_num == 404
2022-05-02 17:52:11 +02:00
2022-08-07 15:43:52 +02:00
pq.set_electron_coord(ctx, 'T', walk_num, coord)
2022-05-02 17:52:11 +02:00
ao_type = pq.get_ao_basis_type(ctx)
assert 'G' in ao_type
2022-05-02 17:52:11 +02:00
size_max = 5*walk_num*elec_num*mo_num
mo_vgl = pq.get_mo_basis_mo_vgl(ctx, size_max)
2022-05-04 11:47:30 +02:00
assert mo_vgl.size == size_max
2022-05-02 17:52:11 +02:00
start = time.clock_gettime_ns(time.CLOCK_REALTIME)
for _ in range(ITERMAX):
mo_vgl_in = pq.get_mo_basis_mo_vgl_inplace(ctx, size_max)
2022-05-02 17:52:11 +02:00
end = time.clock_gettime_ns(time.CLOCK_REALTIME)
print(f'Time for the calculation of 1 step : {(end-start)*.000001/ITERMAX} ms')