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 
34  template <typename T_Element>
37  RefPart & refpart,
38  amrex::ParticleReal const zin,
39  amrex::ParticleReal const zout,
40  int const nsteps,
41  T_Element const & element
42  )
43  {
44  using namespace amrex::literals; // for _rt and _prt
45 
46  // initialize numerical integration parameters
47  amrex::ParticleReal const dz = (zout-zin)/nsteps;
48  amrex::ParticleReal const tau1 = dz/2.0_prt;
49  amrex::ParticleReal const tau2 = dz;
50 
51  // initialize the value of the independent variable
52  amrex::ParticleReal zeval = zin;
53 
54  // loop over integration steps
55  for(int j=0; j < nsteps; ++j)
56  {
57  element.map1(tau1,refpart,zeval);
58  element.map2(tau2,refpart,zeval);
59  element.map1(tau1,refpart,zeval);
60  }
61  }
62 
77  template <typename T_Element>
80  RefPart & refpart,
81  amrex::ParticleReal const zin,
82  amrex::ParticleReal const zout,
83  int const nsteps,
84  T_Element const & element
85  )
86  {
87  using namespace amrex::literals; // for _rt and _prt
88 
89  // initialize numerical integration parameters
90  amrex::ParticleReal const dz = (zout-zin)/nsteps;
91  amrex::ParticleReal const tau1 = dz/2.0_prt;
92  amrex::ParticleReal const tau2 = dz/2.0_prt;
93  amrex::ParticleReal const tau3 = dz;
94 
95  // initialize the value of the independent variable
96  amrex::ParticleReal zeval = zin;
97 
98  // loop over integration steps
99  for(int j=0; j < nsteps; ++j)
100  {
101  element.map1(tau1,refpart,zeval);
102  element.map2(tau2,refpart,zeval);
103  element.map3(tau3,refpart,zeval);
104  element.map2(tau2,refpart,zeval);
105  element.map1(tau1,refpart,zeval);
106  }
107  }
108 
126  template <typename T_Element>
129  RefPart & refpart,
130  amrex::ParticleReal const zin,
131  amrex::ParticleReal const zout,
132  int const nsteps,
133  T_Element const & element
134  )
135  {
136  using namespace amrex::literals; // for _rt and _prt
137 
138  // initialize numerical integration parameters
139  amrex::ParticleReal const dz = (zout-zin)/nsteps;
140  amrex::ParticleReal const alpha = 1.0_prt - pow(2.0_prt,1.0/3.0);
141  amrex::ParticleReal const tau2 = dz/(1.0_prt + alpha);
142  amrex::ParticleReal const tau1 = tau2/2.0_prt;
143  amrex::ParticleReal const tau3 = alpha*tau1;
144  amrex::ParticleReal const tau4 = (alpha - 1.0_prt)*tau2;
145 
146  // initialize the value of the independent variable
147  amrex::ParticleReal zeval = zin;
148 
149  // loop over integration steps
150  for (int j=0; j < nsteps; ++j)
151  {
152  element.map1(tau1,refpart,zeval);
153  element.map2(tau2,refpart,zeval);
154  element.map1(tau3,refpart,zeval);
155  element.map2(tau4,refpart,zeval);
156  element.map1(tau3,refpart,zeval);
157  element.map2(tau2,refpart,zeval);
158  element.map1(tau1,refpart,zeval);
159  }
160  }
161 } // namespace impactx::integrators
162 
163 #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:128
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:36
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:79
int nsteps
Definition: ReferenceParticle.H:30