61template <
typename Scalar,
typename Func>
64 return (x + dt * k1).eval();
87template <
typename Scalar,
typename Func>
92 return (x + (dt / 2.0) * (k1 + k2)).eval();
130template <
typename Scalar,
typename Func>
140 return (x + (dt / 6.0) * (k1 + 2.0 * k2 + 2.0 * k3 + k4)).eval();
165template <
typename Scalar,
typename AccelFunc>
166SecondOrderStepResult<Scalar>
192template <
typename Scalar,
typename AccelFunc>
249template <
typename Scalar,
typename Func>
253 constexpr double a2 = 1.0 / 5.0;
254 constexpr double a3 = 3.0 / 10.0;
255 constexpr double a4 = 4.0 / 5.0;
256 constexpr double a5 = 8.0 / 9.0;
260 constexpr double b21 = 1.0 / 5.0;
262 constexpr double b31 = 3.0 / 40.0;
263 constexpr double b32 = 9.0 / 40.0;
265 constexpr double b41 = 44.0 / 45.0;
266 constexpr double b42 = -56.0 / 15.0;
267 constexpr double b43 = 32.0 / 9.0;
269 constexpr double b51 = 19372.0 / 6561.0;
270 constexpr double b52 = -25360.0 / 2187.0;
271 constexpr double b53 = 64448.0 / 6561.0;
272 constexpr double b54 = -212.0 / 729.0;
274 constexpr double b61 = 9017.0 / 3168.0;
275 constexpr double b62 = -355.0 / 33.0;
276 constexpr double b63 = 46732.0 / 5247.0;
277 constexpr double b64 = 49.0 / 176.0;
278 constexpr double b65 = -5103.0 / 18656.0;
280 constexpr double b71 = 35.0 / 384.0;
282 constexpr double b73 = 500.0 / 1113.0;
283 constexpr double b74 = 125.0 / 192.0;
284 constexpr double b75 = -2187.0 / 6784.0;
285 constexpr double b76 = 11.0 / 84.0;
288 constexpr double c1 = 35.0 / 384.0;
290 constexpr double c3 = 500.0 / 1113.0;
291 constexpr double c4 = 125.0 / 192.0;
292 constexpr double c5 = -2187.0 / 6784.0;
293 constexpr double c6 = 11.0 / 84.0;
297 constexpr double d1 = 5179.0 / 57600.0;
299 constexpr double d3 = 7571.0 / 16695.0;
300 constexpr double d4 = 393.0 / 640.0;
301 constexpr double d5 = -92097.0 / 339200.0;
302 constexpr double d6 = 187.0 / 2100.0;
303 constexpr double d7 = 1.0 / 40.0;
316 (x + dt * (b61 * k1 + b62 * k2 + b63 * k3 + b64 * k4 + b65 * k5)).
eval();
319 (x + dt * (b71 * k1 + b73 * k3 + b74 * k4 + b75 * k5 + b76 * k6)).
eval();
327 (x + dt * (d1 * k1 + d3 * k3 + d4 * k4 + d5 * k5 + d6 * k6 + d7 * k7)).
eval();
331 Scalar error =
diff.norm();
C++20 concepts constraining valid Janus scalar types.
Core type aliases for numeric and symbolic Eigen/CasADi interop.
Definition Diagnostics.hpp:19
JanusVector< Scalar > rk4_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Classic 4th-order Runge-Kutta integration step.
Definition IntegratorStep.hpp:131
JanusVector< Scalar > rk2_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Heun's method (RK2) integration step.
Definition IntegratorStep.hpp:88
SecondOrderStepResult< Scalar > rkn4_step(AccelFunc &&acceleration, const JanusVector< Scalar > &q, const JanusVector< Scalar > &v, Scalar t, Scalar dt)
Classical 4th-order Runge-Kutta-Nystrom step for q'' = a(t, q).
Definition IntegratorStep.hpp:193
auto diff(const Eigen::MatrixBase< Derived > &v)
Computes adjacent differences of a vector Returns a vector of size N-1 where out[i] = v[i+1] - v[i].
Definition Calculus.hpp:27
auto eval(const Eigen::MatrixBase< Derived > &mat)
Evaluate a symbolic matrix to a numeric Eigen matrix.
Definition JanusIO.hpp:62
RK45Result< Scalar > rk45_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Dormand-Prince RK45 integration step with embedded error estimate.
Definition IntegratorStep.hpp:250
SecondOrderStepResult< Scalar > stormer_verlet_step(AccelFunc &&acceleration, const JanusVector< Scalar > &q, const JanusVector< Scalar > &v, Scalar t, Scalar dt)
Stormer-Verlet / velocity-Verlet step for q'' = a(t, q).
Definition IntegratorStep.hpp:167
JanusVector< Scalar > euler_step(Func &&f, const JanusVector< Scalar > &x, Scalar t, Scalar dt)
Forward Euler integration step.
Definition IntegratorStep.hpp:62
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > JanusVector
Dynamic-size column vector for both numeric and symbolic backends.
Definition JanusTypes.hpp:49
Result of RK45 step with error estimate.
Definition IntegratorStep.hpp:220
Scalar error
Estimated local truncation error: ||y5 - y4||.
Definition IntegratorStep.hpp:228
JanusVector< Scalar > y4
4th-order solution (used for error estimation)
Definition IntegratorStep.hpp:225
JanusVector< Scalar > y5
5th-order solution (recommended for propagation)
Definition IntegratorStep.hpp:222
Result of a second-order integration step.
Definition IntegratorStep.hpp:28
JanusVector< Scalar > q
Definition IntegratorStep.hpp:29
JanusVector< Scalar > v
Definition IntegratorStep.hpp:30