Skip to content

Conversation

@cemitch99
Copy link
Member

@cemitch99 cemitch99 commented Nov 10, 2025

This PR adds a 2.5D Space Charge model for particle tracking, using a 2D Poisson solve (in the transverse variables X,Y) with current weighting along the longitudinal direction within the bunch. This addresses the final part of #401, and is a follow-up to #909 .

  • add basic logic and input structure
  • add longitudinal charge deposition and derivative (following 2.5D Gaussian Solver #1166 )
  • modify push logic
  • add Python bindings
  • update documentation
  • add examples

@ax3l ax3l added tracking: particles component: space charge Space charge & potential solver labels Nov 11, 2025
@ax3l ax3l requested review from ax3l and qianglbl November 11, 2025 17:36
@cemitch99
Copy link
Member Author

I'm reconsidering this approach now. The number of places where we need to replace True_2D with True_2D or True_2p5D is very large. I'm tempted to re-use True_2D and add another boolean to set to true when the user sets algo.space_charge = 2p5D.

px += field_interp[0] * Fxy * push_consts;
py += field_interp[1] * Fxy * push_consts;
pz += 0.0_rt;
//pz -= (eintz + pz_push_const) * Fz * push_consts;

Check notice

Code scanning / CodeQL

Commented-out code

This comment appears to contain commented-out code.
amrex::Real * beam_profile_slope = nullptr;
int num_bins = 129;

[[maybe_unused]] auto const [x_min, y_min, t_min, x_max, y_max, t_max] =

Check notice

Code scanning / CodeQL

Unused local variable

Variable x_min is not used.
amrex::Real * beam_profile_slope = nullptr;
int num_bins = 129;

[[maybe_unused]] auto const [x_min, y_min, t_min, x_max, y_max, t_max] =

Check notice

Code scanning / CodeQL

Unused local variable

Variable y_min is not used.
amrex::Real * beam_profile_slope = nullptr;
int num_bins = 129;

[[maybe_unused]] auto const [x_min, y_min, t_min, x_max, y_max, t_max] =

Check notice

Code scanning / CodeQL

Unused local variable

Variable x_max is not used.
amrex::Real * beam_profile_slope = nullptr;
int num_bins = 129;

[[maybe_unused]] auto const [x_min, y_min, t_min, x_max, y_max, t_max] =

Check notice

Code scanning / CodeQL

Unused local variable

Variable y_max is not used.
{
BL_PROFILE("impactx::spacecharge::Deposit1D");

using namespace amrex::literals;
Copy link
Member

Choose a reason for hiding this comment

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

Let's always assert here that beam_profile.size() is +1 of beam_profile_slope.size()

Comment on lines 28 to 29
[[maybe_unused]] amrex::Real * beam_profile,
[[maybe_unused]] amrex::Real * beam_profile_slope,
Copy link
Member

Choose a reason for hiding this comment

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

Let's pass a amrex::Gpu::DeviceVector<amrex::Real> by reference & here for each array.
Omit num_bins and take it from beam_profile_slope.size()

Copy link
Member

@ax3l ax3l Nov 26, 2025

Choose a reason for hiding this comment

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

Even better: pass no arrays and just return the profile array and bin_size.

Let's do the one-liner for slope calc afterwards, it is safe and not part of deposit.

amrex::GpuArray<amrex::Real, 3> const field_interp =
ablastr::particles::doGatherScalarFieldNodal<2>(
x, y, z,
phi_arr,
Copy link
Member Author

Choose a reason for hiding this comment

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

Here phi_arr still needs to be declared with the correct type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: space charge Space charge & potential solver tracking: particles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants