OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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 "Stepper.h"
24
26template <typename FieldFunction, typename... Arguments>
27class RK4 : public Stepper<FieldFunction, Arguments...> {
28public:
29 RK4(const FieldFunction& fieldfunc) : Stepper<FieldFunction, Arguments...>(fieldfunc) {}
30
31private:
32 bool doAdvance_m(
33 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
34 Arguments&... args) const;
35
46 bool derivate_m(
47 PartBunch_t* bunch, double* y, const double& t, double* yp, const size_t& i,
48 Arguments&... args) const;
49
50 void copyTo(const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, double* x) const;
51
52 void copyFrom(Vector_t<double, 3>& R, Vector_t<double, 3>& P, double* x) const;
53
54 const double mass_coeff =
55 1.0e9 * Units::GeV2kg; // from GeV/c^2 to basic unit: GV*C*s^2/m^2, (1.0e9 converts
56 // V*C*s^2/m^2 to GV*C*s^2/m^2)
58 const double c_mtns = Physics::c / Units::s2ns;
59};
60
61#include "RK4.hpp"
62
63#endif
ippl::Vector< T, Dim > Vector_t
4-th order Runnge-Kutta stepper
Definition RK4.h:27
void copyFrom(Vector_t< double, 3 > &R, Vector_t< double, 3 > &P, double *x) const
Definition RK4.hpp:132
void copyTo(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, double *x) const
Definition RK4.hpp:123
bool derivate_m(PartBunch_t *bunch, double *y, const double &t, double *yp, const size_t &i, Arguments &... args) const
Definition RK4.hpp:80
bool doAdvance_m(PartBunch_t *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const
Definition RK4.hpp:20
const double c_mmtns
Definition RK4.h:57
RK4(const FieldFunction &fieldfunc)
Definition RK4.h:29
const double c_mtns
Definition RK4.h:58
const double mass_coeff
Definition RK4.h:54
constexpr double c
The velocity of light in m/s.
Definition Physics.h:60
constexpr double m2mm
Definition Units.h:26
constexpr double GeV2kg
Definition Units.h:104
constexpr double s2ns
Definition Units.h:44