Skip to content

Commit

Permalink
Merge pull request #51 from TREX-CoE/basis_r_power
Browse files Browse the repository at this point in the history
  • Loading branch information
q-posev authored Nov 28, 2024
2 parents b1f4240 + 4d541c7 commit 0bcf74d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,28 @@ jobs:
echo "=== Check TREXIO file converted from GAMESS ==="
trexio check-mos -n 50 trexio_gamess.h5 > mos-res
grep "Norm of the error" < mos-res | grep -Eo "([0-9]+\.[0-9]*|\.?[0-9]+)([eE][+-][0-9]+)?" > error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 1.0'
cat error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 0.12'
echo "=== Check TREXIO file converted from PySCF ==="
trexio check-mos -n 50 trexio_pyscf_h2o.h5 > mos-res
trexio check-mos -n 100 trexio_pyscf_h2o.h5 > mos-res
grep "Norm of the error" < mos-res | grep -Eo "([0-9]+\.[0-9]*|\.?[0-9]+)([eE][+-][0-9]+)?" > error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 1.0'
cat error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 0.00018'
echo "=== Check TREXIO file converted from ORCA ==="
trexio check-mos -n 50 trexio_orca_h2o.h5 > mos-res
trexio check-mos -n 100 trexio_orca_h2o.h5 > mos-res
grep "Norm of the error" < mos-res | grep -Eo "([0-9]+\.[0-9]*|\.?[0-9]+)([eE][+-][0-9]+)?" > error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 1.0'
cat error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 0.08'
# benchmark helper converters
trexio convert-to -t molden -o trexio_molden.h5 trexio_gamess.h5
echo "=== Check normalization in spherical file ==="
trexio check-mos -n 100 data/methane_sphe.hdf5 > mos-res
grep "Norm of the error" < mos-res | grep -Eo "([0-9]+\.[0-9]*|\.?[0-9]+)([eE][+-][0-9]+)?" > error-res
cat error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 0.0017'
echo "=== Check normalization after transformation into cartesian file ==="
trexio convert-to -t cartesian data/methane_sphe.hdf5 -o methane_cart.hdf5
trexio check-mos -n 100 methane_cart.hdf5 > mos-res
grep "Norm of the error" < mos-res | grep -Eo "([0-9]+\.[0-9]*|\.?[0-9]+)([eE][+-][0-9]+)?" > error-res
cat error-res
python -c 'with open("error-res") as f: error = f.readline().strip(); assert float(error) < 0.0017'
Binary file added data/methane_sphe.hdf5
Binary file not shown.
23 changes: 0 additions & 23 deletions src/trexio_tools/converters/convert_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,53 +511,30 @@ def run_cart_phe(inp, filename, to_cartesian):
# Update MOs
if trexio.has_mo_coefficient(inp):
X = trexio.read_mo_coefficient(inp)
for i in range(R.shape[1]):
if normalization[i] != 1.:
X[i,:] /= normalization[i]
Y = X @ R.T
trexio.write_mo_coefficient(out, Y)

# Update 1e Integrals
if trexio.has_ao_1e_int_overlap(inp):
X = trexio.read_ao_1e_int_overlap(inp)
for i in range(R.shape[1]):
X[:,i] /= normalization[i]
for i in range(R.shape[1]):
X[i,:] /= normalization[i]
Y = R_norm_inv @ X @ R_norm_inv.T
trexio.write_ao_1e_int_overlap(out, Y)


if trexio.has_ao_1e_int_kinetic(inp):
X = trexio.read_ao_1e_int_kinetic(inp)
for i in range(R.shape[1]):
if normalization[i] != 1.:
X[:,i] /= normalization[i]
X[i,:] /= normalization[i]
trexio.write_ao_1e_int_kinetic(out, R_norm_inv @ X @ R_norm_inv.T)

if trexio.has_ao_1e_int_potential_n_e(inp):
X = trexio.read_ao_1e_int_potential_n_e(inp)
for i in range(R.shape[1]):
if normalization[i] != 1.:
X[:,i] /= normalization[i]
X[i,:] /= normalization[i]
trexio.write_ao_1e_int_potential_n_e(out, R_norm_inv @ X @ R_norm_inv.T)

if trexio.has_ao_1e_int_ecp(inp):
X = trexio.read_ao_1e_int_ecp(inp)
for i in range(R.shape[1]):
if normalization[i] != 1.:
X[:,i] /= normalization[i]
X[i,:] /= normalization[i]
trexio.write_ao_1e_int_ecp(out, R_norm_inv @ X @ R_norm_inv.T)

if trexio.has_ao_1e_int_core_hamiltonian(inp):
X = trexio.read_ao_1e_int_core_hamiltonian(inp)
for i in range(R.shape[1]):
if normalization[i] != 1.:
X[:,i] /= normalization[i]
X[i,:] /= normalization[i]
trexio.write_ao_1e_int_core_hamiltonian(out, R_norm_inv @ X @ R_norm_inv.T)

# Remove 2e integrals: too expensive to transform
Expand Down
11 changes: 5 additions & 6 deletions src/trexio_tools/group_tools/check_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ def run(trexio_file, n_points):
the matrix stored in the file.
"""

if not trexio.has_ao_1e_int_overlap(trexio_file):
raise Exception(
"One-electron overlap integrals are missing in the TREXIO file. Required for check-basis."
)

trexio_filename = trexio_file.filename
context = qmckl.context_create()
qmckl.trexio_read(context, trexio_filename)
Expand Down Expand Up @@ -56,7 +51,11 @@ def run(trexio_file, n_points):
S = chi.T @ chi * dv
print()

S_ex = trexio.read_ao_1e_int_overlap(trexio_file)
if trexio.has_ao_1e_int_overlap(trexio_file):
S_ex = trexio.read_ao_1e_int_overlap(trexio_file)
else:
S_ex = np.zeros((ao_num,ao_num))


# This produces a lot of output for large molecules, maybe wrap up in ``if debug`` statement ?
for i in range(ao_num):
Expand Down

0 comments on commit 0bcf74d

Please sign in to comment.