ImpactX
Integrators.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_INTEGRATORS_H_
11 #define IMPACTX_INTEGRATORS_H_
12 
13 #include <ablastr/particles/IndexHandling.H>
14 
15 #include <AMReX_Extension.H> // for AMREX_RESTRICT
16 #include <AMReX_REAL.H> // for ParticleReal
17 
18 
20 {
21 
22  template <typename T_Element>
25  RefPart & refpart,
26  amrex::ParticleReal const zin,
27  amrex::ParticleReal const zout,
28  int const nsteps,
29  T_Element const & element
30  )
31  {
32  using namespace amrex::literals; // for _rt and _prt
33 
34  // initialize numerical integration parameters
35  amrex::ParticleReal const dz = (zout-zin)/nsteps;
36  amrex::ParticleReal const tau1 = dz/2.0_prt;
37  amrex::ParticleReal const tau2 = dz;
38 
39  // initialize the value of the independent variable
40  amrex::ParticleReal zeval = zin;
41 
42  // loop over integration steps
43  for(int j=0; j < nsteps; ++j)
44  {
45  element.map1(tau1,refpart,zeval);
46  element.map2(tau2,refpart,zeval);
47  element.map1(tau1,refpart,zeval);
48  }
49  }
50 
51  template <typename T_Element>
54  RefPart & refpart,
55  amrex::ParticleReal const zin,
56  amrex::ParticleReal const zout,
57  int const nsteps,
58  T_Element const & element
59  )
60  {
61  using namespace amrex::literals; // for _rt and _prt
62 
63  // initialize numerical integration parameters
64  amrex::ParticleReal const dz = (zout-zin)/nsteps;
65  amrex::ParticleReal const tau1 = dz/2.0_prt;
66  amrex::ParticleReal const tau2 = dz/2.0_prt;
67  amrex::ParticleReal const tau3 = dz;
68 
69  // initialize the value of the independent variable
70  amrex::ParticleReal zeval = zin;
71 
72  // loop over integration steps
73  for(int j=0; j < nsteps; ++j)
74  {
75  element.map1(tau1,refpart,zeval);
76  element.map2(tau2,refpart,zeval);
77  element.map3(tau3,refpart,zeval);
78  element.map2(tau2,refpart,zeval);
79  element.map1(tau1,refpart,zeval);
80  }
81  }
82 
83  template <typename T_Element>
86  RefPart & refpart,
87  amrex::ParticleReal const zin,
88  amrex::ParticleReal const zout,
89  int const nsteps,
90  T_Element const & element
91  )
92  {
93  using namespace amrex::literals; // for _rt and _prt
94 
95  // initialize numerical integration parameters
96  amrex::ParticleReal const dz = (zout-zin)/nsteps;
97  amrex::ParticleReal const alpha = 1.0_prt - pow(2.0_prt,1.0/3.0);
98  amrex::ParticleReal const tau2 = dz/(1.0_prt + alpha);
99  amrex::ParticleReal const tau1 = tau2/2.0_prt;
100  amrex::ParticleReal const tau3 = alpha*tau1;
101  amrex::ParticleReal const tau4 = (alpha - 1.0_prt)*tau2;
102 
103  // initialize the value of the independent variable
104  amrex::ParticleReal zeval = zin;
105 
106  // loop over integration steps
107  for (int j=0; j < nsteps; ++j)
108  {
109  element.map1(tau1,refpart,zeval);
110  element.map2(tau2,refpart,zeval);
111  element.map1(tau3,refpart,zeval);
112  element.map2(tau4,refpart,zeval);
113  element.map1(tau3,refpart,zeval);
114  element.map2(tau2,refpart,zeval);
115  element.map1(tau1,refpart,zeval);
116  }
117  }
118 } // namespace impactx::integrators
119 
120 #endif // IMPACTX_INTEGRATORS_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
int dz
Definition: Integrators.H:20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp4_integrate(RefPart &refpart, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition: Integrators.H:85
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp2_integrate(RefPart &refpart, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition: Integrators.H:24
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp2_integrate_split3(RefPart &refpart, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition: Integrators.H:53
int nsteps
Definition: ReferenceParticle.H:30