Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TREXIO + MCSCF wavefunction #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

NastaMauger
Copy link
Contributor

@NastaMauger NastaMauger commented Dec 20, 2024

Hello,

In this PR, you will find modifications that allow users to register an MCSCF function in the TREXIO format.

I am uncertain if additional data must be stored for TREXIO to function correctly with other software and to return the corresponding wave function produced by PySCF before registering it into TREXIO. However, the corresponding HDF5 file generated using the following code:

mcscf = mcscf.casci_symm.CASCI(rhf, norb, nelec)
mcscf.fcisolver = selected_ci_spin0_symm.SelectedCI(rhf)

mcscf.kernel()
trexio_file = 'data_mcscf.hdf5'
pyscf_trexio.to_trexio(mcscf, trexio_file)

pyscf_trexio.det_to_trexio(mcscf, norb, nelec, trexio_file)
eri = mol.intor('int2e')
pyscf_trexio.write_eri(eri, trexio_file)

seems to register the data correctly.

Please let me know if further modifications or improvements are necessary. I am also uncertain whether the one-electron MO group is essential, as mentione here. I would also appreciate any feedback on whether the write_eri function needs to be modified to handle CASCI/CASSCF, particularly for the corresponding active space

Best

@q-posev
Copy link

q-posev commented Jan 2, 2025

Thank you @NastaMauger !

I noticed that you do not register the CI determinants as part of your new mcscf_to_trexio. Is it intended?

@q-posev
Copy link

q-posev commented Jan 2, 2025

I guess the best test of the validity of the produced multi-configurational TREXIO wavefunction is via an attempt to import and use it in some software that handles such wave functions (e.g. QP2)? @NastaMauger @scemama

@@ -434,10 +464,6 @@ def det_to_trexio(mcscf, norb, nelec, filename, backend='h5', ci_threshold=0., c
with trexio.File(filename, 'u', back_end=_mode(backend)) as tf:
if trexio.has_determinant(tf):
trexio.delete_determinant(tf)
trexio.write_mo_num(tf, mo_num)
trexio.write_electron_up_num(tf, len(a))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this removed? We need the number of up and down electrons to perform the CI determinants "correctness" check before writing them in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled by the _mcscf_to_trexio function, which calls _mol_to_trexio.

Reshape write_eri function to ensusre conssitency between other codes
mcscf_function directly register the determinant list now
@NastaMauger
Copy link
Contributor Author

NastaMauger commented Feb 17, 2025

@q-posev

  • I noticed that you do not register the CI determinants as part of your new mcscf_to_trexio. Is it intended?
    Done

  • I guess the best test of the validity of the produced multi-configurational TREXIO wavefunction is via an attempt to import and use it in some software that handles such wave functions (e.g. QP2)? @NastaMauger @scemama
    There is still an issue due to the normalization factor, which needs to be resolved.

  • The write-eri function might still lack consistency between what the original function in pyscf-forge returns and what QP2 (or other software) might expect.

@q-posev
Copy link

q-posev commented Feb 17, 2025

@NastaMauger

For the ERIs - I agree, @kgasperich submitted a draft PR which takes care of the AO/MO inconsistency.

@NastaMauger
Copy link
Contributor Author

NastaMauger commented Mar 1, 2025

Hello,

I am following this issue as it's a feature I really want to add.

After discussing with @q-posev and @scemama, we observed that although we correctly registered all necessary data into TREXIO, there is still a difference between the CASSCF energy from PySCF and the exported TREXIO file. Upon examining the convergence of the energy with respect to the CAS space, it seems there may be a hidden selected CI procedure within the CASSCF routine.

@sunqm Could you please confirm and provide guidance on how to correctly register the CASCI wavefunction if some selected CI is implicitly performed?

Best

@MatthewRHermes
Copy link
Collaborator

Hello,

I am following this issue as it's a feature I really want to add.

After discussing with @q-posev and @scemama, we observed that although we correctly registered all necessary data into TREXIO, there is still a difference between the CASSCF energy from PySCF and the exported TREXIO file. Upon examining the convergence of the energy with respect to the CAS space, it seems there may be a hidden selected CI procedure within the CASSCF routine.

@sunqm Could you please confirm and provide guidance on how to correctly register the CASCI wavefunction if some selected CI is implicitly performed?

Best

There is no selected CI procedure in CASSCF that I am aware of. There is a procedure to approximate the CI step during the orbital optimization, but that should have no effect on the evaluation of the CASCI energy, which is entirely determined by the MO coefficients, one- and two-electron integrals, and CI vectors. Could you elaborate on what you are seeing?

@sunqm
Copy link
Contributor

sunqm commented Mar 8, 2025

Hello,

I am following this issue as it's a feature I really want to add.

After discussing with @q-posev and @scemama, we observed that although we correctly registered all necessary data into TREXIO, there is still a difference between the CASSCF energy from PySCF and the exported TREXIO file. Upon examining the convergence of the energy with respect to the CAS space, it seems there may be a hidden selected CI procedure within the CASSCF routine.

@sunqm Could you please confirm and provide guidance on how to correctly register the CASCI wavefunction if some selected CI is implicitly performed?

Best

Are you able to reproduce the CASSCF energy for small systems like H2 molecule with (2,2) CAS?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants