Skip to content

Commit

Permalink
Removed incrementation from compute_intersections call (#62)
Browse files Browse the repository at this point in the history
* Removed incrementation from compute_intersections call, leading to issues with n many body expansions on n + 1 mers

* add regression test

* trivial change to re-trigger CI

---------

Co-authored-by: ryan <[email protected]>
  • Loading branch information
jlheflin and ryanmrichard authored Jul 30, 2024
1 parent d0c1ae4 commit 2ebd77e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void compute_intersection(const index_set& curr_frag, std::size_t starting_frag,
// Add the intersection
ints_so_far.insert(intersection);

compute_intersection(intersection, starting_frag + 1, frag_indices,
compute_intersection(intersection, starting_frag, frag_indices,
ints_so_far);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,42 @@ TEST_CASE("Intersection Finder") {
}
}
}

TEST_CASE("Bug associated with #62") {
// It was found that this module didn't work correctly when the MBE is
// truncated at order (n-1) for a system with n monomers, e.g., a three-body
// expansion on water tetramer would exhibit this bug. This regression test
// ensures that the module works for a three-body truncation of water 4
// (n.b. we just use hydrogen atoms as the module only cares about
// nuclear indices).

nuclei_type nuclei;

for(auto i = 0; i < 12; ++i) {
nuclei.push_back(nucleus_type("H", 1ul, 1.0, i, 0.0, 0.0));
}

fragments_type fragmented_nuclei(nuclei);
fragmented_nuclei.insert({0, 1, 2, 3, 4, 5, 6, 7, 8});
fragmented_nuclei.insert({0, 1, 2, 3, 4, 5, 9, 10, 11});
fragmented_nuclei.insert({0, 1, 2, 6, 7, 8, 9, 10, 11});
fragmented_nuclei.insert({3, 4, 5, 6, 7, 8, 9, 10, 11});

fragments_type corr(fragmented_nuclei);
corr.insert({0, 1, 2});
corr.insert({0, 1, 2, 3, 4, 5});
corr.insert({0, 1, 2, 6, 7, 8});
corr.insert({0, 1, 2, 9, 10, 11});
corr.insert({3, 4, 5});
corr.insert({3, 4, 5, 6, 7, 8});
corr.insert({3, 4, 5, 9, 10, 11});
corr.insert({6, 7, 8});
corr.insert({6, 7, 8, 9, 10, 11});
corr.insert({9, 10, 11});

auto mm = testing::initialize();
auto& mod = mm.at("Intersections");

auto intersects = mod.run_as<property_type>(fragmented_nuclei);
REQUIRE(intersects == corr);
}

0 comments on commit 2ebd77e

Please sign in to comment.