Tests: Derive analytical formula for particle_boundary_interaction#6817
Merged
RemiLehe merged 7 commits intoBLAST-WarpX:developmentfrom Apr 29, 2026
Conversation
Replace the hard-coded reference values with a Python expression that derives them from the input parameters: relativistic Lorentz factor, straight-line ray-sphere intersection for the impact point, mirror reflection at the impact point, and free flight to ts.t[-1]. Loosened tolerance from 1e-5 to 0.02. The remaining ~1.8% gap between the simulation and the analytical formula is due to the discretization of the embedded boundary in WarpX (the buffered scrape position sits slightly inside the sphere and the cell normal differs from the geometric one): doubling the resolution in r and z and halving dt reduces the z error from 1.79% to 0.61%, confirming convergence. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Previously the comment dropped the x0 and vx0 terms (they happen to vanish for the chosen initial condition x0 = 0). Write the full quadratic and use it in the code so the derivation reads correctly. Co-Authored-By: Claude Opus 4.7 <[email protected]>
EZoni
reviewed
Apr 28, 2026
Replace hard-coded electron positions with analytically computed ion impact points. Each emitted electron is matched to the closest impact point (rather than by index) to accommodate the stochastic thermal kick applied at emission. Tolerance is set as an absolute distance (0.025 m) that bounds the combined effect of the thermal kick and the EB discretization. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Replace hard-coded parameter values (sphere radius, initial particle positions and velocities) in both analysis scripts with values read from warpx_used_inputs via parse_input_file, as done in other analysis scripts. This makes the analytical derivation self-consistent with the actual simulation inputs. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Read ux/uy/uz from the final diagnostic (OpenPMDTimeSeries returns u/c) and back-propagate each electron to the analytically computed ion impact time. This removes the deterministic part of the thermal-kick displacement from the comparison, so the check captures only the EB discretization error. The tolerance tightens from 0.025 m to 0.01 m. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
for more information, see https://pre-commit.ci
Express the tolerance as a fraction of the sphere radius R (5 %) rather than an absolute distance, consistent with the particle_boundary_interaction analysis script. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
EZoni
approved these changes
Apr 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces hard-coded reference values in two test analysis scripts with Python expressions that derive them analytically from the input parameters (read via
parse_input_filefromwarpx_used_inputs).test_rz_particle_boundary_interaction_picmits.t[-1].1e-5to2 %, because the simulation result differs from the analytical (purely geometric) result by about 1.8 % onz. This error is due to the discretization of the EB (a sphere approximated by AMReX's cut-cell approach). This was confirmed by running with twice the resolution inrandzand half the timestep: the dominantzerror dropped from 1.79 % to 0.61 %, consistent with first-order convergence of the EB scraping.test_rz_secondary_ion_emission_picmiopenpmd_viewerreturns proper velocities in units of c). This removes the stochastic thermal-kick displacement from the comparison, so the check is sensitive only to the EB discretization error.🤖 Generated with Claude Code