Class RKSolver

Class Documentation

class RKSolver

Class that defines a 4 and 5th order Runge-Kutta method.

This is a “bespoke” Runge-Kutta formula based on the nodes used in 5th and 6th order Gauss-Lobatto integration, as detailed in [1].

[1] Agocs, F. J., et al. “Efficient Method for Solving Highly Oscillatory Ordinary Differential Equations with Applications to Physical Systems.” Physical Review Research, vol. 2, no. 1, 2020, doi:10.1103/physrevresearch.2.013030.

Public Functions

RKSolver()

Callable that gives the frequency term in the ODE at a given time

Default constructor.

RKSolver(de_system &de_sys)

Constructor for the RKSolver class. It sets up the Butcher tableaus for the two Runge-Kutta methods (4th and 5th order) used.

Parameters

de_sys[in] – the system of first-order equations defining the second-order ODE to solve.

Eigen::Matrix<std::complex<double>, 2, 2> step(std::complex<double>, std::complex<double>, double, double)
Eigen::Matrix<std::complex<double>, 1, 2> f(double t, const Eigen::Matrix<std::complex<double>, 1, 2> &y)

Turns the second-order ODE into a system of first-order ODEs as follows:

\[ y = [x, \dot{x}], \]
\[ \dot{y[0]} = y[1], \]
\[ \dot{y[1]} = -\omega^2(t)y[0] -2\gamma(t)y[1]. \]

Parameters
  • t[in] – time \( t \)

  • y[in] – vector of unknowns \( y = [x, \dot{x}] \)

Returns

a vector of the derivative of \( y \)

Eigen::Matrix<std::complex<double>, 1, 2> dense_point(std::complex<double> x, std::complex<double> dx, const Eigen::Matrix<std::complex<double>, 6, 2> &k5)
void dense_step(double t0, double h0, std::complex<double> y0, std::complex<double> dy0, const std::list<double> &dots, std::list<std::complex<double>> &doxs, std::list<std::complex<double>> &dodxs)

Public Members

de_system *de_sys_

Defines the ODE

Eigen::Matrix<std::complex<double>, 6, 1> ws

6 values of the frequency term per step, evaluated at the nodes of 6th order Gauss-Lobatto quadrature

Eigen::Matrix<std::complex<double>, 6, 1> gs

6 values of the friction term per step, evaluated at the nodes of 6th order Gauss-Lobatto quadrature

Eigen::Matrix<std::complex<double>, 5, 1> ws5

5 values of the frequency term per step, evaluated at the nodes of 5th order Gauss-Lobatto quadrature

Eigen::Matrix<std::complex<double>, 5, 1> gs5

5 values of the friction term per step, evaluated at the nodes of 5th order Gauss-Lobatto quadrature

Eigen::Matrix<std::complex<double>, 6, 2> k5
Eigen::Matrix<std::complex<double>, 7, 2> k_dense
Eigen::Matrix<double, 7, 4> P_dense
Eigen::Matrix<std::complex<double>, 7, 1> x_vdm