OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
LF2.hpp
Go to the documentation of this file.
1 #include "BorisPusher.h"
2 
3 template <typename FieldFunction, typename ... Arguments>
5  const size_t& i,
6  const double& t,
7  const double dt,
8  Arguments& ... args) const
9 {
10  bool flagNoDeletion = true;
11 
12  // push for first LF2 half step
13  push_m(bunch->R[i], bunch->P[i], 0.5 * dt * 1.0e-9); // ns --> s
14 
15  flagNoDeletion = kick_m(bunch, i, t, dt * 1.0e-9, args ...);
16 
17  // push for second LF2 half step
18  push_m(bunch->R[i], bunch->P[i], 0.5 * dt * 1.0e-9); // ns --> s
19 
20  return flagNoDeletion;
21 }
22 
23 
24 template <typename FieldFunction, typename ... Arguments>
26  const double& h) const
27 {
28  double const gamma = sqrt(1.0 + dot(P, P));
29  double const c_gamma = Physics::c / gamma;
30  Vector_t const v = P * c_gamma;
31  R += h * v;
32 }
33 
34 
35 template <typename FieldFunction, typename ... Arguments>
37  const double& t, const double& h,
38  Arguments& ... args) const
39 {
40  Vector_t externalE = Vector_t(0.0, 0.0, 0.0);
41  Vector_t externalB = Vector_t(0.0, 0.0, 0.0);
42 
43  bool outOfBound = this->fieldfunc_m(t, i, externalE, externalB, args ...);
44 
45  if ( outOfBound )
46  return false;
47 
48 
49  double const q = bunch->Q[0] / Physics::q_e; // For now all particles have the same charge
50  double const M = bunch->M[0] * 1.0e9; // For now all particles have the same rest energy
51 
52  BorisPusher pusher;
53 
54  pusher.kick(bunch->R[i], bunch->P[i],
55  externalE, externalB,
56  h, M, q);
57 
58  return true;
59 }
ParticleAttrib< Vector_t > P
constexpr double e
The value of .
Definition: Physics.h:40
ParticleAttrib< double > Q
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
bool doAdvance_m(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double dt, Arguments &...args) const
Definition: LF2.hpp:4
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:52
void kick(const Vector_t &R, Vector_t &P, const Vector_t &Ef, const Vector_t &Bf, const double &dt) const
Definition: BorisPusher.h:48
bool kick_m(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double &h, Arguments &...args) const
Definition: LF2.hpp:36
Vektor< double, 3 > Vector_t
Definition: Vektor.h:6
Tps< T > sqrt(const Tps< T > &x)
Square root.
Definition: TpsMath.h:91
constexpr double q_e
The elementary charge in As.
Definition: Physics.h:76
ParticleAttrib< double > M
ParticlePos_t & R
void push_m(Vector_t &R, const Vector_t &P, const double &h) const
Definition: LF2.hpp:25