CMS 3D CMS Logo

List of all members | Public Member Functions
RK4OneStep Class Reference

#include <RK4OneStep.h>

Public Member Functions

CartesianState operator() (const CartesianState &start, const RKCartesianDerivative &deriv, double step) const
 

Detailed Description

Definition at line 9 of file RK4OneStep.h.

Member Function Documentation

◆ operator()()

CartesianState RK4OneStep::operator() ( const CartesianState start,
const RKCartesianDerivative deriv,
double  step 
) const

Definition at line 6 of file RK4OneStep.cc.

References mps_fire::result.

8  {
9  double s0 = 0; // derivatives do't depend on absolute value of the integration variable
10  CartesianState k1 = step * deriv(s0, start);
11  CartesianState k2 = step * deriv(s0 + step / 2, start + k1 / 2);
12  CartesianState k3 = step * deriv(s0 + step / 2, start + k2 / 2);
13  CartesianState k4 = step * deriv(s0 + step, start + k3);
14  /*
15  std::cout << "k1 = " << k1.position() << k1.momentum() << std::endl;
16  std::cout << "k2 = " << k2.position() << k2.momentum() << std::endl;
17  std::cout << "k3 = " << k3.position() << k3.momentum() << std::endl;
18  std::cout << "k4 = " << k4.position() << k4.momentum() << std::endl;
19 */
20  CartesianState result = start + k1 / 6 + k2 / 3 + k3 / 3 + k4 / 6;
21  return result;
22 }
Definition: start.py:1
step
Definition: StallMonitor.cc:98