10 #ifndef IMPACTX_CFBEND_H
11 #define IMPACTX_CFBEND_H
34 static constexpr
auto name =
"CFbend";
52 amrex::ParticleReal
ds,
53 amrex::ParticleReal rc,
54 amrex::ParticleReal k,
55 amrex::ParticleReal
dx = 0,
56 amrex::ParticleReal
dy = 0,
57 amrex::ParticleReal rotation_degree = 0,
67 using BeamOptic::operator();
79 PType& AMREX_RESTRICT p,
80 amrex::ParticleReal & AMREX_RESTRICT px,
81 amrex::ParticleReal & AMREX_RESTRICT py,
82 amrex::ParticleReal & AMREX_RESTRICT pt,
85 using namespace amrex::literals;
91 amrex::ParticleReal
const x = p.pos(
RealAoS::x);
92 amrex::ParticleReal
const y = p.pos(
RealAoS::y);
96 amrex::ParticleReal pxout = px;
97 amrex::ParticleReal pyout = py;
98 amrex::ParticleReal ptout = pt;
101 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
104 amrex::ParticleReal
const pt_ref = refpart.
pt;
105 amrex::ParticleReal
const betgam2 =
pow(pt_ref, 2) - 1.0_prt;
106 amrex::ParticleReal
const bet =
sqrt(betgam2/(1.0_prt + betgam2));
109 amrex::ParticleReal
const gx =
m_k +
pow(
m_rc,-2);
110 amrex::ParticleReal
const omegax =
sqrt(std::abs(gx));
115 amrex::ParticleReal
const r56 = slice_ds/betgam2
116 + (sinx - omegax*slice_ds)/(gx*omegax*
pow(bet,2)*
pow(
m_rc,2));
119 p.pos(
RealAoS::x) = cosx*x + sinx/omegax*px - (1.0_prt - cosx)/(gx*bet*
m_rc)*pt;
120 pxout = -omegax*sinx*x + cosx*px - sinx/(omegax*bet*
m_rc)*pt;
127 amrex::ParticleReal
const sinhx = sinh(omegax * slice_ds);
128 amrex::ParticleReal
const coshx = cosh(omegax * slice_ds);
129 amrex::ParticleReal
const r56 = slice_ds/betgam2
130 + (sinhx - omegax*slice_ds)/(gx*omegax*
pow(bet,2)*
pow(
m_rc,2));
133 p.pos(
RealAoS::x) = coshx*x + sinhx/omegax*px - (1.0_prt - coshx)/(gx*bet*
m_rc)*pt;
134 pxout = omegax*sinhx*x + coshx*px - sinhx/(omegax*bet*
m_rc)*pt;
142 amrex::ParticleReal
const gy = -
m_k;
143 amrex::ParticleReal
const omegay =
sqrt(std::abs(gy));
151 pyout = -omegay*siny*y + cosy*py;
155 amrex::ParticleReal
const sinhy = sinh(omegay * slice_ds);
156 amrex::ParticleReal
const coshy = cosh(omegay * slice_ds);
159 p.pos(
RealAoS::y) = coshy*y + sinhy/omegay*py;
160 pyout = omegay*sinhy*y + coshy*py;
179 using namespace amrex::literals;
182 amrex::ParticleReal
const x = refpart.x;
183 amrex::ParticleReal
const px = refpart.px;
184 amrex::ParticleReal
const y = refpart.y;
185 amrex::ParticleReal
const py = refpart.py;
186 amrex::ParticleReal
const z = refpart.z;
187 amrex::ParticleReal
const pz = refpart.pz;
188 amrex::ParticleReal
const t = refpart.t;
189 amrex::ParticleReal
const pt = refpart.pt;
190 amrex::ParticleReal
const s = refpart.s;
193 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
196 amrex::ParticleReal
const theta = slice_ds/
m_rc;
197 amrex::ParticleReal
const B =
sqrt(
pow(pt,2)-1.0_prt)/
m_rc;
203 refpart.px = px*cos_theta - pz*sin_theta;
205 refpart.pz = pz*cos_theta + px*sin_theta;
208 refpart.x = x + (refpart.pz - pz)/B;
209 refpart.y = y + (theta/B)*py;
210 refpart.z = z - (refpart.px - px)/B;
211 refpart.t =
t - (theta/B)*pt;
214 refpart.s =
s + slice_ds;
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
T_ParticleType ParticleType
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::pair< double, double > sincos(double x)
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:35
@ t
fixed t as the independent variable
CFbend(amrex::ParticleReal ds, amrex::ParticleReal rc, amrex::ParticleReal k, amrex::ParticleReal dx=0, amrex::ParticleReal dy=0, amrex::ParticleReal rotation_degree=0, int nslice=1)
Definition: CFbend.H:51
amrex::ParticleReal m_rc
Definition: CFbend.H:218
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:78
amrex::ParticleReal m_k
bend radius in m
Definition: CFbend.H:219
ImpactXParticleContainer::ParticleType PType
Definition: CFbend.H:35
static constexpr auto name
Definition: CFbend.H:34
@ x
position in x [m] (at fixed s OR fixed t)
Definition: ImpactXParticleContainer.H:49
@ y
position in y [m] (at fixed s OR fixed t)
Definition: ImpactXParticleContainer.H:50
@ t
c * time-of-flight [m] (at fixed s)
Definition: ImpactXParticleContainer.H:51
Definition: ReferenceParticle.H:30
amrex::ParticleReal pt
energy, normalized by rest energy
Definition: ReferenceParticle.H:39
Definition: alignment.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_out(amrex::ParticleReal &AMREX_RESTRICT x, amrex::ParticleReal &AMREX_RESTRICT y, amrex::ParticleReal &AMREX_RESTRICT px, amrex::ParticleReal &AMREX_RESTRICT py) const
Definition: alignment.H:91
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition: alignment.H:120
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_in(amrex::ParticleReal &AMREX_RESTRICT x, amrex::ParticleReal &AMREX_RESTRICT y, amrex::ParticleReal &AMREX_RESTRICT px, amrex::ParticleReal &AMREX_RESTRICT py) const
Definition: alignment.H:61
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition: alignment.H:130
Definition: beamoptic.H:135
Definition: nofinalize.H:22
Thick(amrex::ParticleReal ds, int nslice)
Definition: thick.H:30
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
amrex::ParticleReal m_ds
Definition: thick.H:58