10#ifndef IMPACTX_CHRQUAD_H
11#define IMPACTX_CHRQUAD_H
44 static constexpr auto type =
"ChrQuad";
95 using BeamOptic::operator();
109 Alignment::compute_constants(refpart);
135 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
153 T_Real
const xout = x;
154 T_Real
const yout = y;
155 T_Real
const tout =
t;
158 T_Real
const delta1 =
sqrt(1_prt - 2_prt * pt /
m_beta + powi<2>(pt));
159 T_Real
const delta = delta1 - 1_prt;
178 bool const focusing =
m_g > 0_prt;
184 T_Real
const ax = focusing ? -1_prt : 1_prt;
188 T_Real
const w = omega * delta1;
190 T_Real
const R12 = sx / w;
191 T_Real
const R21 = ax * w * sx;
192 T_Real
const R22 = R11;
194 T_Real
const R34 = sy / w;
195 T_Real
const R43 = -ax * w * sy;
196 T_Real
const R44 = R33;
198 x = R11 * xout + R12 * px;
199 pxout = R21 * xout + R22 * px;
200 y = R33 * yout + R34 * py;
201 pyout = R43 * yout + R44 * py;
206 T_Real
const q1 = focusing ? xout : yout;
207 T_Real
const q2 = focusing ? yout : xout;
208 T_Real
const p1 = focusing ? px : py;
209 T_Real
const p2 = focusing ? py : px;
212 T_Real
const term = pt + delta /
m_beta;
213 T_Real
const t0 = tout - term *
m_slice_ds / delta1;
215 T_Real
const term1 = -(powi<2>(p2) + powi<2>(q2) * powi<2>(w)) * sinh(2_prt *
m_slice_ds * omega);
216 T_Real
const term2 = -(powi<2>(p1) - powi<2>(q1) * powi<2>(w)) * sin(2_prt *
m_slice_ds * omega);
217 T_Real
const term3 = -2_prt * q2 * p2 * w * cosh(2_prt *
m_slice_ds * omega);
218 T_Real
const term4 = -2_prt * q1 * p1 * w * cos(2_prt *
m_slice_ds * omega);
219 T_Real
const term5 = 2_prt * omega * (
220 q1 * p1 * delta1 + q2 * p2 * delta1
222 -(powi<2>(q1) - powi<2>(q2)) * powi<2>(w) *
m_slice_ds
224 t = t0 + (-1_prt +
m_beta * pt)
225 / (8_prt *
m_beta * powi<3>(delta1) * omega)
226 * (term1 + term2 + term3 + term4 + term5);
239 T_Real term = 2_prt * powi<2>(pt) + powi<2>(px) + powi<2>(py);
240 term = 2_prt - 4_prt *
m_beta * pt + powi<2>(
m_beta) * term;
241 term = -2_prt + powi<2>(refpart.gamma()) * term;
242 term = (-1_prt +
m_beta * pt) * term;
282 refpart.x = x + step * px;
283 refpart.y = y + step * py;
284 refpart.z = z + step * pz;
285 refpart.t =
t - step * pt;
288 refpart.s =
s + slice_ds;
305 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
326 T_Real
const delta1 =
sqrt(1_prt - 2_prt * pt /
m_beta + powi<2>(pt));
327 T_Real
const inv_delta1 = 1_prt / delta1;
330 T_Real
const gamma = refpart.gamma() * (1_prt -
m_beta * pt);
331 T_Real
const gyro_const = 1_prt + refpart.gyromagnetic_anomaly * gamma;
335 T_Real
const omega =
sqrt(
abs(
m_g) * inv_delta1);
340 T_Real
const sinh_omega_ds = sinh(omega_ds);
341 T_Real
const cosh_omega_ds = cosh(omega_ds);
350 bool const focusing =
m_g > 0.0_prt;
352 T_Real
const fac_x = focusing ? (1_prt - cos_omega_ds) : (cosh_omega_ds - 1_prt);
353 T_Real
const fac_y = focusing ? (cosh_omega_ds - 1_prt) : (1_prt - cos_omega_ds);
355 T_Real
const sin_x = focusing ? sin_omega_ds : sinh_omega_ds;
356 T_Real
const sin_y = focusing ? sinh_omega_ds : sin_omega_ds;
358 T_Real
const sgn = focusing ? -gyro_const : gyro_const;
360 T_Real
const lambdax = sgn * (py * inv_delta1 * fac_y + y * omega * sin_y);
361 T_Real
const lambday = sgn * (px * inv_delta1 * fac_x + x * omega * sin_x);
362 T_Real
const lambdaz = 0_prt;
365 rotate_spin(lambdax, lambday, lambdaz, sx, sy, sz);
368 (*this)(x, y,
t, px, py, pt, idcpu, refpart);
372 using LinearTransport::operator();
403 R(1,1) = std::cos(omega*slice_ds);
404 R(1,2) = std::sin(omega*slice_ds)/omega;
405 R(2,1) = -omega*std::sin(omega*slice_ds);
406 R(2,2) = std::cos(omega*slice_ds);
407 R(3,3) = std::cosh(omega*slice_ds);
408 R(3,4) = std::sinh(omega*slice_ds)/omega;
409 R(4,3) = omega*std::sinh(omega*slice_ds);
410 R(4,4) = std::cosh(omega*slice_ds);
411 R(5,6) = slice_ds/betgam2;
412 }
else if (g < 0.0) {
413 R(1,1) = std::cosh(omega*slice_ds);
414 R(1,2) = std::sinh(omega*slice_ds)/omega;
415 R(2,1) = omega*std::sinh(omega*slice_ds);
416 R(2,2) = std::cosh(omega*slice_ds);
417 R(3,3) = std::cos(omega*slice_ds);
418 R(3,4) = std::sin(omega*slice_ds)/omega;
419 R(4,3) = -omega*std::sin(omega*slice_ds);
420 R(4,4) = std::cos(omega*slice_ds);
421 R(5,6) = slice_ds/betgam2;
#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
__host__ __device__ std::pair< double, double > sincos(double x)
__host__ __device__ T abs(const GpuComplex< T > &a_z) noexcept
__host__ __device__ GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
@ 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 rigidity_Tm() const
Definition ReferenceParticle.H:260
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta() const
Definition ReferenceParticle.H:151
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal gamma() const
Definition ReferenceParticle.H:139
int m_unit
quadrupole strength in 1/m^2 (or T/m)
Definition ChrQuad.H:433
amrex::ParticleReal m_const1
Definition ChrQuad.H:441
amrex::ParticleReal m_slice_ds
unit specification for quad strength
Definition ChrQuad.H:438
ImpactXParticleContainer::ParticleType PType
Definition ChrQuad.H:45
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ChrQuad.H:381
void compute_constants(RefPart const &refpart)
Definition ChrQuad.H:104
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 const &AMREX_RESTRICT pt, T_IdCpu const &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition ChrQuad.H:137
static constexpr int DEFAULT_unit
Definition ChrQuad.H:47
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 const &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 ChrQuad.H:307
amrex::ParticleReal m_k
Definition ChrQuad.H:432
static constexpr auto type
Definition ChrQuad.H:44
ChrQuad(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 nslice=DEFAULT_nslice, std::optional< std::string > name=DEFAULT_name)
Definition ChrQuad.H:71
void reverse()
Definition ChrQuad.H:92
amrex::ParticleReal m_beta
m_ds / nslice();
Definition ChrQuad.H:439
amrex::ParticleReal m_g
Definition ChrQuad.H:440
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 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