OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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 "Physics/Physics.h"
22#include "Physics/Units.h"
23#include "Steppers/Stepper.h"
24
26template <typename FieldFunction, typename ... Arguments>
27class RK4 : public Stepper<FieldFunction, Arguments...> {
28
29public:
30 RK4(const FieldFunction& fieldfunc) : Stepper<FieldFunction, Arguments ...>(fieldfunc) { }
31
32private:
34 const size_t& i,
35 const double& t,
36 const double dt,
37 Arguments& ... args) const;
49 double *y,
50 const double& t,
51 double* yp,
52 const size_t& i,
53 Arguments& ... args) const;
54
55 void copyTo(const Vector_t& R, const Vector_t& P, double* x) const;
56
57 void copyFrom(Vector_t& R, Vector_t& P, double* x) const;
58
59 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)
60};
61
62#include "RK4.hpp"
63
64#endif
constexpr double GeV2kg
Definition Units.h:104
bool derivate_m(PartBunchBase< double, 3 > *bunch, double *y, const double &t, double *yp, const size_t &i, Arguments &... args) const
Definition RK4.hpp:93
RK4(const FieldFunction &fieldfunc)
Definition RK4.h:30
const double mass_coeff
Definition RK4.h:59
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:148
void copyTo(const Vector_t &R, const Vector_t &P, double *x) const
Definition RK4.hpp:136
Stepper(const FieldFunction &fieldfunc)
Definition Stepper.h:40
Vektor< double, 3 > Vector_t