19 template <
typename FieldFunction,
typename ... Arguments>
24 Arguments& ... args)
const
35 this->copyTo(bunch->
R[i], bunch->
P[i], &x[0]);
44 bool outOfBound = derivate_m(bunch, x, t, deriv1 , i, args ...);
50 const double half_dt = 0.5 * dt;
51 const double t_half = t + half_dt;
53 for(
int j = 0; j < 6; ++j)
54 xtemp[j] = x[j] + half_dt * deriv1[j];
56 outOfBound = derivate_m(bunch, xtemp, t_half, deriv2 , i, args ...);
62 for (
int j = 0; j < 6; ++j) {
63 xtemp[j] = x[j] + half_dt * deriv2[j];
66 outOfBound = derivate_m(bunch, xtemp, t_half, deriv3 , i, args ...);
72 double t_full = t + dt;
73 for (
int j = 0; j < 6; ++j) {
74 xtemp[j] = x[j] + dt * deriv3[j];
77 outOfBound = derivate_m(bunch, xtemp, t_full, deriv4 , i, args ...);
83 for (
int j = 0; j < 6; ++j) {
84 x[j] += dt / 6.*(deriv1[j] + deriv4[j] + 2.*(deriv2[j] + deriv3[j]));
86 this->copyFrom(bunch->
R[i], bunch->
P[i], &x[0]);
92 template <
typename FieldFunction,
typename ... Arguments>
98 Arguments& ... args)
const
103 Vector_t externalE, externalB, tempR;
105 externalB =
Vector_t(0.0, 0.0, 0.0);
106 externalE =
Vector_t(0.0, 0.0, 0.0);
108 for (
int j = 0; j < 3; ++j) {
113 bool outOfBound = this->fieldfunc_m(t, i, externalE, externalB, args ...);
115 double qtom = bunch->
Q[i] / (bunch->
M[i] * mass_coeff);
117 double tempgamma =
std::sqrt(1 + (y[3] * y[3] + y[4] * y[4] + y[5] * y[5]));
123 yp[3] = (externalE(0) /
Physics::c + (externalB(2) * y[4] - externalB(1) * y[5]) / tempgamma) * qtom;
124 yp[4] = (externalE(1) /
Physics::c - (externalB(2) * y[3] - externalB(0) * y[5]) / tempgamma) * qtom;
125 yp[5] = (externalE(2) /
Physics::c + (externalB(1) * y[3] - externalB(0) * y[4]) / tempgamma) * qtom;
135 template <
typename FieldFunction,
typename ... Arguments>
140 for (
int j = 0; j < 3; j++) {
147 template <
typename FieldFunction,
typename ... Arguments>
152 for (
int j = 0; j < 3; j++) {
Tps< T > sqrt(const Tps< T > &x)
Square root.
constexpr double c
The velocity of light in m/s.
ParticleAttrib< Vector_t > P
Vektor< double, 3 > Vector_t
void copyFrom(Vector_t &R, Vector_t &P, double *x) const
ParticleAttrib< double > M
void copyTo(const Vector_t &R, const Vector_t &P, double *x) const
ParticleAttrib< double > Q
bool derivate_m(PartBunchBase< double, 3 > *bunch, double *y, const double &t, double *yp, const size_t &i, Arguments &...args) const
bool doAdvance_m(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double dt, Arguments &...args) const