10#ifndef HANDLE_WAKEFIELD_H
11#define HANDLE_WAKEFIELD_H
20#ifndef ImpactX_USE_FFT
36 template <
typename T_Element>
39 T_Element
const& element_variant,
41 bool print_wakefield =
false
44 BL_PROFILE(
"impactx::particles::wakefields::HandleWakefield")
54 if (csr && element_has_csr)
56#ifndef ImpactX_USE_FFT
57 throw std::runtime_error(
"algo.csr was requested but ImpactX was not compiled with FFT support. Recompile with ImpactX_FFT=ON.");
64 [[maybe_unused]]
auto const [x_min, y_min, t_min, x_max, y_max, t_max] =
68 bool const is_unity_particle_weight =
false;
69 bool const GetNumberDensity =
true;
71 int const num_bins = csr_bins;
72 amrex::Real
const bin_min = t_min;
73 amrex::Real
const bin_max = t_max;
74 amrex::Real
const bin_size = (bin_max - bin_min) / (num_bins - 1);
87 charge_distribution.
data(),
88 charge_distribution.
size(),
97 bin_size, is_unity_particle_weight);
106 amrex::Real *
const dptr_wake_function = wake_function.
data();
110 amrex::Real
const s =
static_cast<amrex::Real
>(i) * bin_size;
113 else if (i > num_bins) {
114 amrex::Real
const s =
static_cast<amrex::Real
>(i - 2*num_bins) * bin_size;
125 convolved_wakefield.
data(),
126 convolved_wakefield.
size(),
133 std::cout <<
"Convolved wakefield: ";
134 std::ofstream outfile(
"convolved_wakefield.txt");
135 for (
double const i : convolved_wakefield) {
136 std::cout << i <<
" ";
137 outfile << i << std::endl;
139 std::cout << std::endl;
size_type size() const noexcept
int queryAddWithParser(const char *name, T &ref)
int queryAdd(const char *name, T &ref)
Definition ImpactXParticleContainer.H:133
std::tuple< amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal > MinAndMaxPositions()
Definition ImpactXParticleContainer.cpp:399
RefPart & GetRefParticle()
Definition ImpactXParticleContainer.cpp:378
PODVector< T, ArenaAllocator< T > > DeviceVector
MPI_Comm Communicator() noexcept
void Bcast(void *, int, MPI_Datatype, int, MPI_Comm)
int IOProcessorNumber() noexcept
bool IOProcessor() noexcept
void Sum(T &v, int root, MPI_Comm comm)
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition ChargeBinning.cpp:17
void DerivativeCharge1D(amrex::Gpu::DeviceVector< amrex::Real > const &charge_distribution, amrex::Gpu::DeviceVector< amrex::Real > &slopes, amrex::Real bin_size, bool GetNumberDensity)
Definition ChargeBinning.cpp:87
void HandleWakefield(impactx::ImpactXParticleContainer &particle_container, T_Element const &element_variant, amrex::Real slice_ds, bool print_wakefield=false)
Definition HandleWakefield.H:37
void DepositCharge1D(impactx::ImpactXParticleContainer &myspc, amrex::Gpu::DeviceVector< amrex::Real > &charge_distribution, amrex::Real bin_min, amrex::Real bin_size, bool is_unity_particle_weight)
Definition ChargeBinning.cpp:18
void MeanTransversePosition(impactx::ImpactXParticleContainer &myspc, amrex::Gpu::DeviceVector< amrex::Real > &mean_x, amrex::Gpu::DeviceVector< amrex::Real > &mean_y, amrex::Real bin_min, amrex::Real bin_size, bool is_unity_particle_weight)
Definition ChargeBinning.cpp:115
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real w_l_csr(amrex::Real s, amrex::Real R, amrex::Real const bin_size)
Definition WakeConvolution.H:106
std::tuple< bool, amrex::Real > CSRBendElement(VariantType const &element_variant, RefPart const &refpart)
Definition CSRBendElement.H:35
amrex::Gpu::DeviceVector< amrex::Real > convolve_fft(amrex::Gpu::DeviceVector< amrex::Real > const &beam_profile_slope, amrex::Gpu::DeviceVector< amrex::Real > const &wake_func, amrex::Real delta_t)
Definition WakeConvolution.cpp:66
void WakePush(ImpactXParticleContainer &pc, amrex::Gpu::DeviceVector< amrex::Real > const &convolved_wakefield, amrex::ParticleReal slice_ds, amrex::Real bin_size, amrex::Real bin_min)
Definition WakePush.cpp:21
@ s
fixed s as the independent variable
Definition ImpactXParticleContainer.H:37