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

CSF truncation #128

Open
NastaMauger opened this issue Nov 17, 2024 · 2 comments
Open

CSF truncation #128

NastaMauger opened this issue Nov 17, 2024 · 2 comments

Comments

@NastaMauger
Copy link

Hello,

Is there a way to truncate the final wavefunction at different thresholds in CSF space after generating it using the following code?

from mrh.my_pyscf.fci import csf_solver

norb = 10
nelec = 4 

casci = mcscf.casci_symm.CASCI(rhf, norb, nelec)
casci.verbose = 9 
casci.wfnsym = 'A' 
casci.fcisolver = csf_solver(mol, smult=1)

casci.kernel()
csf = casci.fcisolver.transformer.ncsf
print(f'Number of CSF is: {csf}')

I would like to truncate the wavefunction in CSF space at various thresholds to explore how properties change as a function of the number of determinants.

So far, I have used a naive truncation procedure that sets a threshold based on the CI coefficients, but I would prefer to do the truncation based on the CSFs instead.

Thank you for your help!

@MatthewRHermes
Copy link
Owner

There is no truncation system built into the solver.

To access the CI vector in the CSF basis so that you can script it yourself, do this:

ci_csf = casci.fcisolver.transformer.vec_det2csf (casci.ci)

The meaning of the ith element of the vector ci_csf can be obtained by

print (casci.fcisolver.transformer.printable_csfstring (i))

@MatthewRHermes
Copy link
Owner

IDK what workflow you're trying to build here, but if you have some list of CSFs that you want to forbid for whatever reason, then I think you can accomplish this by patching fcisolver.transformer.vec_det2csf and fcisolver.transformer.vec_csf2det to set forbidden CSF elements to zero and either using fcisolver.davidson_only = True or additionally patching fcisolver.pspace like

idx_allow = # a boolean array of shape (ncsf,) which is True where a CSF is allowed and False where a CSF is forbidden
def new_pspace (*args, **kwargs):
    addr, h0 = old_pspace (*args, **kwargs)
    i = idx_allow[addr]
    return addr[i], h0[np.ix_(i,i)]

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

No branches or pull requests

2 participants