ARTEMIS
HardEdged_K.H
Go to the documentation of this file.
1 /* Copyright 2022 David Grote
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_ACCELERATORLATTICE_LATTICEELEMENTS_HARDEDGED_K_H_
8 #define WARPX_ACCELERATORLATTICE_LATTICEELEMENTS_HARDEDGED_K_H_
9 
10 #include "Utils/WarpXConst.H"
11 
12 #include <AMReX_REAL.H>
13 #include <AMReX_Vector.H>
14 
26 amrex::ParticleReal hard_edged_fraction(const amrex::ParticleReal z,
27  const amrex::ParticleReal zpvdt,
28  const amrex::ParticleReal zs,
29  const amrex::ParticleReal ze)
30 {
31 
32  using namespace amrex::literals;
33 
34  // This allows vz to be positive or negative
35  amrex::ParticleReal const zl = std::min(z, zpvdt);
36  amrex::ParticleReal const zr = std::max(z, zpvdt);
37 
38  // Calculate the residence correction
39  // frac will be 1 if the step is completely inside the lens, between 0 and 1
40  // when entering or leaving the lens, and otherwise 0.
41  // This accounts for the case when particles step over the element without landing in it.
42  // This assumes that vzp != 0.
43  amrex::ParticleReal const zl_bounded = std::min(std::max(zl, zs), ze);
44  amrex::ParticleReal const zr_bounded = std::min(std::max(zr, zs), ze);
45  amrex::ParticleReal frac = (zr_bounded - zl_bounded)/(zr - zl);
46 
47  return frac;
48 }
49 
50 #endif // WARPX_ACCELERATORLATTICE_LATTICEELEMENTS_HARDEDGED_K_H_
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal hard_edged_fraction(const amrex::ParticleReal z, const amrex::ParticleReal zpvdt, const amrex::ParticleReal zs, const amrex::ParticleReal ze)
Calculate the residence correction, the fraction of the time step the particle spends inside of the h...
Definition: HardEdged_K.H:26
def z
Definition: Excitation_Flag_Generator.py:77