OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BorisPusher.h
Go to the documentation of this file.
1//
2// Class BorisPusher
3// Boris-Buneman 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#ifndef OPALX_PartPusher_H
19#define OPALX_PartPusher_H
20
21#include "Physics/Physics.h"
22
23#include "Expression/IpplExpressions.h"
24
25/*
26
27
28*/
29
30extern Inform* gmsg;
31
33public:
34 KOKKOS_INLINE_FUNCTION BorisPusher() = default;
35
36 KOKKOS_INLINE_FUNCTION void kick(
38 const Vector_t<double, 3>& Bf, const double& dt, const double& mass,
39 const double& charge) const;
40
41 KOKKOS_INLINE_FUNCTION void push(
42 Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& dt) const;
43};
44
45KOKKOS_INLINE_FUNCTION void BorisPusher::kick(
47 const Vector_t<double, 3>& Bf, const double& dt, const double& mass,
48 const double& charge) const {
49 // Implementation follows chapter 4-4, p. 61 - 63 from
50 // Birdsall, C. K. and Langdon, A. B. (1985). Plasma physics
51 // via computer simulation.
52 //
53 // Up to finite precision effects, the new implementation is equivalent to the
54 // old one, but uses less floating point operations.
55 //
56 // Relativistic variant implemented below is described in
57 // chapter 15-4, p. 356 - 357.
58 // However, since other units are used here, small
59 // modifications are required. The relativistic variant can be derived
60 // from the nonrelativistic one by replacing
61 // mass
62 // by
63 // gamma * rest mass
64 // and transforming the units.
65 //
66 // Parameters:
67 // R = x / (c * dt): Scaled position x, not used in here
68 // P = v / c * gamma: Scaled velocity v
69 // Ef: Electric field
70 // Bf: Magnetic field
71 // dt: Timestep
72 // mass = rest energy = rest mass * c * c
73 // charge
74
75 // Half step E
76 P += 0.5 * dt * charge * Physics::c / mass * Ef;
77
78 // Full step B
79
80 /*
81 LF
82 double const gamma = sqrt(1.0 + dot(P, P).apply());
83 Vector_t<double, 3> const t = dt * charge * c * c / (gamma * mass) * Bf;
84 P += cross(P, t);
85 */
86
87 double gamma = Kokkos::sqrt(1.0 + dot(P, P));
88 Vector_t<double, 3> const t = 0.5 * dt * charge * Physics::c * Physics::c / (gamma * mass) * Bf;
89 Vector_t<double, 3> const w = P + cross(P, t);
90 Vector_t<double, 3> const s = 2.0 / (1.0 + dot(t, t)) * t;
91 P += cross(w, s);
92
93 /* a poor Leap-Frog
94 P += 1.0 * dt * charge * c * c / (gamma * mass) * cross(P,Bf);
95 */
96
97 // Half step E
98 P += 0.5 * dt * charge * Physics::c / mass * Ef;
99}
100
101KOKKOS_INLINE_FUNCTION void BorisPusher::push(
102 Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& /* dt */) const {
110 R += 0.5 * P / Kokkos::sqrt(1.0 + dot(P));
111}
112
113#endif
Inform * gmsg
Definition changes.cpp:7
ippl::Vector< T, Dim > Vector_t
Vector3D cross(const Vector3D &lhs, const Vector3D &rhs)
Vector cross product.
Definition Vector3D.cpp:89
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition Vector3D.cpp:95
KOKKOS_INLINE_FUNCTION BorisPusher()=default
KOKKOS_INLINE_FUNCTION void kick(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &P, const Vector_t< double, 3 > &Ef, const Vector_t< double, 3 > &Bf, const double &dt, const double &mass, const double &charge) const
Definition BorisPusher.h:45
KOKKOS_INLINE_FUNCTION void push(Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &dt) const
constexpr double c
The velocity of light in m/s.
Definition Physics.h:60