10#ifndef IMPACTX_SOFTQUAD_H
11#define IMPACTX_SOFTQUAD_H
68 -9.056149864743113E-002,
69 1.803476331179615E-002,
70 4.464887700797893E-002,
71 7.364410636252136E-003,
72 -1.697541023436736E-002,
73 -9.012679515542771E-003,
74 4.367667630047725E-003,
75 5.444030542119803E-003,
76 -5.889959910931886E-005,
77 -2.409098101409192E-003,
78 -7.962712154165590E-004,
79 7.855814707106538E-004,
80 6.174930463182168E-004,
81 -1.340154094301854E-004,
82 -3.167213724698439E-004,
83 -4.925292460592617E-005,
84 1.221580597451921E-004,
85 6.331025910961789E-005,
86 -3.202416719002774E-005,
87 -3.872103053895529E-005,
88 8.212882937116278E-007
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 static constexpr auto type =
"SoftQuadrupole";
143 std::vector<amrex::ParticleReal> cos_coef,
144 std::vector<amrex::ParticleReal> sin_coef,
152 std::optional<std::string>
name = std::nullopt
161 m_ncoef = int(cos_coef.size());
162 if (
m_ncoef !=
int(sin_coef.size()))
163 throw std::runtime_error(
"SoftQuadrupole: cos and sin coefficients must have same length!");
182 using BeamOptic::operator();
195 Alignment::compute_constants(refpart);
217 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
246 auto const out = R *
v;
285 refpart.map =
decltype(refpart.map)::Identity();
313 refpart.x = x + slice_ds*px/bgi;
314 refpart.y = y + slice_ds*py/bgi;
315 refpart.z = z + slice_ds*pz/bgi;
321 refpart.px = px*bgf/bgi;
322 refpart.py = py*bgf/bgi;
323 refpart.pz = pz*bgf/bgi;
326 refpart.s =
s + slice_ds;
330 using LinearTransport::operator();
354 std::tuple<amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal>
362#if AMREX_DEVICE_COMPILE
381 if (std::abs(z) <= zmid)
383 bfield = 0.5_prt*cos_data[0];
384 bfieldint = z*bfield;
385 for (
int j=1; j <
m_ncoef; ++j)
387 bfield = bfield + cos_data[j] *std::cos(j * 2 * pi * z / zlen) +
388 sin_data[j] *std::sin(j * 2 * pi * z / zlen);
389 bfieldp = bfieldp - j * 2 * pi * cos_data[j] *std::sin(j * 2 * pi * z / zlen) / zlen +
390 j * 2 * pi * sin_data[j] *std::cos(j * 2 * pi * z / zlen) / zlen;
391 bfieldint = bfieldint + zlen * cos_data[j] *std::sin(j * 2 * pi * z / zlen) / (j * 2 * pi) -
392 zlen * sin_data[j] *std::cos(j * 2 * pi * z / zlen) / (j * 2 * pi);
395 return std::make_tuple(bfield, bfieldp, bfieldint);
420 refpart.
t =
t + tau/std::sqrt(1.0_prt - powi<-2>(pt));
434 refpart.
map(1,1) = R(1,1) + tau*R(2,1);
435 refpart.
map(1,2) = R(1,2) + tau*R(2,2);
436 refpart.
map(1,3) = R(1,3) + tau*R(2,3);
437 refpart.
map(1,4) = R(1,4) + tau*R(2,4);
439 refpart.
map(3,1) = R(3,1) + tau*R(4,1);
440 refpart.
map(3,2) = R(3,2) + tau*R(4,2);
441 refpart.
map(3,3) = R(3,3) + tau*R(4,3);
442 refpart.
map(3,4) = R(3,4) + tau*R(4,4);
444 refpart.
map(5,5) = R(5,5) + tau*R(6,5)/powi<2>(betgam);
445 refpart.
map(5,6) = R(5,6) + tau*R(6,6)/powi<2>(betgam);
481 refpart.
map(2,1) = R(2,1) - tau*alpha*R(1,1);
482 refpart.
map(2,2) = R(2,2) - tau*alpha*R(1,2);
483 refpart.
map(2,3) = R(2,3) - tau*alpha*R(1,3);
484 refpart.
map(2,4) = R(2,4) - tau*alpha*R(1,4);
486 refpart.
map(4,1) = R(4,1) + tau*alpha*R(3,1);
487 refpart.
map(4,2) = R(4,2) + tau*alpha*R(3,2);
488 refpart.
map(4,3) = R(4,3) + tau*alpha*R(3,3);
489 refpart.
map(4,4) = R(4,4) + tau*alpha*R(3,4);
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define IMPACTX_PUSH_EXTERN_TEMPLATE(ElementType)
Definition PushAll.H:78
T_ParticleType ParticleType
#define IMPACTX_GPUDATA_EXTERN(ElementType)
Definition dynamicdata.H:130
amrex_particle_real ParticleReal
constexpr T powi(T x) noexcept
__host__ __device__ void ignore_unused(const Ts &...)
SmallMatrix< T, N, 1, Order::F, StartIndex > SmallVector
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp2_integrate(RefPart &refpart, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition Integrators.H:36
@ s
fixed s as the independent variable
Definition ImpactXParticleContainer.H:37
@ t
fixed t as the independent variable
Definition ImpactXParticleContainer.H:38
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > Map6x6
Definition CovarianceMatrix.H:20
static constexpr __host__ __device__ SmallMatrix< T, NRows, NCols, ORDER, StartIndex > Identity() noexcept
Definition ReferenceParticle.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta_gamma() const
Definition ReferenceParticle.H:166
amrex::ParticleReal pt
energy, normalized by rest energy
Definition ReferenceParticle.H:42
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > map
linearized map
Definition ReferenceParticle.H:48
amrex::ParticleReal t
clock time * c in meters
Definition ReferenceParticle.H:38
amrex::Vector< amrex::ParticleReal > default_cos_coef
Definition SoftQuad.H:63
amrex::Vector< amrex::ParticleReal > default_sin_coef
Definition SoftQuad.H:91
Definition SoftQuad.H:104
mixin::TrackedVector< amrex::ParticleReal > sin
Definition SoftQuad.H:106
mixin::TrackedVector< amrex::ParticleReal > cos
Definition SoftQuad.H:105
Definition SoftQuad.H:118
static constexpr auto type
Definition SoftQuad.H:119
mixin::GPUDataRegistry< QuadrupoleFourierCoefficients > DynamicData
Definition SoftQuad.H:122
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map1(amrex::ParticleReal const tau, RefPart &refpart, amrex::ParticleReal &zeval) const
Definition SoftQuad.H:407
int m_ncoef
unique soft quad id used for data lookup map
Definition SoftQuad.H:497
ImpactXParticleContainer::ParticleType PType
Definition SoftQuad.H:120
SoftQuadrupole(amrex::ParticleReal ds, amrex::ParticleReal gscale, std::vector< amrex::ParticleReal > cos_coef, std::vector< amrex::ParticleReal > sin_coef, amrex::ParticleReal dx=0, amrex::ParticleReal dy=0, amrex::ParticleReal rotation_degree=0, amrex::ParticleReal aperture_x=0, amrex::ParticleReal aperture_y=0, int mapsteps=1, int nslice=1, std::optional< std::string > name=std::nullopt)
Definition SoftQuad.H:140
amrex::ParticleReal const * m_cos_d_data
non-owning pointer to host sine coefficients
Definition SoftQuad.H:500
int m_id
number of map integration steps per slice
Definition SoftQuad.H:495
amrex::ParticleReal const * m_sin_h_data
non-owning pointer to host cosine coefficients
Definition SoftQuad.H:499
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition SoftQuad.H:339
std::tuple< amrex::ParticleReal, amrex::ParticleReal, amrex::ParticleReal > AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Quad_Bfield(amrex::ParticleReal const zeval) const
Definition SoftQuad.H:356
amrex::ParticleReal m_gscale
Definition SoftQuad.H:493
int m_mapsteps
scaling factor for quad field gradient
Definition SoftQuad.H:494
void reverse()
Definition SoftQuad.H:175
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT t, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py, T_Real &AMREX_RESTRICT pt, T_IdCpu &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition SoftQuad.H:219
amrex::ParticleReal const * m_sin_d_data
non-owning pointer to device cosine coefficients
Definition SoftQuad.H:501
amrex::ParticleReal const * m_cos_h_data
number of Fourier coefficients
Definition SoftQuad.H:498
void compute_constants(RefPart const &refpart)
Definition SoftQuad.H:191
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map2(amrex::ParticleReal const tau, RefPart &refpart, amrex::ParticleReal &zeval) const
Definition SoftQuad.H:458
Definition alignment.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_out(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:109
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:146
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:136
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_in(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:78
Definition beamoptic.H:436
Definition dynamicdata.H:50
static std::shared_ptr< QuadrupoleFourierCoefficients > const & get(int id)
Definition dynamicdata.H:73
static QuadrupoleFourierCoefficients & emplace(int id, Args &&... args)
Definition dynamicdata.H:100
Definition lineartransport.H:50
AMREX_GPU_HOST Named(std::optional< std::string > name)
Definition named.H:57
AMREX_FORCE_INLINE std::string name() const
Definition named.H:122
Definition nofinalize.H:22
Definition pipeaperture.H:26
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void apply_aperture(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_IdCpu &AMREX_RESTRICT idcpu) const
Definition pipeaperture.H:59
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_x() const
Definition pipeaperture.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_y() const
Definition pipeaperture.H:101
PipeAperture(amrex::ParticleReal aperture_x, amrex::ParticleReal aperture_y)
Definition pipeaperture.H:32
Thick(amrex::ParticleReal ds, int nslice)
Definition thick.H:30
amrex::ParticleReal m_ds
Definition thick.H:68
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition thick.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition thick.H:43
Definition TrackedVector.H:49