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 Note

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 Note

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 Note

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 Note

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 Note

Variable y_max is not used.
Comment on lines +42 to +43
amrex::Real * beam_profile = nullptr;
amrex::Real * beam_profile_slope = nullptr;
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.

Allocate the profiles here. Note that _slope is num_bins or so and the charge is num_bins + 1.

Suggested change
amrex::Real * beam_profile = nullptr;
amrex::Real * beam_profile_slope = nullptr;
amrex::Gpu::DeviceVector<amrex::Real> beam_profile(num_bins + 1, 0.0);
amrex::Gpu::DeviceVector<amrex::Real> beam_profile_slope(num_bins, 0.0);


if (space_charge == SpaceChargeAlgo::True_2p5D) {

Deposit1D ( pc, beam_profile, beam_profile_slope, bin_min, bin_max, num_bins);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Deposit1D ( pc, beam_profile, beam_profile_slope, bin_min, bin_max, num_bins);
Deposit1D( pc, beam_profile, beam_profile_slope, bin_min, bin_max, num_bins);

{
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.

Comment on lines +155 to +160
ablastr::particles::doGatherVectorFieldNodal<2>(
x, y, z,
scf_arr_x, scf_arr_y, scf_arr_z,
invdr,
prob_lo_2D
);
Copy link
Member

Choose a reason for hiding this comment

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

After passing also m_phi by reference into GatherAndPush (...):

Suggested change
ablastr::particles::doGatherVectorFieldNodal<2>(
x, y, z,
scf_arr_x, scf_arr_y, scf_arr_z,
invdr,
prob_lo_2D
);
ablastr::particles::doGatherScalarFieldNodal<2>(
x, y, z,
phi_arr,
invdr,
prob_lo_2D
);

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