Skip to content

Only do pairwise energy conservation if there are two or more particles#6818

Merged
JustinRayAngus merged 2 commits intoBLAST-WarpX:developmentfrom
dpgrote:fix_collision_pairwise_energy_conservation
Apr 28, 2026
Merged

Only do pairwise energy conservation if there are two or more particles#6818
JustinRayAngus merged 2 commits intoBLAST-WarpX:developmentfrom
dpgrote:fix_collision_pairwise_energy_conservation

Conversation

@dpgrote
Copy link
Copy Markdown
Member

@dpgrote dpgrote commented Apr 28, 2026

With unequally weight particles in binary collisions, the particle momenta are adjusted to exactly conserve energy and momentum. The adjustment for energy conservation is done pairwise (within each species). This PR adds a check that there are at least two particles in the cell before calling the routine that does the energy correction. Without this check, an infinite loop can arise since due to round off, the relative energy can be negative.

Also, a check is added for the unlikely case where the relative energy is negative for all pairs of particles.

@dpgrote dpgrote requested a review from JustinRayAngus April 28, 2026 18:07
@dpgrote dpgrote added the component: collisions Anything related to particle collisions label Apr 28, 2026
Copy link
Copy Markdown
Contributor

@JustinRayAngus JustinRayAngus left a comment

Choose a reason for hiding this comment

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

LGTM.

Thanks, Dave.

@JustinRayAngus JustinRayAngus merged commit 5711320 into BLAST-WarpX:development Apr 28, 2026
47 of 48 checks passed
@JustinRayAngus JustinRayAngus added bug Something isn't working bug: affects latest release Bug also exists in latest release version KISMET labels Apr 28, 2026
@dpgrote dpgrote deleted the fix_collision_pairwise_energy_conservation branch April 28, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug: affects latest release Bug also exists in latest release version bug Something isn't working component: collisions Anything related to particle collisions KISMET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants