OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 [[maybe_unused]], const size_t& i, const double& t,
50 const double& h [[maybe_unused]], 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) return false;
57
58 [[maybe_unused]] BorisPusher pusher;
59
60 // \todo pusher.kick(bunch->R(i), bunch->P(i), externalE, externalB, h, M, q);
61 return true;
62}
ippl::Vector< T, Dim > Vector_t
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition Vector3D.cpp:95
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
Vector_t< double, Dim > R(size_t)
Do not use; throws (access positions via ParticleContainer::R).
Definition PartBunch.h:611
Vector_t< double, Dim > P(size_t)
Do not use; throws (access momenta via ParticleContainer::P).
Definition PartBunch.h:620
constexpr double c
The velocity of light in m/s.
Definition Physics.h:60
constexpr double ns2s
Definition Units.h:47