10 #ifndef IMPACTX_CFBEND_H
11 #define IMPACTX_CFBEND_H
31 static constexpr
auto name =
"CFbend";
46 amrex::ParticleReal
const ds,
47 amrex::ParticleReal
const rc,
48 amrex::ParticleReal
const k,
55 using BeamOptic::operator();
67 PType& AMREX_RESTRICT p,
68 amrex::ParticleReal & AMREX_RESTRICT px,
69 amrex::ParticleReal & AMREX_RESTRICT py,
70 amrex::ParticleReal & AMREX_RESTRICT pt,
73 using namespace amrex::literals;
76 amrex::ParticleReal
const x = p.pos(
RealAoS::x);
77 amrex::ParticleReal
const y = p.pos(
RealAoS::y);
78 amrex::ParticleReal
const t = p.pos(
RealAoS::t);
81 amrex::ParticleReal pxout = px;
82 amrex::ParticleReal pyout = py;
83 amrex::ParticleReal ptout = pt;
86 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
89 amrex::ParticleReal
const pt_ref = refpart.
pt;
90 amrex::ParticleReal
const betgam2 =
pow(pt_ref, 2) - 1.0_prt;
91 amrex::ParticleReal
const bet =
sqrt(betgam2/(1.0_prt + betgam2));
94 amrex::ParticleReal
const gx =
m_k +
pow(
m_rc,-2);
95 amrex::ParticleReal
const omegax =
sqrt(std::abs(gx));
99 amrex::ParticleReal
const sinx = sin(omegax * slice_ds);
100 amrex::ParticleReal
const cosx = cos(omegax * slice_ds);
101 amrex::ParticleReal
const r56 = slice_ds/betgam2
102 + (sinx - omegax*slice_ds)/(gx*omegax*
pow(bet,2)*
pow(
m_rc,2));
105 p.pos(
RealAoS::x) = cosx*x + sinx/omegax*px - (1.0_prt - cosx)/(gx*bet*
m_rc)*pt;
106 pxout = -omegax*sinx*x + cosx*px - sinx/(omegax*bet*
m_rc)*pt;
113 amrex::ParticleReal
const sinhx = sinh(omegax * slice_ds);
114 amrex::ParticleReal
const coshx = cosh(omegax * slice_ds);
115 amrex::ParticleReal
const r56 = slice_ds/betgam2
116 + (sinhx - omegax*slice_ds)/(gx*omegax*
pow(bet,2)*
pow(
m_rc,2));
119 p.pos(
RealAoS::x) = coshx*x + sinhx/omegax*px - (1.0_prt - coshx)/(gx*bet*
m_rc)*pt;
120 pxout = omegax*sinhx*x + coshx*px - sinhx/(omegax*bet*
m_rc)*pt;
128 amrex::ParticleReal
const gy = -
m_k;
129 amrex::ParticleReal
const omegay =
sqrt(std::abs(gy));
133 amrex::ParticleReal
const siny = sin(omegay * slice_ds);
134 amrex::ParticleReal
const cosy = cos(omegay * slice_ds);
138 pyout = -omegay*siny*y + cosy*py;
142 amrex::ParticleReal
const sinhy = sinh(omegay * slice_ds);
143 amrex::ParticleReal
const coshy = cosh(omegay * slice_ds);
146 p.pos(
RealAoS::y) = coshy*y + sinhy/omegay*py;
147 pyout = omegay*sinhy*y + coshy*py;
163 using namespace amrex::literals;
166 amrex::ParticleReal
const x = refpart.x;
167 amrex::ParticleReal
const px = refpart.px;
168 amrex::ParticleReal
const y = refpart.y;
169 amrex::ParticleReal
const py = refpart.py;
170 amrex::ParticleReal
const z = refpart.z;
171 amrex::ParticleReal
const pz = refpart.pz;
172 amrex::ParticleReal
const t = refpart.t;
173 amrex::ParticleReal
const pt = refpart.pt;
174 amrex::ParticleReal
const s = refpart.s;
177 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
180 amrex::ParticleReal
const theta = slice_ds/
m_rc;
181 amrex::ParticleReal
const B =
sqrt(
pow(pt,2)-1.0_prt)/
m_rc;
185 amrex::ParticleReal
const sin_theta = sin(theta);
186 amrex::ParticleReal
const cos_theta = cos(theta);
189 refpart.px = px*cos_theta - pz*sin_theta;
191 refpart.pz = pz*cos_theta + px*sin_theta;
194 refpart.x = x + (refpart.pz - pz)/B;
195 refpart.y = y + (theta/B)*py;
196 refpart.z = z - (refpart.px - px)/B;
197 refpart.t = t - (theta/B)*pt;
200 refpart.s =
s + slice_ds;
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
T_ParticleType ParticleType
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Definition: ImpactX.cpp:33
CFbend(amrex::ParticleReal const ds, amrex::ParticleReal const rc, amrex::ParticleReal const k, int const nslice)
Definition: CFbend.H:45
amrex::ParticleReal m_rc
Definition: CFbend.H:204
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(PType &AMREX_RESTRICT p, amrex::ParticleReal &AMREX_RESTRICT px, amrex::ParticleReal &AMREX_RESTRICT py, amrex::ParticleReal &AMREX_RESTRICT pt, RefPart const &refpart) const
Definition: CFbend.H:66
amrex::ParticleReal m_k
bend radius in m
Definition: CFbend.H:205
ImpactXParticleContainer::ParticleType PType
Definition: CFbend.H:32
static constexpr auto name
Definition: CFbend.H:31
@ x
position in x [m] (at fixed s OR fixed t)
Definition: ImpactXParticleContainer.H:42
@ y
position in y [m] (at fixed s OR fixed t)
Definition: ImpactXParticleContainer.H:43
@ t
c * time-of-flight [m] (at fixed s)
Definition: ImpactXParticleContainer.H:44
Definition: ReferenceParticle.H:30
amrex::ParticleReal pt
energy, normalized by rest energy
Definition: ReferenceParticle.H:39
Definition: beamoptic.H:135
Definition: nofinalize.H:22
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: thick.H:50
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: thick.H:40
amrex::ParticleReal m_ds
Definition: thick.H:56
Thick(amrex::ParticleReal const ds, int const nslice)
Definition: thick.H:30