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