8000 Generate truncated hilbert spaces by brianz98 · Pull Request #448 · evangelistalab/forte · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Generate truncated hilbert spaces #448

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

Merged
merged 8 commits into from
Feb 16, 2025
Merged

Generate truncated hilbert spaces #448

merged 8 commits into from
Feb 16, 2025

Conversation

brianz98
Copy link
Contributor

Description

This PR is a small modification on the make_hilbert_space function that allows one to truncate the total excitation rank relative to the aufbau determinant.

Checklist

  • Added/updated tests of new features and included a reference output.ref file
  • Documented source code
  • Ready to go!

Copy link
Member
@fevangelista fevangelista left a comment

Choose a reason for hiding this comment

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

Can I suggest a slightly different strategy here? Can we have the aufbau determinant passed to the function? That would expand significantly its use case.

@brianz98
Copy link
Contributor Author

Can I suggest a slightly different strategy here? Can we have the aufbau determinant passed to the function? That would expand significantly its use case.

Thanks for the suggestion! It is now implemented and tested.

@brianz98
Copy link
Contributor Author

@fevangelista having thought about it a little more - do we want to enforce the symmetry of the reference determinant to be the symmetry of generated determinants? For example, what if we want to generate all B1u determinants that can be coupled to the Ag aufbau reference by the dipole operator or some other non totally symmetric operators?


auto strings_a = make_strings(nmo, na, nirrep, mo_symmetry);
auto strings_b = make_strings(nmo, nb, nirrep, mo_symmetry);
for (size_t ha = 0; ha < nirrep; ha++) {
int hb = symmetry ^ ha;
for (const auto& Ia : strings_a[ha]) {
int exc_a = (aufbau_a ^ Ia).count() / 2;
Copy link
Member

Choose a reason for hiding this comment

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

I think that here you could use the faster function fast_a_xor_b_count

for (const auto& Ib : strings_b[hb]) {
dets.push_back(Determinant(Ia, Ib));
int exc_b = (aufbau_b ^ Ib).count() / 2;
Copy link
Member

Choose a reason for hiding this comment

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

same as above


auto strings_a = make_strings(nmo, na, nirrep, mo_symmetry);
auto strings_b = make_strings(nmo, nb, nirrep, mo_symmetry);
for (size_t ha = 0; ha < nirrep; ha++) {
int hb = symmetry ^ ha;
for (const auto& Ia : strings_a[ha]) {
int exc_a = (aufbau_a ^ Ia).count() / 2;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int exc_a = (aufbau_a ^ Ia).count() / 2;
int exc_a = Ia. fast_a_xor_b_count(aufbau_a) / 2;

dets.push_back(Determinant(Ia, Ib));
int exc_b = (aufbau_b ^ Ib).count() / 2;
if (truncation == -1) {
dets.push_back(Determinant(Ia, Ib));
Copy link
Member

Choose a reason for hiding this comment

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

Maybe here and below we could use:

Suggested change
dets.push_back(Determinant(Ia, Ib));
dets.emplace_back(Ia, Ib);

@@ -68,9 +68,10 @@ std::vector<std::vector<String>> make_strings(int n, int k, size_t nirrep,
/// @param nirrep The number of irreps
/// @param mo_symmetry The symmetry of the MOs
/// @param symmetry The symmetry of the determinants
/// @param truncation The excitation level truncation
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// @param truncation The excitation level truncation
/// @param truncation The excitation level truncation (default = -1, no truncation)

if (symmetry >= static_cast<int>(nirrep)) {
throw std::runtime_error(
"The symmetry of the determinants is greater than the number of irreps.");
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add a check that ref has symmetry equal to symmetry.

@fevangelista fevangelista merged commit 9008253 into main Feb 16, 2025
2 checks passed
@fevangelista fevangelista deleted the trunc_hilbert branch February 16, 2025 02:21
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
0