RungeKutta2Solver
A popular explicit time integrator. A popular time integration method, much more precise than the EulerSolver */
The `RungeKutta2Solver` implements the second-order Runge-Kutta method for explicit time integration of ordinary differential equations (ODEs) governing position and velocity in SOFA simulations.
- module
- Sofa.Component.ODESolver.Forward
- namespace
- sofa::component::odesolver::forward
- include
- sofa/component/odesolver/forward/RungeKutta2Solver.h
- inherits
-
- OdeSolver
- description
The RungeKutta2Solver implements the second-order Runge-Kutta method, also known as the midpoint method, for explicit time integration in the SOFA framework. This solver is designed to provide more accurate simulation compared to simpler methods like the Euler solver.
Governing Equations and Operators
The governing equations that RungeKutta2Solver solves are given by:
egin{align*}
rac{dx}{dt} &= v(t) \
rac{dv}{dt} &= a(x, t)
dtend*
where $x$ represents the position, $v$ is the velocity, and $a(x,t)$ denotes the acceleration as a function of position and time. The solver advances these state variables over discrete time steps using two stages.
Numerical Methods and Discretization Choices
The RungeKutta2Solver performs numerical integration using the following second-order Runge-Kutta scheme:
egin{align*}
k_1 &= f(x_n, v_n) \
x_{n+1/2} &= x_n + \frac{δ t}{2} v_n \
v_{n+1/2} &= v_n + \frac{δ t}{2} k_1 \
a(x_{n+1/2}, t) & = f(x_{n+1/2}, v_{n+1/2}) \
x_{n+1} &= x_n + δ t v_{n+1/2} \
v_{n+1} &= v_n + δ t a(x_{n+1/2}, t)
dtend*
where $f(x, v)$ denotes the acceleration function that depends on position and velocity. The solver performs these steps in two stages to estimate the next state $(x_{n+1}, v_{n+1})$ based on current forces and accelerations.
Integration Factors
The getIntegrationFactor method returns the integration factors $c_{ij}$ that determine how much an input derivative affects the output derivative at various orders (position, velocity, acceleration):
egin{align}
\mathbf{C} &= δ t \cdot
\begin{pmatrix}
1 & \frac{δ t}{2} & 0 \
0 & 1 & \frac{δ t}{2} \
0 & 0 & 0
¯B
The getSolutionIntegrationFactor method returns the integration factors $c_j$ for a solution of the linear system:
egin{align}
\mathbf{C_v} &= δ t \cdot
\begin{pmatrix}
0 \
\frac{δ t}{2} \
1
¯B
Role in the Global FEM Pipeline
The RungeKutta2Solver plays a critical role in advancing the state of a mechanical system over time within the SOFA simulation pipeline. It is responsible for integrating the equations of motion, specifically position and velocity, using explicit methods that do not require solving large linear systems at each step. This makes it suitable for real-time or interactive simulations.
Interaction with Constraints
The solver interacts with constraints through its solve method by applying constraint resolution steps after computing the next state. It uses the mop.solveConstraint(pos2, core::ConstraintOrder::POS) and mop.solveConstraint(vel2, core::ConstraintOrder::VEL) methods to ensure that positions and velocities satisfy any imposed constraints.
Conclusion
The RungeKutta2Solver provides a precise and efficient method for time integration in SOFA simulations. Its explicit nature allows it to handle complex systems with minimal computational overhead compared to implicit solvers, making it suitable for real-time applications.
Methods
void
solve
(const core::ExecParams * params, SReal dt, sofa::core::MultiVecCoordId xResult, sofa::core::MultiVecDerivId vResult)
virtual
SReal
getIntegrationFactor
(int inputDerivative, int outputDerivative)
virtual
SReal
getSolutionIntegrationFactor
(int outputDerivative)
virtual
{
"name": "RungeKutta2Solver",
"namespace": "sofa::component::odesolver::forward",
"module": "Sofa.Component.ODESolver.Forward",
"include": "sofa/component/odesolver/forward/RungeKutta2Solver.h",
"doc": "A popular explicit time integrator.\n\nA popular time integration method, much more precise than the EulerSolver */",
"inherits": [
"OdeSolver"
],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "solve",
"return_type": "void",
"params": [
{
"name": "params",
"type": "const core::ExecParams *"
},
{
"name": "dt",
"type": "SReal"
},
{
"name": "xResult",
"type": "sofa::core::MultiVecCoordId"
},
{
"name": "vResult",
"type": "sofa::core::MultiVecDerivId"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getIntegrationFactor",
"return_type": "SReal",
"params": [
{
"name": "inputDerivative",
"type": "int"
},
{
"name": "outputDerivative",
"type": "int"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getSolutionIntegrationFactor",
"return_type": "SReal",
"params": [
{
"name": "outputDerivative",
"type": "int"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `RungeKutta2Solver` is an explicit time integrator in the SOFA framework, designed for more precise simulation compared to simpler methods like the Euler solver. It inherits from the `OdeSolver` class and implements the second-order Runge-Kutta method (also known as midpoint method) for numerical integration of ordinary differential equations. This component is responsible for advancing the state of a mechanical system over time in discrete steps, using two stages to estimate the next position and velocity based on current forces and accelerations.\n\nThe `RungeKutta2Solver` interacts with other components through its `solve` method, which takes parameters such as execution context (`core::ExecParams`), time step (`SReal dt`), and identifiers for result positions and velocities (`sofa::core::MultiVecCoordId`, `sofa::core::MultiVecDerivId`). This method computes the next state of the system using the Runge-Kutta 2nd order scheme.\n\nTwo additional methods, `getIntegrationFactor` and `getSolutionIntegrationFactor`, provide factors that determine how much an input derivative affects the output derivative at various orders (position, velocity, acceleration). These factors are crucial for ensuring accurate numerical integration within the SOFA simulation pipeline.",
"maths": "The `RungeKutta2Solver` implements the second-order Runge-Kutta method, also known as the midpoint method, for explicit time integration in the SOFA framework. This solver is designed to provide more accurate simulation compared to simpler methods like the Euler solver.\n\n### Governing Equations and Operators\n\nThe governing equations that `RungeKutta2Solver` solves are given by:\n\n\begin{align*}\n \frac{dx}{dt} &= v(t) \\\n \frac{dv}{dt} &= a(x, t)\n\ndtend*\n\nwhere $x$ represents the position, $v$ is the velocity, and $a(x,t)$ denotes the acceleration as a function of position and time. The solver advances these state variables over discrete time steps using two stages.\n\n### Numerical Methods and Discretization Choices\n\nThe `RungeKutta2Solver` performs numerical integration using the following second-order Runge-Kutta scheme:\n\n\begin{align*}\n k_1 &= f(x_n, v_n) \\\n x_{n+1/2} &= x_n + \\frac{δ t}{2} v_n \\\n v_{n+1/2} &= v_n + \\frac{δ t}{2} k_1 \\\n a(x_{n+1/2}, t) & = f(x_{n+1/2}, v_{n+1/2}) \\\n x_{n+1} &= x_n + δ t v_{n+1/2} \\\n v_{n+1} &= v_n + δ t a(x_{n+1/2}, t)\n\ndtend*\n\nwhere $f(x, v)$ denotes the acceleration function that depends on position and velocity. The solver performs these steps in two stages to estimate the next state $(x_{n+1}, v_{n+1})$ based on current forces and accelerations.\n\n### Integration Factors\n\nThe `getIntegrationFactor` method returns the integration factors $c_{ij}$ that determine how much an input derivative affects the output derivative at various orders (position, velocity, acceleration):\n\n\begin{align*}\n \\mathbf{C} &= δ t \\cdot\n \\begin{pmatrix}\n 1 & \\frac{δ t}{2} & 0 \\\n 0 & 1 & \\frac{δ t}{2} \\\n 0 & 0 & 0\n ¯B*\n\nThe `getSolutionIntegrationFactor` method returns the integration factors $c_j$ for a solution of the linear system:\n\n\begin{align*}\n \\mathbf{C_v} &= δ t \\cdot\n \\begin{pmatrix}\n 0 \\\n \\frac{δ t}{2} \\\n 1\n ¯B*\n\n### Role in the Global FEM Pipeline\n\nThe `RungeKutta2Solver` plays a critical role in advancing the state of a mechanical system over time within the SOFA simulation pipeline. It is responsible for integrating the equations of motion, specifically position and velocity, using explicit methods that do not require solving large linear systems at each step. This makes it suitable for real-time or interactive simulations.\n\n### Interaction with Constraints\n\nThe solver interacts with constraints through its `solve` method by applying constraint resolution steps after computing the next state. It uses the `mop.solveConstraint(pos2, core::ConstraintOrder::POS)` and `mop.solveConstraint(vel2, core::ConstraintOrder::VEL)` methods to ensure that positions and velocities satisfy any imposed constraints.\n\n### Conclusion\n\nThe `RungeKutta2Solver` provides a precise and efficient method for time integration in SOFA simulations. Its explicit nature allows it to handle complex systems with minimal computational overhead compared to implicit solvers, making it suitable for real-time applications.",
"abstract": "The `RungeKutta2Solver` implements the second-order Runge-Kutta method for explicit time integration of ordinary differential equations (ODEs) governing position and velocity in SOFA simulations.",
"sheet": "# RungeKutta2Solver\n\n## Overview\n\nThe `RungeKutta2Solver` is an explicit time integrator component that inherits from the `OdeSolver` class. It implements the second-order Runge-Kutta method (also known as the midpoint method) for numerical integration of ODEs, providing more precise simulation compared to simpler methods like the Euler solver.\n\n## Mathematical Model\n\nThe governing equations solved by the `RungeKutta2Solver` are given by:\n\n\\[ \\frac{dx}{dt} = v(t), \\quad \\frac{dv}{dt} = a(x, t) \\]\n\nwhere $x$ represents position, $v$ is velocity, and $a(x,t)$ denotes acceleration as a function of position and time. The solver advances these state variables over discrete time steps using the following second-order Runge-Kutta scheme:\n\n\\[ k_1 = f(x_n, v_n) \\]\n\\[ x_{n+1/2} = x_n + \\frac{δ t}{2} v_n \\]\n\\[ v_{n+1/2} = v_n + \\frac{δ t}{2} k_1 \\]\n\\[ a(x_{n+1/2}, t) = f(x_{n+1/2}, v_{n+1/2}) \\]\n\\[ x_{n+1} = x_n + δ t v_{n+1/2} \\]\n\\[ v_{n+1} = v_n + δ t a(x_{n+1/2}, t) \\]\n\nwhere $f(x, v)$ denotes the acceleration function that depends on position and velocity. The solver performs these steps in two stages to estimate the next state $(x_{n+1}, v_{n+1})$ based on current forces and accelerations.\n\n## Integration Factors\n\nThe `getIntegrationFactor` method returns the integration factors $c_{ij}$ that determine how much an input derivative affects the output derivative at various orders (position, velocity, acceleration):\n\n\\[ \\mathbf{C} = δ t \\cdot\n\\begin{pmatrix}\n 1 & \\frac{δ t}{2} & 0 \\\\\n 0 & 1 & \\frac{δ t}{2} \\\\\n 0 & 0 & 0\n\\end{pmatrix} \\]\n\nThe `getSolutionIntegrationFactor` method returns the integration factors $c_j$ for a solution of the linear system:\n\n\\[ \\mathbf{C_v} = δ t \\cdot\n\\begin{pmatrix}\n 0 \\\\\n \\frac{δ t}{2} \\\\\n 1\n\\end{pmatrix} \\]"
}