Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a stiff differential equation solver #7384

Open
calcmogul opened this issue Nov 12, 2024 · 1 comment
Open

Implement a stiff differential equation solver #7384

calcmogul opened this issue Nov 12, 2024 · 1 comment
Labels
component: wpimath Math library effort: 5 type: fix Iterations on existing features or infrastructure.

Comments

@calcmogul
Copy link
Member

calcmogul commented Nov 12, 2024

Sometimes, the physics sim differential equations are stiff enough that the default solver takes way too long because it takes very small steps to stay below the error bound. We should add a higher order solver designed for stiff differential equations.

We should also automatically select the appropriate algorithm for a given problem:
https://docs.sciml.ai/DiffEqDocs/stable/getting_started/#Choosing-a-Solver-Algorithm

@calcmogul calcmogul added component: wpimath Math library effort: 5 type: fix Iterations on existing features or infrastructure. labels Nov 12, 2024
@calcmogul
Copy link
Member Author

calcmogul commented Dec 6, 2024

Here's a candidate method: https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.Radau.html aka radau5. It's an implicit 5th order method. I haven't found the paper yet, but the scipy docs imply it uses sparse linear algebra, so something bespoke with Eigen::SimplicialLDLT or a problem built in Sleipnir may be warranted.

Here's the Butcher tableau for 5th order Radau IIA: https://en.wikipedia.org/wiki/List_of_Runge%E2%80%93Kutta_methods#Radau_IIA_methods

The gist of implicit methods seems to be rootfinding. For example, solving k₁ = f(yₙ + hk₁) for k₁ (or f(yₙ + hk₁) − k₁) = 0 for k₁) where dy/dt = f(y), then computing yₙ₊₁ = yₙ = hk₁.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wpimath Math library effort: 5 type: fix Iterations on existing features or infrastructure.
Projects
None yet
Development

No branches or pull requests

1 participant