Skip to content

Add symmetry support for PySCF multiconfiguration methods to savetoqmcpack#5564

Merged
ye-luo merged 10 commits intoQMCPACK:developfrom
NastaMauger:correct_savetoqmcpack
Jul 8, 2025
Merged

Add symmetry support for PySCF multiconfiguration methods to savetoqmcpack#5564
ye-luo merged 10 commits intoQMCPACK:developfrom
NastaMauger:correct_savetoqmcpack

Conversation

@NastaMauger
Copy link
Contributor

@NastaMauger NastaMauger commented Jul 1, 2025

Proposed changes

The current version of savetoqmcpack (PyscfToQmcpack.py) does not properly handle symmetry when using multiconfigurational SCF methods. As a result, it fails if the user enables symmetry in their PySCF calculation.

Related to this issue: #5563

What type(s) of changes does this code introduce?

  • Bugfix

The current version of PyscfToQmcpack.py uses an explicit type comparison against mcscf.mc1step.CASSCF:

  possible_determinant_source =[mcscf.casci.CASCI, mcscf.mc1step.CASSCF]
  if type(mf) in possible_determinant_source:

This fails when the user enables symmetry in PySCF, because the returned object is a subclass like mcscf.mc1step_symm.SymAdaptedCASSCF. Even though it is still an mcscf object, the type(mf) check does not account for subclasses.

This PR updates the type check to use isinstance():
isinstance(mf, (mcscf.casci.CASCI, mcscf.mc1step.CASSCF))
This ensures that both base types and any subclasses (including symmetry-adapted variants) are correctly recognized.

  • Code style update (formatting, renaming)

Added a clear and reliable condition to detect whether the wavefunction is multideterminant, ensuring proper handling of both symmetry and non-symmetry cases. Additionally, user-friendly print statements were included to notify the user when a multideterminant wavefunction has been successfully saved with the explicit name of the file.

Does this introduce a breaking change?

  • No

What systems has this change been tested on?

Tested with symmetry on and off; multideterminant detection works correctly.
test.txt

Checklist

Update the following with an [x] where the items apply. If you're unsure about any of them, don't hesitate to ask. This is
simply a reminder of what we are going to look for before merging your code.

  • I have read the pull request guidance and develop docs
  • This PR is up to date with the current state of 'develop'
  • Code added or changed in the PR has been clang-formatted
  • This PR adds tests to cover any new code, or to catch a bug that is being fixed
  • Documentation has been added (if appropriate)

Copy link
Contributor

@ye-luo ye-luo left a comment

Choose a reason for hiding this comment

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

Welcome and thank you for the fix.

Copy link
Contributor

@prckent prckent left a comment

Choose a reason for hiding this comment

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

Many thanks for investigating this and making the fix. As also noted by Ye, please can you update this to just have the functional change and not the formatting change? It makes it is more difficult to see the changes.

If you have opinions on helpful python formatting we can tackle that separately.

@prckent prckent changed the title Correct savetoqmcpack Add symmetry support for PySCF multiconfiguration methods to savetoqmcpack Jul 1, 2025
@NastaMauger NastaMauger requested a review from ye-luo July 3, 2025 04:56
@ye-luo
Copy link
Contributor

ye-luo commented Jul 7, 2025

Test this please

ye-luo
ye-luo previously approved these changes Jul 7, 2025
@prckent
Copy link
Contributor

prckent commented Jul 8, 2025

Thanks @NastaMauger . Unless you prefer otherwise, I think we can merge this. OK? As you noted in #5563 , clearly additional work is needed to get the overall support for PySCF multideterminant wavefunctions working correctly.

@NastaMauger
Copy link
Contributor Author

@prckent I agree.
A clear statement should be added to the manual or somewhere similar, indicating that there is a bug preventing the use of CASSCF with complex wavefunctions, so users are aware.

@NastaMauger
Copy link
Contributor Author

NastaMauger commented Jul 8, 2025

@prckent and @ye-luo This push fix a formatting and printing issue in the AFQMC converter that I mentioned earlier here.

@ye-luo
Copy link
Contributor

ye-luo commented Jul 8, 2025

Test this please

@ye-luo ye-luo enabled auto-merge July 8, 2025 18:57
@ye-luo ye-luo merged commit 9c47476 into QMCPACK:develop Jul 8, 2025
43 checks passed
@NastaMauger NastaMauger deleted the correct_savetoqmcpack branch July 25, 2025 22:07
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.

3 participants