10#ifndef IMPACTX_CHRPLASMALENS_H
11#define IMPACTX_CHRPLASMALENS_H
43 static constexpr auto type =
"ChrPlasmaLens";
67 amrex::ParticleReal
ds,
68 amrex::ParticleReal k,
70 amrex::ParticleReal
dx = 0,
71 amrex::ParticleReal
dy = 0,
72 amrex::ParticleReal rotation_degree = 0,
76 std::optional<std::string>
name = std::nullopt
87 using BeamOptic::operator();
98 using namespace amrex::literals;
101 Alignment::compute_constants(refpart);
128 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
141 using namespace amrex::literals;
149 T_Real
const delta1 = sqrt(1_prt - 2_prt*pt/
m_beta + powi<2>(pt));
150 T_Real
const delta = delta1 - 1_prt;
154 T_Real
const omega = sqrt(abs(
m_g)/delta1);
164 T_Real
const ptout = pt;
177 xout = cos_ods * x + sin_ods / (omega * delta1) * px;
178 pxout = -omega * delta1 * sin_ods * x + cos_ods * px;
180 yout = cos_ods * y + sin_ods / (omega * delta1) * py;
181 pyout = -omega * delta1 * sin_ods * y + cos_ods * py;
184 T_Real
const term = pt + delta/
m_beta;
187 T_Real
const w = omega*delta1;
188 T_Real
const term1 = -(powi<2>(p2) - powi<2>(q2) * powi<2>(w)) * sin(2_prt*
m_slice_ds*omega);
189 T_Real
const term2 = -(powi<2>(p1) - powi<2>(q1) * powi<2>(w)) * sin(2_prt*
m_slice_ds*omega);
190 T_Real
const term3 = -2_prt * q2 * p2 * w * cos(2_prt*
m_slice_ds*omega);
191 T_Real
const term4 = -2_prt * q1 * p1 * w * cos(2_prt*
m_slice_ds*omega);
192 T_Real
const term5 = 2_prt * omega * (q1*p1*delta1 + q2*p2*delta1
194 tout = t0 + (-1_prt+
m_beta*pt)
195 / (8_prt*
m_beta * powi<3>(delta1)*omega)
196 * (term1+term2+term3+term4+term5);
199 else if (
m_g < 0_prt)
205 xout = cosh_ods * x + sinh_ods / (omega * delta1) * px;
206 pxout = +omega * delta1 * sinh_ods * x + cosh_ods * px;
208 yout = cosh_ods * y + sinh_ods / (omega * delta1) * py;
209 pyout = +omega * delta1 * sinh_ods * y + cosh_ods * py;
212 T_Real
const term = pt + delta/
m_beta;
215 T_Real
const w = omega*delta1;
216 T_Real
const term1 = -(powi<2>(p2) + powi<2>(q2) * powi<2>(w)) * sinh(2_prt*
m_slice_ds*omega);
217 T_Real
const term2 = -(powi<2>(p1) + powi<2>(q1) * powi<2>(w)) * sinh(2_prt*
m_slice_ds*omega);
218 T_Real
const term3 = -2_prt * q2 * p2 * w * cosh(2_prt*
m_slice_ds*omega);
219 T_Real
const term4 = -2_prt * q1 * p1 * w * cosh(2_prt*
m_slice_ds*omega);
220 T_Real
const term5 = 2_prt * omega * (q1*p1*delta1 + q2*p2*delta1
222 tout = t0 + (-1_prt+
m_beta*pt)
223 / (8_prt*
m_beta * powi<3>(delta1)*omega)
224 * (term1+term2+term3+term4+term5);
235 T_Real term = 2_prt * powi<2>(pt) + powi<2>(px) + powi<2>(py);
236 term = 2_prt - 4_prt *
m_beta * pt + powi<2>(
m_beta) * term;
237 term = -2_prt + powi<2>(
m_gamma)*term;
238 term = (-1_prt +
m_beta * pt) * term;
267 using namespace amrex::literals;
271 amrex::ParticleReal
const x = refpart.x;
272 amrex::ParticleReal
const px = refpart.px;
273 amrex::ParticleReal
const y = refpart.y;
274 amrex::ParticleReal
const py = refpart.py;
275 amrex::ParticleReal
const z = refpart.z;
276 amrex::ParticleReal
const pz = refpart.pz;
277 amrex::ParticleReal
const t = refpart.t;
278 amrex::ParticleReal
const pt = refpart.pt;
279 amrex::ParticleReal
const s = refpart.s;
282 amrex::ParticleReal
const slice_ds =
m_ds /
nslice();
285 amrex::ParticleReal
const step = slice_ds / std::sqrt(powi<2>(pt)-1.0_prt);
288 refpart.x = x + step*px;
289 refpart.y = y + step*py;
290 refpart.z = z + step*pz;
291 refpart.t =
t - step*pt;
294 refpart.s =
s + slice_ds;
298 using LinearTransport::operator();
309 throw std::runtime_error(std::string(
type) +
": Envelope tracking is not yet implemented!");
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
T_ParticleType ParticleType
__host__ __device__ std::pair< double, double > sincos(double x)
constexpr T powi(T x) 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:31
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
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal gamma() const
Definition ReferenceParticle.H:82
int m_unit
focusing strength in 1/m^2 (or T/m)
Definition ChrPlasmaLens.H:314
static constexpr auto type
Definition ChrPlasmaLens.H:43
void compute_constants(RefPart const &refpart)
Definition ChrPlasmaLens.H:96
amrex::ParticleReal m_beta
m_ds / nslice();
Definition ChrPlasmaLens.H:320
amrex::ParticleReal m_k
Definition ChrPlasmaLens.H:313
amrex::ParticleReal m_const1
Definition ChrPlasmaLens.H:323
amrex::ParticleReal m_gamma
Definition ChrPlasmaLens.H:321
amrex::ParticleReal m_g
Definition ChrPlasmaLens.H:322
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 ChrPlasmaLens.H:130
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:66
amrex::ParticleReal m_slice_ds
unit specification for focusing strength
Definition ChrPlasmaLens.H:319
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ChrPlasmaLens.H:307
ImpactXParticleContainer::ParticleType PType
Definition ChrPlasmaLens.H:44
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