OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
LF2.hpp
Go to the documentation of this file.
1//
2// Class LF2
3// Second order Leap-Frog time integrator
4//
5// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#include "BorisPusher.h"
19#include "Physics/Units.h"
20
21template <typename FieldFunction, typename... Arguments>
23 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
24 Arguments&... args) const {
25 bool flagNoDeletion = true;
26
27 // push for first LF2 half step
28 push_m(bunch->R(i), bunch->P(i), 0.5 * dt * Units::ns2s);
29
30 flagNoDeletion = kick_m(bunch, i, t, dt * Units::ns2s, args...);
31
32 // push for second LF2 half step
33 push_m(bunch->R(i), bunch->P(i), 0.5 * dt * Units::ns2s);
34
35 return flagNoDeletion;
36}
37
38template <typename FieldFunction, typename... Arguments>
40 Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& h) const {
41 double const gamma = sqrt(1.0 + dot(P, P));
42 double const c_gamma = Physics::c / gamma;
43 Vector_t<double, 3> const v = P * c_gamma;
44 R += h * v;
45}
46
47template <typename FieldFunction, typename... Arguments>
49 PartBunch_t* bunch, const size_t& i, const double& t, const double& h,
50 Arguments&... args) const {
51 Vector_t<double, 3> externalE = Vector_t<double, 3>(0.0, 0.0, 0.0);
52 Vector_t<double, 3> externalB = Vector_t<double, 3>(0.0, 0.0, 0.0);
53
54 bool outOfBound = this->fieldfunc_m(t, i, externalE, externalB, args...);
55
56 if (outOfBound)
57 return false;
58
59 double const q = 1; // \todo = bunch->Q(0) / Physics::q_e;
60 double const M = 1; // \todo = bunch->M(0) * Units::GeV2eV;
61 // same rest energy
62
63 BorisPusher pusher;
64
65 // \todo pusher.kick(bunch->R(i), bunch->P(i), externalE, externalB, h, M, q);
66
67 return true;
68}
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition Vector3D.cpp:118
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
constexpr double c
The velocity of light in m/s.
Definition Physics.h:45
constexpr double ns2s
Definition Units.h:47
Vector_t< double, Dim > R(size_t i)
Definition PartBunch.h:276
ParticleAttrib< Vector_t< T, Dim > > P
void push_m(Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &h) const
Definition LF2.hpp:39
bool kick_m(PartBunch_t *bunch, const size_t &i, const double &t, const double &h, Arguments &... args) const
Definition LF2.hpp:48
bool doAdvance_m(PartBunch_t *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const
Definition LF2.hpp:22
const FieldFunction & fieldfunc_m
Definition Stepper.h:65