10#ifndef IMPACTX_EXACTQUAD_H
11#define IMPACTX_EXACTQUAD_H
44 static constexpr auto type =
"ExactQuad";
74 amrex::ParticleReal
ds,
75 amrex::ParticleReal k,
77 amrex::ParticleReal
dx = 0,
78 amrex::ParticleReal
dy = 0,
79 amrex::ParticleReal rotation_degree = 0,
85 std::optional<std::string>
name = std::nullopt
96 using BeamOptic::operator();
107 using namespace amrex::literals;
110 Alignment::compute_constants(refpart);
116 amrex::ParticleReal
const pt_ref = refpart.
pt;
143 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
156 using namespace amrex::literals;
166 amrex::ParticleReal
const zin = 0_prt;
210 template<
typename T_Real>
212 void map1 (amrex::ParticleReal
const tau,
214 amrex::ParticleReal & zeval)
const
216 using namespace amrex::literals;
218 T_Real
const x = particle(1);
219 T_Real
const px = particle(2);
220 T_Real
const y = particle(3);
221 T_Real
const py = particle(4);
222 T_Real
const t = particle(5);
223 T_Real
const pt = particle(6);
232 amrex::ParticleReal
const sin_omega_ds = sin(
m_omega*tau);
233 amrex::ParticleReal
const cos_omega_ds = cos(
m_omega*tau);
234 amrex::ParticleReal
const sinh_omega_ds = sinh(
m_omega*tau);
235 amrex::ParticleReal
const cosh_omega_ds = cosh(
m_omega*tau);
236 amrex::ParticleReal
const slice_bg = tau /
m_betgam2;
241 xout = cos_omega_ds*x + sin_omega_ds/
m_omega*px;
242 pxout = -
m_omega*sin_omega_ds*x + cos_omega_ds*px;
244 yout = cosh_omega_ds*y + sinh_omega_ds/
m_omega*py;
245 pyout =
m_omega*sinh_omega_ds*y + cosh_omega_ds*py;
247 tout =
t + (slice_bg)*pt;
249 }
else if (
m_g < 0.0_prt)
252 xout = cosh_omega_ds*x + sinh_omega_ds/
m_omega*px;
253 pxout =
m_omega*sinh_omega_ds*x + cosh_omega_ds*px;
255 yout = cos_omega_ds*y + sin_omega_ds/
m_omega*py;
256 pyout = -
m_omega*sin_omega_ds*y + cos_omega_ds*py;
258 tout =
t + slice_bg*pt;
266 tout =
t + slice_bg * pt;
289 template<
typename T_Real>
291 void map2 (amrex::ParticleReal
const tau,
293 amrex::ParticleReal & zeval)
const
295 using namespace amrex::literals;
299 T_Real
const x = particle(1);
300 T_Real
const px = particle(2);
301 T_Real
const y = particle(3);
302 T_Real
const py = particle(4);
303 T_Real
const t = particle(5);
304 T_Real
const pt = particle(6);
307 T_Real
const inv_pzden = 1_prt / sqrt(
315 particle(1) = x + tau * px * (-1_prt + inv_pzden);
317 particle(3) = y + tau * py * (-1_prt + inv_pzden);
333 using namespace amrex::literals;
337 amrex::ParticleReal
const x = refpart.x;
338 amrex::ParticleReal
const px = refpart.px;
339 amrex::ParticleReal
const y = refpart.y;
340 amrex::ParticleReal
const py = refpart.py;
341 amrex::ParticleReal
const z = refpart.z;
342 amrex::ParticleReal
const pz = refpart.pz;
343 amrex::ParticleReal
const t = refpart.t;
344 amrex::ParticleReal
const pt = refpart.pt;
345 amrex::ParticleReal
const s = refpart.s;
348 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
351 amrex::ParticleReal
const step = slice_ds / std::sqrt(powi<2>(pt)-1.0_prt);
354 refpart.x = x + step*px;
355 refpart.y = y + step*py;
356 refpart.z = z + step*pz;
357 refpart.t =
t - step*pt;
360 refpart.s =
s + slice_ds;
371 using namespace amrex::literals;
375 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
378 amrex::ParticleReal
const pt_ref = refpart.pt;
379 amrex::ParticleReal
const betgam2 = powi<2>(pt_ref) - 1.0_prt;
382 amrex::ParticleReal
const omega = std::sqrt(std::abs(
m_k));
388 R(1,1) = std::cos(omega*slice_ds);
389 R(1,2) = std::sin(omega*slice_ds)/omega;
390 R(2,1) = -omega*std::sin(omega*slice_ds);
391 R(2,2) = std::cos(omega*slice_ds);
392 R(3,3) = std::cosh(omega*slice_ds);
393 R(3,4) = std::sinh(omega*slice_ds)/omega;
394 R(4,3) = omega*std::sinh(omega*slice_ds);
395 R(4,4) = std::cosh(omega*slice_ds);
396 R(5,6) = slice_ds/betgam2;
397 }
else if (
m_k < 0.0) {
398 R(1,1) = std::cosh(omega*slice_ds);
399 R(1,2) = std::sinh(omega*slice_ds)/omega;
400 R(2,1) = omega*std::sinh(omega*slice_ds);
401 R(2,2) = std::cosh(omega*slice_ds);
402 R(3,3) = std::cos(omega*slice_ds);
403 R(3,4) = std::sin(omega*slice_ds)/omega;
404 R(4,3) = -omega*std::sin(omega*slice_ds);
405 R(4,4) = std::cos(omega*slice_ds);
406 R(5,6) = slice_ds/betgam2;
417 using LinearTransport::operator();
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
T_ParticleType ParticleType
constexpr T powi(T x) noexcept
SmallMatrix< T, N, 1, Order::F, StartIndex > SmallVector
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, T_Element const &element)
Definition Integrators.H:225
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, T_Element const &element)
Definition Integrators.H:284
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, T_Element const &element)
Definition Integrators.H:178
@ 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:31
amrex::ParticleReal pt
energy, normalized by rest energy
Definition ReferenceParticle.H:40
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal rigidity_Tm() const
Definition ReferenceParticle.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta() const
Definition ReferenceParticle.H:94
void compute_constants(RefPart const &refpart)
Definition ExactQuad.H:105
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:73
amrex::ParticleReal m_ibetgam2
beta*gamma^2
Definition ExactQuad.H:429
amrex::ParticleReal m_slice_ds
number of integration steps per slice
Definition ExactQuad.H:427
int m_int_order
unit specification for quad strength
Definition ExactQuad.H:421
int m_mapsteps
order used for the symplectic integration (2 or 4)
Definition ExactQuad.H:422
amrex::ParticleReal m_omega
quadrupole strength in 1/m^2
Definition ExactQuad.H:433
amrex::ParticleReal m_ibeta
beta
Definition ExactQuad.H:431
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map1(amrex::ParticleReal const tau, amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal &zeval) const
Definition ExactQuad.H:212
amrex::ParticleReal m_beta
1 / m_betgam2
Definition ExactQuad.H:430
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map2(amrex::ParticleReal const tau, amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal &zeval) const
Definition ExactQuad.H:291
amrex::ParticleReal m_g
1 / m_beta
Definition ExactQuad.H:432
ImpactXParticleContainer::ParticleType PType
Definition ExactQuad.H:45
int m_unit
quadrupole strength in 1/m^2 (or T/m)
Definition ExactQuad.H:420
amrex::ParticleReal m_k
Definition ExactQuad.H:419
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ExactQuad.H:369
amrex::ParticleReal m_betgam2
m_ds / nslice();
Definition ExactQuad.H:428
static constexpr auto type
Definition ExactQuad.H:44
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 ExactQuad.H:145
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:219
Definition lineartransport.H:29
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:58
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