Skip to content

Add EK species/container tau cross-check#5383

Merged
jngrad merged 3 commits into
espressomd:pythonfrom
RudolfWeeber:fix/bug-19-ekspecies-tau-crosscheck
Jun 23, 2026
Merged

Add EK species/container tau cross-check#5383
jngrad merged 3 commits into
espressomd:pythonfrom
RudolfWeeber:fix/bug-19-ekspecies-tau-crosscheck

Conversation

@RudolfWeeber

Copy link
Copy Markdown
Contributor

EKContainer::add_in_core validated only floating-point precision and the
MPI Cartesian-communicator observer, never comparing the new species' tau
against the container's tau. An EKSpecies derives all of its MD<->lattice
conversion factors (diffusion, flux, energy, external e-field) from its own
tau, while the integrator and the MD-tau veto use the container tau. When
the two differ, effective diffusion/flux/mobility are wrong by a factor of
tau_species/tau_container with no error raised: ekcontainer.add(species)
succeeded silently.

Add a tau comparison inside the existing parallel_try_catch lambda, next to
the precision/observer checks, throwing std::runtime_error when the species
tau differs from the container tau. The check runs under the same
coordinated parallel_try_catch on every rank, so it cannot diverge. This
PREVENTs the inconsistent input rather than silently rescaling baked-in
conversion factors, matching how every other add-time mismatch in this path
is treated and the documented contract that tau must be an integer multiple
of the MD time step on both classes.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

🤖 Generated with Claude Code

RudolfWeeber and others added 3 commits June 16, 2026 16:44
…19)

EKContainer::add_in_core validated only floating-point precision and the
MPI Cartesian-communicator observer, never comparing the new species' tau
against the container's tau. An EKSpecies derives all of its MD<->lattice
conversion factors (diffusion, flux, energy, external e-field) from its own
tau, while the integrator and the MD-tau veto use the container tau. When
the two differ, effective diffusion/flux/mobility are wrong by a factor of
tau_species/tau_container with no error raised: ekcontainer.add(species)
succeeded silently.

Add a tau comparison inside the existing parallel_try_catch lambda, next to
the precision/observer checks, throwing std::runtime_error when the species
tau differs from the container tau. The check runs under the same
coordinated parallel_try_catch on every rank, so it cannot diverge. This
PREVENTs the inconsistent input rather than silently rescaling baked-in
conversion factors, matching how every other add-time mismatch in this path
is treated and the documented contract that tau must be an integer multiple
of the MD time step on both classes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jngrad jngrad marked this pull request as ready for review June 23, 2026 16:36
@jngrad jngrad added the BugFix label Jun 23, 2026

@jngrad jngrad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jngrad jngrad changed the title walberla: fix missing EK species/container tau cross-check (bug-sweep #19) Add EK species/container tau cross-check Jun 23, 2026
@jngrad jngrad merged commit d2584a2 into espressomd:python Jun 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants