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