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

Allow to calc energy contrib for single bond #5040

Open
wants to merge 8 commits into
base: python
Choose a base branch
from

Conversation

RudolfWeeber
Copy link
Contributor

via system.analysis.particle_bond_energy(particle,bond)

This also

  • makes sure _bond_id is set on BondedInteraction instances once the bodn has been added to the system, and for instances returned by particle.bonds
  • upgrades teh assert (MPi deadlock in non-debug mode) for Utils::MPI::reduce_optional() to an exception. This should never happen to end users in any case, but is easier on developers who trigger it...

Comment on lines 38 to 41
assert(1 == boost::mpi::all_reduce(comm, static_cast<int>(!!result),
std::plus<>()) &&
"Incorrect number of return values");
if (boost::mpi::all_reduce(comm, static_cast<int>(!!result),
std::plus<>())!=1) {
throw std::runtime_error("Internal error. Incorrect number of return values when collecting values from MPI ranks");
}
Copy link
Member

Choose a reason for hiding this comment

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

Are you really sure about this change? We use assertions in almost all MPI reductions so that we get code coverage for the assertion. By turning it into an exception, we get zero code coverage for the body of the conditional, because it's impossible for the testsuite to enter it when there is no bug.

I'm always developing code with -D CMAKE_BUILD_TYPE=RelWithAssert builds, which is almost as fast as Release builds except for a few momentum-conservation tests, and has the advantage of enabling all assertions. By selectively turning a few critical assertions into exceptions, we are decreasing incentives for other ESPResSo developers to adopt RelWithAssert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like my answer via email ditn't work. I reverted the change in reuduce_optoinal()

@RudolfWeeber RudolfWeeber requested a review from jngrad February 7, 2025 13: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.

2 participants