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

Tuto det #1

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

Tuto det #1

wants to merge 12 commits into from

Conversation

NastaMauger
Copy link

Hello,

Here is the tutorial for PySCF + TREXIO with the determinants feature.
Let me know if any further modifications are needed.

Best

@NastaMauger
Copy link
Author

NastaMauger commented Nov 17, 2024

I realized that PySCF registers the ERI in the MO group of TREXIO. Since mol.into('int2e') in PySCF gives the two-electron integrals in the AO basis, don't you think that line 174 of trexio.py should be modified to register in the AO field of TREXIO?

I even wonder if it might be better to add a parameter to the write_eri function, so that the user can specify whether the ERI they want to register is in the AO or MO basis. For example:

def write_eri(eri, eri_type, filename): 
    if eri_type == 'MO':
        trexio.write_mo_2e_int_eri(tf, 0, num_integrals, idx, eri.ravel())
    elif eri_type == 'AO':
        trexio.write_ao_2e_int_eri(tf, 0, num_integrals, idx, eri.ravel())

Let me know your thoughts.


# Save results in TREXIO format
trexio_file = 'rhf.hdf5'
to_trexio(mf, trexio_file)
Copy link
Member

Choose a reason for hiding this comment

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

Please define where all your functions come from. If you try to run your Jupyter notebook as it is right now - the execution will fail because to_trexio and a bunch of other TREXIO-related functions will not be found.

Since this is a tutorial for newcomers - we try to be more pedagogic and give more details so that the user always knows where the functions come from. In your case, for example, one can do:

from pyscf.tools import trexio as pyscf_trexio
pyscf_trexio.to_trexio(...)


## Importing TREXIO

TREXIO is avialble throught the pyscf-forge repository (https://github.com/pyscf/pyscf-forge). After installing PySCF-FORGE, you can access the TREXIO library within PySCF using the following import statement:
Copy link
Member

Choose a reason for hiding this comment

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

Please check the text for typos (e.g. avialble here)

The ```det_to_trexio``` function registers the number of MO, number of alpha and beta electrions, total number of determinants, coefficients and the determinants in bitfield format.

## Applying a Threshold for Determinants
You can filter determinants by their coefficients, saving only those that exceed a specified threshold:
Copy link
Member

Choose a reason for hiding this comment

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

This is not recommended as you might produce an inconsistent wave function data (see Anthony's comment elsewhere). Please remove this section.

import trexio

filename = 'data_for_qp2.hdf5'
trexio_file = trexio.File(filename, mode='w', back_end=trexio.TREXIO_HDF5)
Copy link
Member

Choose a reason for hiding this comment

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

You can use a context handling here, e.g.

with trexio.File(filename, mode='w', back_end=trexio.TREXIO_HDF5) as trexio_file:
  #Index of the current state: 0 is the GS
  trexio_file.set_state(0)
  #Total number of states
  trexio.write_state_num(trexio_file,1) 

This way, you do not need to manually close the file via .close()

Copy link
Member

@q-posev q-posev left a comment

Choose a reason for hiding this comment

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

Thank you @NastaMauger !
I left a few comments. My main concern is that at present, the notebook is not functional as it is missing:

  1. A practical example of the PySCF Molecule/SCF setup. Perhaps you can provide some simple small molecule like H2O (or some other molecule that you use for your tests) as an example here?
  2. The imported functions are not defined and so if you try to run the notebook - you will get a bunch of errors stemming from the fact that the functions could not be found. Since this is a tutorial for newcomers who do not necessarily know the pyscf-forge source code - more details are needed.

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.

2 participants