10#ifndef IMPACTX_EXACTQUAD_H
11#define IMPACTX_EXACTQUAD_H
46 static constexpr auto type =
"ExactQuad";
87 std::optional<std::string>
name = std::nullopt
101 using BeamOptic::operator();
115 Alignment::compute_constants(refpart);
147 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
202 template<
typename T_Real>
212 T_Real
const x = particle(1);
213 T_Real
const px = particle(2);
214 T_Real
const y = particle(3);
215 T_Real
const py = particle(4);
216 T_Real
const t = particle(5);
217 T_Real
const pt = particle(6);
235 xout = cos_omega_ds*x + sin_omega_ds/
m_omega*px;
236 pxout = -
m_omega*sin_omega_ds*x + cos_omega_ds*px;
238 yout = cosh_omega_ds*y + sinh_omega_ds/
m_omega*py;
239 pyout =
m_omega*sinh_omega_ds*y + cosh_omega_ds*py;
241 tout =
t + slice_bg*pt;
243 }
else if (
m_g < 0.0_prt)
246 xout = cosh_omega_ds*x + sinh_omega_ds/
m_omega*px;
247 pxout =
m_omega*sinh_omega_ds*x + cosh_omega_ds*px;
249 yout = cos_omega_ds*y + sin_omega_ds/
m_omega*py;
250 pyout = -
m_omega*sin_omega_ds*y + cos_omega_ds*py;
252 tout =
t + slice_bg*pt;
260 tout =
t + slice_bg * pt;
284 template<
typename T_Real>
295 T_Real
const x = particle(1);
296 T_Real
const px = particle(2);
297 T_Real
const y = particle(3);
298 T_Real
const py = particle(4);
299 T_Real
const t = particle(5);
300 T_Real
const pt = particle(6);
303 T_Real
const inv_pzden = 1_prt /
sqrt(
311 particle(1) = x + tau * px * (-1_prt + inv_pzden);
313 particle(3) = y + tau * py * (-1_prt + inv_pzden);
330 template<
typename T_Real>
347 T_Real lambdax = 0_prt;
348 T_Real lambday = 0_prt;
349 T_Real lambdaz = 0_prt;
351 T_Real
const x = particle(1);
352 T_Real
const px = particle(2);
353 T_Real
const y = particle(3);
354 T_Real
const py = particle(4);
356 T_Real
const pt = particle(6);
357 T_Real sx = particle_spin(1);
358 T_Real sy = particle_spin(2);
359 T_Real sz = particle_spin(3);
362 T_Real
const Bx =
m_g * y *
m_beta * gamma_ref;
363 T_Real
const By =
m_g * x *
m_beta * gamma_ref;
364 T_Real
const Bz = 0_prt;
367 T_Real
const Ex = 0.0_prt;
368 T_Real
const Ey = 0.0_prt;
369 T_Real
const Ez = 0.0_prt;
372 T_Real
const Pnorm =
sqrt(1_prt - 2_prt * pt *
m_ibeta + pt*pt);
373 T_Real
const iPnorm = 1_prt/Pnorm;
374 T_Real
const Ps =
sqrt(Pnorm*Pnorm - px*px - py*py);
375 T_Real
const gamma = gamma_ref * (1_prt - pt*
m_beta);
376 T_Real
const ux = px * iPnorm;
377 T_Real
const uy = py * iPnorm;
378 T_Real
const uz = Ps * iPnorm;
384 tbmt_precession_vector(x,ux,uy,uz,gamma,h,gyro_anomaly,Bx,By,Bz,Ex,Ey,Ez,lambdax,lambday,lambdaz);
395 particle_spin(1) = sx;
396 particle_spin(2) = sy;
397 particle_spin(3) = sz;
433 refpart.x = x + step*px;
434 refpart.y = y + step*py;
435 refpart.z = z + step*pz;
436 refpart.t =
t - step*pt;
439 refpart.s =
s + slice_ds;
467 R(1,1) = std::cos(omega*slice_ds);
468 R(1,2) = std::sin(omega*slice_ds)/omega;
469 R(2,1) = -omega*std::sin(omega*slice_ds);
470 R(2,2) = std::cos(omega*slice_ds);
471 R(3,3) = std::cosh(omega*slice_ds);
472 R(3,4) = std::sinh(omega*slice_ds)/omega;
473 R(4,3) = omega*std::sinh(omega*slice_ds);
474 R(4,4) = std::cosh(omega*slice_ds);
475 R(5,6) = slice_ds/betgam2;
476 }
else if (
m_k < 0.0_prt) {
477 R(1,1) = std::cosh(omega*slice_ds);
478 R(1,2) = std::sinh(omega*slice_ds)/omega;
479 R(2,1) = omega*std::sinh(omega*slice_ds);
480 R(2,2) = std::cosh(omega*slice_ds);
481 R(3,3) = std::cos(omega*slice_ds);
482 R(3,4) = std::sin(omega*slice_ds)/omega;
483 R(4,3) = -omega*std::sin(omega*slice_ds);
484 R(4,4) = std::cos(omega*slice_ds);
485 R(5,6) = slice_ds/betgam2;
511 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
554 sx = particle_spin(1);
555 sy = particle_spin(2);
556 sz = particle_spin(3);
560 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:45
void compute_constants(RefPart const &refpart)
Definition ExactQuad.H:110
ExactQuad(amrex::ParticleReal ds, amrex::ParticleReal k, int unit, amrex::ParticleReal dx=0, amrex::ParticleReal dy=0, amrex::ParticleReal rotation_degree=0, amrex::ParticleReal aperture_x=0, amrex::ParticleReal aperture_y=0, int int_order=2, int mapsteps=5, int nslice=1, std::optional< std::string > name=std::nullopt)
Definition ExactQuad.H:75
amrex::ParticleReal m_ibetgam2
beta*gamma^2
Definition ExactQuad.H:572
amrex::ParticleReal m_slice_ds
number of integration steps per slice
Definition ExactQuad.H:570
int m_int_order
unit specification for quad strength
Definition ExactQuad.H:564
int m_mapsteps
order used for the symplectic integration (2 or 4)
Definition ExactQuad.H:565
amrex::ParticleReal m_omega
quadrupole strength in 1/m^2
Definition ExactQuad.H:576
amrex::ParticleReal m_ibeta
beta
Definition ExactQuad.H:574
amrex::ParticleReal m_beta
1 / m_betgam2
Definition ExactQuad.H:573
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:149
amrex::ParticleReal m_g
1 / m_beta
Definition ExactQuad.H:575
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:286
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:204
ImpactXParticleContainer::ParticleType PType
Definition ExactQuad.H:47
int m_unit
quadrupole strength in 1/m^2 (or T/m)
Definition ExactQuad.H:563
amrex::ParticleReal m_k
Definition ExactQuad.H:562
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:448
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:332
void reverse()
Definition ExactQuad.H:98
amrex::ParticleReal m_betgam2
m_ds / nslice();
Definition ExactQuad.H:571
static constexpr auto type
Definition ExactQuad.H:46
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:513
Definition alignment.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:189
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:179
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 rotate_aligned_map(Map6x6 const &R) const
Definition alignment.H:263
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:39
Definition beamoptic.H:529
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 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
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
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