10#ifndef IMPACTX_EXACTQUAD_H
11#define IMPACTX_EXACTQUAD_H
45 static constexpr auto type =
"ExactQuad";
104 using BeamOptic::operator();
118 Alignment::compute_constants(refpart);
150 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
205 template<
typename T_Real>
215 T_Real
const x = particle(1);
216 T_Real
const px = particle(2);
217 T_Real
const y = particle(3);
218 T_Real
const py = particle(4);
219 T_Real
const t = particle(5);
220 T_Real
const pt = particle(6);
238 xout = cos_omega_ds*x + sin_omega_ds/
m_omega*px;
239 pxout = -
m_omega*sin_omega_ds*x + cos_omega_ds*px;
241 yout = cosh_omega_ds*y + sinh_omega_ds/
m_omega*py;
242 pyout =
m_omega*sinh_omega_ds*y + cosh_omega_ds*py;
244 tout =
t + slice_bg*pt;
246 }
else if (
m_g < 0.0_prt)
249 xout = cosh_omega_ds*x + sinh_omega_ds/
m_omega*px;
250 pxout =
m_omega*sinh_omega_ds*x + cosh_omega_ds*px;
252 yout = cos_omega_ds*y + sin_omega_ds/
m_omega*py;
253 pyout = -
m_omega*sin_omega_ds*y + cos_omega_ds*py;
255 tout =
t + slice_bg*pt;
263 tout =
t + slice_bg * pt;
287 template<
typename T_Real>
298 T_Real
const x = particle(1);
299 T_Real
const px = particle(2);
300 T_Real
const y = particle(3);
301 T_Real
const py = particle(4);
302 T_Real
const t = particle(5);
303 T_Real
const pt = particle(6);
306 T_Real
const inv_pzden = 1_prt /
sqrt(
314 particle(1) = x + tau * px * (-1_prt + inv_pzden);
316 particle(3) = y + tau * py * (-1_prt + inv_pzden);
333 template<
typename T_Real>
350 T_Real lambdax = 0_prt;
351 T_Real lambday = 0_prt;
352 T_Real lambdaz = 0_prt;
354 T_Real
const x = particle(1);
355 T_Real
const px = particle(2);
356 T_Real
const y = particle(3);
357 T_Real
const py = particle(4);
359 T_Real
const pt = particle(6);
360 T_Real sx = particle_spin(1);
361 T_Real sy = particle_spin(2);
362 T_Real sz = particle_spin(3);
365 T_Real
const Bx =
m_g * y *
m_beta * gamma_ref;
366 T_Real
const By =
m_g * x *
m_beta * gamma_ref;
367 T_Real
const Bz = 0_prt;
370 T_Real
const Ex = 0.0_prt;
371 T_Real
const Ey = 0.0_prt;
372 T_Real
const Ez = 0.0_prt;
375 T_Real
const Pnorm =
sqrt(1_prt - 2_prt * pt *
m_ibeta + pt*pt);
376 T_Real
const iPnorm = 1_prt/Pnorm;
377 T_Real
const Ps =
sqrt(Pnorm*Pnorm - px*px - py*py);
378 T_Real
const gamma = gamma_ref * (1_prt - pt*
m_beta);
379 T_Real
const ux = px * iPnorm;
380 T_Real
const uy = py * iPnorm;
381 T_Real
const uz = Ps * iPnorm;
387 tbmt_precession_vector(x,ux,uy,uz,gamma,h,gyro_anomaly,Bx,By,Bz,Ex,Ey,Ez,lambdax,lambday,lambdaz);
398 particle_spin(1) = sx;
399 particle_spin(2) = sy;
400 particle_spin(3) = sz;
435 refpart.x = x + step*px;
436 refpart.y = y + step*py;
437 refpart.z = z + step*pz;
438 refpart.t =
t - step*pt;
441 refpart.s =
s + slice_ds;
469 R(1,1) = std::cos(omega*slice_ds);
470 R(1,2) = std::sin(omega*slice_ds)/omega;
471 R(2,1) = -omega*std::sin(omega*slice_ds);
472 R(2,2) = std::cos(omega*slice_ds);
473 R(3,3) = std::cosh(omega*slice_ds);
474 R(3,4) = std::sinh(omega*slice_ds)/omega;
475 R(4,3) = omega*std::sinh(omega*slice_ds);
476 R(4,4) = std::cosh(omega*slice_ds);
477 R(5,6) = slice_ds/betgam2;
478 }
else if (
m_k < 0.0_prt) {
479 R(1,1) = std::cosh(omega*slice_ds);
480 R(1,2) = std::sinh(omega*slice_ds)/omega;
481 R(2,1) = omega*std::sinh(omega*slice_ds);
482 R(2,2) = std::cosh(omega*slice_ds);
483 R(3,3) = std::cos(omega*slice_ds);
484 R(3,4) = std::sin(omega*slice_ds)/omega;
485 R(4,3) = -omega*std::sin(omega*slice_ds);
486 R(4,4) = std::cos(omega*slice_ds);
487 R(5,6) = slice_ds/betgam2;
512 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
555 sx = particle_spin(1);
556 sy = particle_spin(2);
557 sz = particle_spin(3);
561 using LinearTransport::operator();
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define IMPACTX_PUSH_EXTERN_TEMPLATE(ElementType)
Definition PushAll.H:78
T_ParticleType ParticleType
amrex_particle_real ParticleReal
constexpr T powi(T x) noexcept
SmallMatrix< T, N, 1, Order::F, StartIndex > SmallVector
__host__ __device__ GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp2_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, RefPart const &refpart, T_Element const &element)
Definition Integrators.H:182
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp4_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, RefPart const &refpart, T_Element const &element)
Definition Integrators.H:231
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp_integrate_particle_spin(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::SmallVector< T_Real, 3, 1 > &particle_spin, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, int int_order, RefPart const &refpart, T_Element const &element)
Definition Integrators.H:493
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp6_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, RefPart const &refpart, T_Element const &element)
Definition Integrators.H:292
@ 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::ParticleReal pt
energy, normalized by rest energy
Definition ReferenceParticle.H:42
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal rigidity_Tm() const
Definition ReferenceParticle.H:260
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta() const
Definition ReferenceParticle.H:151
Definition ExactQuad.H:44
void compute_constants(RefPart const &refpart)
Definition ExactQuad.H:113
amrex::ParticleReal m_ibetgam2
beta*gamma^2
Definition ExactQuad.H:573
amrex::ParticleReal m_slice_ds
number of integration steps per slice
Definition ExactQuad.H:571
int m_int_order
unit specification for quad strength
Definition ExactQuad.H:565
int m_mapsteps
order used for the symplectic integration (2 or 4)
Definition ExactQuad.H:566
static constexpr int DEFAULT_int_order
Definition ExactQuad.H:49
ExactQuad(amrex::ParticleReal ds, amrex::ParticleReal k, int unit=DEFAULT_unit, amrex::ParticleReal dx=DEFAULT_dx, amrex::ParticleReal dy=DEFAULT_dy, amrex::ParticleReal rotation_degree=DEFAULT_rotation_degree, amrex::ParticleReal aperture_x=DEFAULT_aperture_x, amrex::ParticleReal aperture_y=DEFAULT_aperture_y, int int_order=DEFAULT_int_order, int mapsteps=DEFAULT_mapsteps, int nslice=DEFAULT_nslice, std::optional< std::string > name=DEFAULT_name)
Definition ExactQuad.H:78
amrex::ParticleReal m_omega
quadrupole strength in 1/m^2
Definition ExactQuad.H:577
amrex::ParticleReal m_ibeta
beta
Definition ExactQuad.H:575
static constexpr int DEFAULT_mapsteps
Definition ExactQuad.H:50
static constexpr int DEFAULT_unit
Definition ExactQuad.H:48
amrex::ParticleReal m_beta
1 / m_betgam2
Definition ExactQuad.H:574
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 const &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:152
amrex::ParticleReal m_g
1 / m_beta
Definition ExactQuad.H:576
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map2(amrex::ParticleReal const tau, amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal &zeval, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:289
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map1(amrex::ParticleReal const tau, amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal &zeval, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:207
ImpactXParticleContainer::ParticleType PType
Definition ExactQuad.H:46
int m_unit
quadrupole strength in 1/m^2 (or T/m)
Definition ExactQuad.H:564
amrex::ParticleReal m_k
Definition ExactQuad.H:563
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:450
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map3(amrex::ParticleReal const tau, amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::SmallVector< T_Real, 3, 1 > &particle_spin, amrex::ParticleReal &zeval, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:335
void reverse()
Definition ExactQuad.H:101
amrex::ParticleReal m_betgam2
m_ds / nslice();
Definition ExactQuad.H:572
static constexpr auto type
Definition ExactQuad.H:45
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void spin_and_phasespace_push(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_Real &AMREX_RESTRICT sx, T_Real &AMREX_RESTRICT sy, T_Real &AMREX_RESTRICT sz, T_IdCpu const &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:514
Definition alignment.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:193
static constexpr amrex::ParticleReal DEFAULT_dy
Definition alignment.H:34
static constexpr amrex::ParticleReal DEFAULT_dx
Definition alignment.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:183
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 rotate_aligned_map(Map6x6 const &R) const
Definition alignment.H:267
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:43
static constexpr amrex::ParticleReal DEFAULT_rotation_degree
Definition alignment.H:35
Definition beamoptic.H:567
Definition lineartransport.H:50
static constexpr std::nullopt_t DEFAULT_name
Definition named.H:30
AMREX_GPU_HOST Named(std::optional< std::string > name)
Definition named.H:59
AMREX_FORCE_INLINE std::string name() const
Definition named.H:124
Definition nofinalize.H:22
Definition pipeaperture.H:26
static constexpr amrex::ParticleReal DEFAULT_aperture_x
Definition pipeaperture.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_x() const
Definition pipeaperture.H:93
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_y() const
Definition pipeaperture.H:104
static constexpr amrex::ParticleReal DEFAULT_aperture_y
Definition pipeaperture.H:28
PipeAperture(amrex::ParticleReal aperture_x, amrex::ParticleReal aperture_y)
Definition pipeaperture.H:35
Definition spintransport.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void tbmt_precession_vector(T_Real const &AMREX_RESTRICT x, T_Real const &AMREX_RESTRICT ux, T_Real const &AMREX_RESTRICT uy, T_Real const &AMREX_RESTRICT uz, T_Real const &AMREX_RESTRICT gamma, amrex::ParticleReal const &AMREX_RESTRICT h, amrex::ParticleReal const &AMREX_RESTRICT gyro_anomaly, T_Real const &AMREX_RESTRICT Bx, T_Real const &AMREX_RESTRICT By, T_Real const &AMREX_RESTRICT Bz, T_Real const &AMREX_RESTRICT Ex, T_Real const &AMREX_RESTRICT Ey, T_Real const &AMREX_RESTRICT Ez, T_Real &AMREX_RESTRICT Omegax, T_Real &AMREX_RESTRICT Omegay, T_Real &AMREX_RESTRICT Omegaz) const
Definition spintransport.H:121
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void rotate_spin(T_Real const &AMREX_RESTRICT lambdax, T_Real const &AMREX_RESTRICT lambday, T_Real const &AMREX_RESTRICT lambdaz, T_Real &AMREX_RESTRICT sx, T_Real &AMREX_RESTRICT sy, T_Real &AMREX_RESTRICT sz) const
Definition spintransport.H:48
static constexpr int DEFAULT_nslice
Definition thick.H:25
Thick(amrex::ParticleReal ds, int nslice)
Definition thick.H:32
amrex::ParticleReal m_ds
Definition thick.H:70
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition thick.H:55
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition thick.H:45