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 
15 #include <AMReX_Extension.H>
16 #include <AMReX_REAL.H>
17 
18 #include <cmath>
19 
20 
21 namespace impactx
22 {
23  struct DipEdge
24  {
25  static constexpr auto name = "DipEdge";
27 
42  DipEdge( amrex::ParticleReal const psi, amrex::ParticleReal const rc,
43  amrex::ParticleReal const g, amrex::ParticleReal const K2 )
44  : m_psi(psi), m_rc(rc), m_g(g), m_K2(K2)
45  {
46  }
47 
59  PType& AMREX_RESTRICT p,
60  amrex::ParticleReal & AMREX_RESTRICT px,
61  amrex::ParticleReal & AMREX_RESTRICT py,
62  [[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT pt,
63  [[maybe_unused]] RefPart const & refpart) const {
64 
65  using namespace amrex::literals; // for _rt and _prt
66 
67  // access AoS data such as positions and cpu/id
68  amrex::ParticleReal const x = p.pos(0);
69  amrex::ParticleReal const y = p.pos(1);
70 
71  // access reference particle values if needed
72 
73  // edge focusing matrix elements (zero gap)
74  amrex::ParticleReal const R21 = tan(m_psi)/m_rc;
75  amrex::ParticleReal R43 = -R21;
76  amrex::ParticleReal vf = 0;
77 
78  // first-order effect of nonzero gap
79  vf = (1.0_prt + pow(sin(m_psi),2))/(pow(cos(m_psi),3));
80  vf *= m_g * m_K2/(pow(m_rc,2));
81  R43 += vf;
82 
83  // apply edge focusing
84  px = px + R21*x;
85  py = py + R43*y;
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 
103  int nslice () const
104  {
105  return 1;
106  }
107 
113  amrex::ParticleReal ds () const
114  {
115  using namespace amrex::literals;
116  return 0.0_prt;
117  }
118 
119  private:
120  amrex::ParticleReal m_psi;
121  amrex::ParticleReal m_rc;
122  amrex::ParticleReal m_g;
123  amrex::ParticleReal m_K2;
124  };
125 
126 } // namespace impactx
127 
128 #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:58
Definition: ImpactX.cpp:31
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
amrex::ParticleReal m_g
bend radius in m
Definition: DipEdge.H:122
static constexpr auto name
Definition: DipEdge.H:25
DipEdge(amrex::ParticleReal const psi, amrex::ParticleReal const rc, amrex::ParticleReal const g, amrex::ParticleReal const K2)
Definition: DipEdge.H:42
amrex::ParticleReal m_rc
pole face angle in rad
Definition: DipEdge.H:121
amrex::ParticleReal m_psi
Definition: DipEdge.H:120
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:123
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: DipEdge.H:113
Definition: DipEdge.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: DipEdge.H:103