10 const double Safety = 0.9;
11 double remainigStep =
step;
12 double stepSize =
step;
15 std::pair<CartesianState, double> tryStep;
20 if (tryStep.second < eps) {
21 if (remainigStep - stepSize < eps / 2) {
23 std::cout <<
"Accuracy reached, and full step taken in " << nsteps <<
" steps" << std::endl;
26 remainigStep -= stepSize;
28 double factor =
std::min(Safety *
pow(fabs(eps / tryStep.second), 0.2), 4.);
29 stepSize =
std::min(stepSize * factor, remainigStep);
30 currentStart = tryStep.first;
32 std::cout <<
"Accuracy reached, but " << remainigStep <<
" remain after " << nsteps
33 <<
" steps. Step size increased by " << factor <<
" to " << stepSize << std::endl;
37 double factor =
std::max(Safety *
pow(fabs(eps / tryStep.second), 0.25), 0.1);
40 std::cout <<
"Accuracy not yet reached: delta = " << tryStep.second <<
", step reduced by " << factor <<
" to "
44 }
while (remainigStep > eps / 2);
57 return std::pair<CartesianState, double>(secondHalf,
diff);
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
double distance(const CartesianState &a, const CartesianState &b) const
CartesianState operator()(const CartesianState &start, const RKCartesianDerivative &deriv, double step, double eps) const
T z() const
Cartesian z coordinate.
std::pair< CartesianState, double > stepWithAccuracy(const CartesianState &start, const RKCartesianDerivative &deriv, double step) const
T perp() const
Magnitude of transverse component.
const Vector3D & momentum() const
const Vector3D & position() const
Power< A, B >::type pow(const A &a, const B &b)