10#ifndef IMPACTX_CHRPLASMALENS_H
11#define IMPACTX_CHRPLASMALENS_H
45 static constexpr auto type =
"ChrPlasmaLens";
78 std::optional<std::string>
name = std::nullopt
92 using BeamOptic::operator();
106 Alignment::compute_constants(refpart);
133 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
151 T_Real
const delta1 =
sqrt(1_prt - 2_prt*pt/
m_beta + powi<2>(pt));
152 T_Real
const delta = delta1 - 1_prt;
171 T_Real
const p1 = px;
172 T_Real
const p2 = py;
179 xout = cos_ods * x + sin_ods / (omega * delta1) * px;
180 pxout = -omega * delta1 * sin_ods * x + cos_ods * px;
182 yout = cos_ods * y + sin_ods / (omega * delta1) * py;
183 pyout = -omega * delta1 * sin_ods * y + cos_ods * py;
186 T_Real
const term = pt + delta/
m_beta;
189 T_Real
const w = omega*delta1;
190 T_Real
const term1 = -(powi<2>(p2) - powi<2>(q2) * powi<2>(w)) * sin(2_prt*
m_slice_ds*omega);
191 T_Real
const term2 = -(powi<2>(p1) - powi<2>(q1) * powi<2>(w)) * sin(2_prt*
m_slice_ds*omega);
192 T_Real
const term3 = -2_prt * q2 * p2 * w * cos(2_prt*
m_slice_ds*omega);
193 T_Real
const term4 = -2_prt * q1 * p1 * w * cos(2_prt*
m_slice_ds*omega);
194 T_Real
const term5 = 2_prt * omega * (q1*p1*delta1 + q2*p2*delta1
196 tout = t0 + (-1_prt+
m_beta*pt)
197 / (8_prt*
m_beta * powi<3>(delta1)*omega)
198 * (term1+term2+term3+term4+term5);
201 else if (
m_g < 0_prt)
207 xout = cosh_ods * x + sinh_ods / (omega * delta1) * px;
208 pxout = +omega * delta1 * sinh_ods * x + cosh_ods * px;
210 yout = cosh_ods * y + sinh_ods / (omega * delta1) * py;
211 pyout = +omega * delta1 * sinh_ods * y + cosh_ods * py;
214 T_Real
const term = pt + delta/
m_beta;
217 T_Real
const w = omega*delta1;
218 T_Real
const term1 = -(powi<2>(p2) + powi<2>(q2) * powi<2>(w)) * sinh(2_prt*
m_slice_ds*omega);
219 T_Real
const term2 = -(powi<2>(p1) + powi<2>(q1) * powi<2>(w)) * sinh(2_prt*
m_slice_ds*omega);
220 T_Real
const term3 = -2_prt * q2 * p2 * w * cosh(2_prt*
m_slice_ds*omega);
221 T_Real
const term4 = -2_prt * q1 * p1 * w * cosh(2_prt*
m_slice_ds*omega);
222 T_Real
const term5 = 2_prt * omega * (q1*p1*delta1 + q2*p2*delta1
224 tout = t0 + (-1_prt+
m_beta*pt)
225 / (8_prt*
m_beta * powi<3>(delta1)*omega)
226 * (term1+term2+term3+term4+term5);
237 T_Real term = 2_prt * powi<2>(pt) + powi<2>(px) + powi<2>(py);
238 term = 2_prt - 4_prt *
m_beta * pt + powi<2>(
m_beta) * term;
239 term = -2_prt + powi<2>(refpart.gamma())*term;
240 term = (-1_prt +
m_beta * pt) * term;
284 refpart.x = x + step*px;
285 refpart.y = y + step*py;
286 refpart.z = z + step*pz;
287 refpart.t =
t - step*pt;
290 refpart.s =
s + slice_ds;
308 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
329 T_Real lambdax = 0_prt;
330 T_Real lambday = 0_prt;
331 T_Real lambdaz = 0_prt;
334 T_Real
const delta1 =
sqrt(1_prt - 2_prt*pt/
m_beta + powi<2>(pt));
335 T_Real
const inv_delta1 = 1_prt / delta1;
338 T_Real
const gamma = refpart.gamma() * (1_prt -
m_beta*pt);
339 T_Real
const gyro_const = 1_prt + refpart.gyromagnetic_anomaly * gamma;
343 T_Real
const omega =
sqrt(
abs(
m_g)*inv_delta1);
347 T_Real
const sinh_omega_ds = sinh(omega*
m_slice_ds);
348 T_Real
const cosh_omega_ds = cosh(omega*
m_slice_ds);
354 lambdax = +gyro_const * ( py*inv_delta1*(1_prt - cos_omega_ds) + y*omega*sin_omega_ds );
355 lambday = -gyro_const * ( px*inv_delta1*(1_prt - cos_omega_ds) + x*omega*sin_omega_ds );
357 }
else if (
m_g < 0.0_prt)
361 lambdax = -gyro_const * ( py*inv_delta1*(cosh_omega_ds - 1_prt) + y*omega*sinh_omega_ds );
362 lambday = +gyro_const * ( px*inv_delta1*(cosh_omega_ds - 1_prt) + x*omega*sinh_omega_ds );
372 (*this)(x, y,
t, px, py, pt, idcpu, refpart);
378 using LinearTransport::operator();
406 R(1,1) = std::cos(omega*slice_ds);
407 R(1,2) = std::sin(omega*slice_ds)/omega;
408 R(2,1) = -omega*std::sin(omega*slice_ds);
409 R(2,2) = std::cos(omega*slice_ds);
410 R(3,3) = std::cos(omega*slice_ds);
411 R(3,4) = std::sin(omega*slice_ds)/omega;
412 R(4,3) = -omega*std::sin(omega*slice_ds);
413 R(4,4) = std::cos(omega*slice_ds);
414 R(5,6) = slice_ds/betgam2;
415 }
else if (
m_k < 0.0) {
416 R(1,1) = std::cosh(omega*slice_ds);
417 R(1,2) = std::sinh(omega*slice_ds)/omega;
418 R(2,1) = omega*std::sinh(omega*slice_ds);
419 R(2,2) = std::cosh(omega*slice_ds);
420 R(3,3) = std::cosh(omega*slice_ds);
421 R(3,4) = std::sinh(omega*slice_ds)/omega;
422 R(4,3) = omega*std::sinh(omega*slice_ds);
423 R(4,4) = std::cosh(omega*slice_ds);
424 R(5,6) = slice_ds/betgam2;
428 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
Definition ChrPlasmaLens.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 const &AMREX_RESTRICT pt, T_IdCpu const &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition ChrPlasmaLens.H:135
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 ChrPlasmaLens.H:310
int m_unit
focusing strength in 1/m^2 (or T/m)
Definition ChrPlasmaLens.H:436
static constexpr auto type
Definition ChrPlasmaLens.H:45
void compute_constants(RefPart const &refpart)
Definition ChrPlasmaLens.H:101
amrex::ParticleReal m_beta
m_ds / nslice();
Definition ChrPlasmaLens.H:442
amrex::ParticleReal m_k
Definition ChrPlasmaLens.H:435
amrex::ParticleReal m_const1
Definition ChrPlasmaLens.H:444
amrex::ParticleReal m_g
Definition ChrPlasmaLens.H:443
ChrPlasmaLens(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 nslice=1, std::optional< std::string > name=std::nullopt)
Definition ChrPlasmaLens.H:68
amrex::ParticleReal m_slice_ds
unit specification for focusing strength
Definition ChrPlasmaLens.H:441
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ChrPlasmaLens.H:387
void reverse()
Definition ChrPlasmaLens.H:89
ImpactXParticleContainer::ParticleType PType
Definition ChrPlasmaLens.H:46
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 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