OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
RK4.h
Go to the documentation of this file.
1//
2// Class RK4
3// Fourth order Runge-Kutta 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 RK4_H
19#define RK4_H
20
21#include "Stepper.h"
22#include "Physics/Physics.h"
23#include "Physics/Units.h"
24
26template <typename FieldFunction, typename ... Arguments>
27class RK4 : public Stepper<FieldFunction, Arguments...> {
28
29public:
30
31 RK4(const FieldFunction& fieldfunc) : Stepper<FieldFunction, Arguments ...>(fieldfunc) { }
32
33private:
35 const size_t& i,
36 const double& t,
37 const double dt,
38 Arguments& ... args) const;
39
51 double *y,
52 const double& t,
53 double* yp,
54 const size_t& i,
55 Arguments& ... args) const;
56
57
58 void copyTo(const Vector_t& R, const Vector_t& P, double* x) const;
59
60 void copyFrom(Vector_t& R, Vector_t& P, double* x) const;
61
62 const double mass_coeff = 1.0e9 * Units::GeV2kg; // from GeV/c^2 to basic unit: GV*C*s^2/m^2, (1.0e9 converts V*C*s^2/m^2 to GV*C*s^2/m^2)
64 const double c_mtns = Physics::c / Units::s2ns;
65};
66
67#include "RK4.hpp"
68
69#endif
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
constexpr double m2mm
Definition: Units.h:26
constexpr double GeV2kg
Definition: Units.h:104
constexpr double s2ns
Definition: Units.h:44
4-th order Runnge-Kutta stepper
Definition: RK4.h:27
bool derivate_m(PartBunchBase< double, 3 > *bunch, double *y, const double &t, double *yp, const size_t &i, Arguments &... args) const
Definition: RK4.hpp:88
const double c_mmtns
Definition: RK4.h:63
RK4(const FieldFunction &fieldfunc)
Definition: RK4.h:31
const double c_mtns
Definition: RK4.h:64
const double mass_coeff
Definition: RK4.h:62
bool doAdvance_m(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const
Definition: RK4.hpp:20
void copyFrom(Vector_t &R, Vector_t &P, double *x) const
Definition: RK4.hpp:145
void copyTo(const Vector_t &R, const Vector_t &P, double *x) const
Definition: RK4.hpp:133