-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Hello,
I think it might also be beneficial for users to have a direct example showing how to extract and register the determinants from a PySCF script.
For instance, I not only needed to confirm the 1-based indexing for the determinant list, but also to ensure that my TREXIO file contained the correct number of states (which, to be honest, was not obvious in my case since I am working with the ground state, and this section in the TREXIO documentation pertains to excited states).
The example determinant file you already have does not mention this and might not provide enough detail on how to do this from PySCF. Additionally, converting to a bit-field format may not be obvious depending on the user's level of knowledge. I believe you could directly use my PySCF script (which is highly inspired from your ResultsFIle work) related to this part, which is attached.
# Determinans in Trexio
from trexio_tools.group_tools import determinant as trexio_det #To convert in bitfiled format
int64_num = int((mo_num-1)/64) + 1
det_list = []
for occsa, occsb, _, _ in data_all_sorted: #occsa represent the alpha orbitals list whereas occsb is the beta one
occsa_upshifted = [orb + 1 for orb in occsa] #need +1 because pyscf orbital list is 0 based
occsb_upshifted = [orb + 1 for orb in occsb]
det_tmp = []
det_tmp += trexio_det.to_determinant_list(occsa_upshifted, int64_num)
det_tmp += trexio_det.to_determinant_list(occsb_upshifted, int64_num)
det_list.append(det_tmp)
offset_file = 0
trexio_file.set_state(0) #Needed otherwise qp2 export failed
trexio.write_state_num(trexio_file,1) #Needed otherwise qp2 export failed
n_chunks = 1
for _ in range(n_chunks):
trexio.write_determinant_list(trexio_file, offset_file, num_determinants, det_list)
offset_file += n_chunks
ci_coeff_list = []
for occsa, occsb, ci_coeff, _ in data_all_sorted:
ci_coeff_list.append(ci_coeff)
if len(ci_coeff_list) == num_determinants:
dset = np.array(ci_coeff_list)
trexio.write_determinant_coefficient(trexio_file, offset_file, num_determinants, dset)
Best
Originally posted by @NastaMauger in TREX-CoE/trexio_tools#45 (comment)