19template <
typename FieldFunction,
typename ... Arguments>
24 Arguments& ... args)
const
35 this->copyTo(bunch->
R[i], bunch->
P[i], &x[0]);
45 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 ...);
61 for(
int j = 0; j < 6; ++j)
62 xtemp[j] = x[j] + half_dt * deriv2[j];
64 outOfBound = derivate_m(bunch, xtemp, t_half, deriv3 , i, args ...);
69 double t_full = t + dt;
70 for(
int j = 0; j < 6; ++j)
71 xtemp[j] = x[j] + dt * deriv3[j];
73 outOfBound = derivate_m(bunch, xtemp, t_full, deriv4 , i, args ...);
78 for(
int j = 0; j < 6; ++j)
79 x[j] += dt / 6.*(deriv1[j] + deriv4[j] + 2.*(deriv2[j] + deriv3[j]));
81 this->copyFrom(bunch->
R[i], bunch->
P[i], &x[0]);
87template <
typename FieldFunction,
typename ... Arguments>
93 Arguments& ... args)
const
98 Vector_t externalE, externalB, tempR;
100 externalB =
Vector_t(0.0, 0.0, 0.0);
101 externalE =
Vector_t(0.0, 0.0, 0.0);
103 for(
int j = 0; j < 3; ++j)
108 bool outOfBound = this->fieldfunc_m(t, i, externalE, externalB, args ...);
110 double qtom = bunch->
Q[i] / (bunch->
M[i] * mass_coeff);
112 double tempgamma =
sqrt(1 + (y[3] * y[3] + y[4] * y[4] + y[5] * y[5]));
114 yp[0] = c_mtns / tempgamma * y[3];
115 yp[1] = c_mtns / tempgamma * y[4];
116 yp[2] = c_mtns / tempgamma * y[5];
124 yp[3] = (externalE(0) /
Physics::c + (externalB(2) * y[4] - externalB(1) * y[5]) / tempgamma) * qtom;
125 yp[4] = (externalE(1) /
Physics::c - (externalB(2) * y[3] - externalB(0) * y[5]) / tempgamma) * qtom;
126 yp[5] = (externalE(2) /
Physics::c + (externalB(1) * y[3] - externalB(0) * y[4]) / tempgamma) * qtom;
132template <
typename FieldFunction,
typename ... Arguments>
137 for (
int j = 0; j < 3; j++) {
144template <
typename FieldFunction,
typename ... Arguments>
149 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< double > M
ParticleAttrib< Vector_t > P
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
void copyFrom(Vector_t &R, Vector_t &P, double *x) const
void copyTo(const Vector_t &R, const Vector_t &P, double *x) const
Vektor< double, 3 > Vector_t