ImpactX
ShortRF.H
Go to the documentation of this file.
1 /* Copyright 2022 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 
94  [[maybe_unused]] RefPart & AMREX_RESTRICT refpart) const {
95 
96  // nothing to do: this is a zero-length element
97 
98  }
99 
105  int nslice () const
106  {
107  return 1;
108  }
109 
115  amrex::ParticleReal ds () const
116  {
117  using namespace amrex::literals;
118  return 0.0_prt;
119  }
120 
121  private:
122  amrex::ParticleReal m_V;
123  amrex::ParticleReal m_k;
124  };
125 
126 } // namespace impactx
127 
128 #endif // IMPACTX_SHORTRF_H
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: ShortRF.H:105
def x
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:38
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: ShortRF.H:115
amrex::ParticleReal m_k
normalized (max) RF voltage drop.
Definition: ShortRF.H:123
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
static constexpr auto name
Definition: ShortRF.H:25
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
Definition: ReferenceParticle.H:28
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:122