ImpactX
DipEdge.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_DIPEDGE_H
11 #define IMPACTX_DIPEDGE_H
12 
14 #include "mixin/beamoptic.H"
15 #include "mixin/thin.H"
16 
17 #include <AMReX_Extension.H>
18 #include <AMReX_REAL.H>
19 
20 #include <cmath>
21 
22 
23 namespace impactx
24 {
25  struct DipEdge
26  : public elements::BeamOptic<DipEdge>,
27  public elements::Thin
28  {
29  static constexpr auto name = "DipEdge";
31 
46  DipEdge( amrex::ParticleReal const psi, amrex::ParticleReal const rc,
47  amrex::ParticleReal const g, amrex::ParticleReal const K2 )
48  : m_psi(psi), m_rc(rc), m_g(g), m_K2(K2)
49  {
50  }
51 
53  using BeamOptic::operator();
54 
66  PType& AMREX_RESTRICT p,
67  amrex::ParticleReal & AMREX_RESTRICT px,
68  amrex::ParticleReal & AMREX_RESTRICT py,
69  [[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT pt,
70  [[maybe_unused]] RefPart const & refpart) const {
71 
72  using namespace amrex::literals; // for _rt and _prt
73 
74  // access AoS data such as positions and cpu/id
75  amrex::ParticleReal const x = p.pos(0);
76  amrex::ParticleReal const y = p.pos(1);
77 
78  // access reference particle values if needed
79 
80  // edge focusing matrix elements (zero gap)
81  amrex::ParticleReal const R21 = tan(m_psi)/m_rc;
82  amrex::ParticleReal R43 = -R21;
83  amrex::ParticleReal vf = 0;
84 
85  // first-order effect of nonzero gap
86  vf = (1.0_prt + pow(sin(m_psi),2))/(pow(cos(m_psi),3));
87  vf *= m_g * m_K2/(pow(m_rc,2));
88  R43 += vf;
89 
90  // apply edge focusing
91  px = px + R21*x;
92  py = py + R43*y;
93  }
94 
96  using Thin::operator();
97 
98  private:
99  amrex::ParticleReal m_psi;
100  amrex::ParticleReal m_rc;
101  amrex::ParticleReal m_g;
102  amrex::ParticleReal m_K2;
103  };
104 
105 } // namespace impactx
106 
107 #endif // IMPACTX_DIPEDGE_H
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(PType &AMREX_RESTRICT p, amrex::ParticleReal &AMREX_RESTRICT px, amrex::ParticleReal &AMREX_RESTRICT py, [[maybe_unused]] amrex::ParticleReal &AMREX_RESTRICT pt, [[maybe_unused]] RefPart const &refpart) const
Definition: DipEdge.H:65
Definition: ImpactX.cpp:31
Definition: beamoptic.H:134
Definition: thin.H:23
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
amrex::ParticleReal m_g
bend radius in m
Definition: DipEdge.H:101
static constexpr auto name
Definition: DipEdge.H:29
DipEdge(amrex::ParticleReal const psi, amrex::ParticleReal const rc, amrex::ParticleReal const g, amrex::ParticleReal const K2)
Definition: DipEdge.H:46
amrex::ParticleReal m_rc
pole face angle in rad
Definition: DipEdge.H:100
amrex::ParticleReal m_psi
Definition: DipEdge.H:99
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_K2
gap parameter in m
Definition: DipEdge.H:102
Definition: DipEdge.H:25