ImpactX
ShortRF.H
Go to the documentation of this file.
1 /* Copyright 2022-2023 The Regents of the University of California, through Lawrence
2  * Berkeley National Laboratory (subject to receipt of any required
3  * approvals from the U.S. Dept. of Energy). All rights reserved.
4  *
5  * This file is part of ImpactX.
6  *
7  * Authors: Chad Mitchell, Axel Huebl
8  * License: BSD-3-Clause-LBNL
9  */
10 #ifndef IMPACTX_SHORTRF_H
11 #define IMPACTX_SHORTRF_H
12 
14 
15 #include <AMReX_Extension.H>
16 #include <AMReX_REAL.H>
17 
18 #include <cmath>
19 
20 
21 namespace impactx
22 {
23  struct ShortRF
24  {
25  static constexpr auto name = "ShortRF";
27 
33  ShortRF( amrex::ParticleReal const V, amrex::ParticleReal const k )
34  : m_V(V), m_k(k)
35  {
36  }
37 
49  PType& AMREX_RESTRICT p,
50  amrex::ParticleReal & AMREX_RESTRICT px,
51  amrex::ParticleReal & AMREX_RESTRICT py,
52  amrex::ParticleReal & AMREX_RESTRICT pt,
53  RefPart const & refpart) const {
54 
55  using namespace amrex::literals; // for _rt and _prt
56 
57  // access AoS data such as positions and cpu/id
58  amrex::ParticleReal const x = p.pos(0);
59  amrex::ParticleReal const y = p.pos(1);
60  amrex::ParticleReal const t = p.pos(2);
61 
62  // access reference particle values to find (beta*gamma)^2
63  amrex::ParticleReal const pt_ref = refpart.pt;
64  amrex::ParticleReal const betgam2 = pow(pt_ref, 2) - 1.0_prt;
65 
66  // intialize output values of momenta
67  amrex::ParticleReal pxout = px;
68  amrex::ParticleReal pyout = py;
69  amrex::ParticleReal ptout = pt;
70 
71  // advance position and momentum
72  p.pos(0) = x;
73  pxout = px + m_k*m_V/(2.0_prt*betgam2)*x;
74 
75  p.pos(1) = y;
76  pyout = py + m_k*m_V/(2.0_prt*betgam2)*y;
77 
78  p.pos(2) = t;
79  ptout = pt - m_k*m_V*t;
80 
81  // assign updated momenta
82  px = pxout;
83  py = pyout;
84  pt = ptout;
85 
86  }
87 
93  void operator() ([[maybe_unused]] RefPart & AMREX_RESTRICT refpart) const {
94 
95  // nothing to do: this is a zero-length element
96 
97  }
98 
104  int nslice () const
105  {
106  return 1;
107  }
108 
114  amrex::ParticleReal ds () const
115  {
116  using namespace amrex::literals;
117  return 0.0_prt;
118  }
119 
120  private:
121  amrex::ParticleReal m_V;
122  amrex::ParticleReal m_k;
123  };
124 
125 } // namespace impactx
126 
127 #endif // IMPACTX_SHORTRF_H
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: ShortRF.H:48
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: ShortRF.H:104
Definition: ImpactX.cpp:31
Definition: ShortRF.H:23
ShortRF(amrex::ParticleReal const V, amrex::ParticleReal const k)
Definition: ShortRF.H:33
amrex::ParticleReal pt
energy deviation, normalized by rest energy
Definition: ReferenceParticle.H:39
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: ShortRF.H:114
amrex::ParticleReal m_k
normalized (max) RF voltage drop.
Definition: ShortRF.H:122
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
static constexpr auto name
Definition: ShortRF.H:25
Definition: ReferenceParticle.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
amrex::ParticleReal m_V
Definition: ShortRF.H:121