Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork238
High performance ordinary differential equation (ODE) and differential-algebraic equation (DAE) solvers, including neural ordinary differential equations (neural ODEs) and scientific machine learning (SciML)
License
SciML/OrdinaryDiffEq.jl
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
OrdinaryDiffEq.jl is a component package in the DifferentialEquations ecosystem. It holds theordinary differential equation solvers and utilities. While completely independentand usable on its own, users interested in using thisfunctionality should check outDifferentialEquations.jl.
Assuming that you already have Julia correctly installed, it suffices to importOrdinaryDiffEq.jl in the standard way:
import Pkg;Pkg.add("OrdinaryDiffEq");
OrdinaryDiffEq.jl is part of the SciML common interface, but can be used independently of DifferentialEquations.jl. The only requirement is that the user passes an OrdinaryDiffEq.jl algorithm tosolve. For example, we can solve theODE tutorial from the docs using theTsit5() algorithm:
using OrdinaryDiffEqf(u, p, t)=1.01* uu0=1/2tspan= (0.0,1.0)prob=ODEProblem(f, u0, tspan)sol=solve(prob,Tsit5(), reltol=1e-8, abstol=1e-8)using Plotsplot(sol, linewidth=5, title="Solution to the linear ODE with a thick line", xaxis="Time (t)", yaxis="u(t) (in μm)", label="My Thick Line!")# legend=falseplot!(sol.t, t->0.5*exp(1.01t), lw=3, ls=:dash, label="True Solution!")
That example uses the out-of-place syntaxf(u,p,t), while the inplace syntax (more efficient for systems of equations) is shown in the Lorenz example:
using OrdinaryDiffEqfunctionlorenz!(du, u, p, t) du[1]=10.0(u[2]- u[1]) du[2]= u[1]* (28.0- u[3])- u[2] du[3]= u[1]* u[2]- (8/3)* u[3]endu0= [1.0;0.0;0.0]tspan= (0.0,100.0)prob=ODEProblem(lorenz!, u0, tspan)sol=solve(prob,Tsit5())using Plots;plot(sol, idxs= (1,2,3))
Very fast static array versions can be specifically compiled to the size of your model. For example:
using OrdinaryDiffEq, StaticArraysfunctionlorenz(u, p, t) SA[10.0(u[2]- u[1]), u[1]* (28.0- u[3])- u[2], u[1]* u[2]- (8/3)* u[3]]endu0= SA[1.0;0.0;0.0]tspan= (0.0,100.0)prob=ODEProblem(lorenz, u0, tspan)sol=solve(prob,Tsit5())
For "refined ODEs", like dynamical equations andSecondOrderODEProblems, refer to theDiffEqDocs. For example, inDiffEqTutorials.jl we show how to solve equations of motion using symplectic methods:
functionHH_acceleration!(dv, v, u, p, t) x, y= u dx, dy= dv dv[1]=-x-2x* y dv[2]= y^2- y- x^2endinitial_positions= [0.0,0.1]initial_velocities= [0.5,0.0]prob=SecondOrderODEProblem(HH_acceleration!, initial_velocities, initial_positions, tspan)sol2=solve(prob,KahanLi8(), dt=1/10);
Other refined forms are IMEX and semi-linear ODEs (for exponential integrators).
For the list of available solvers, please refer to theDifferentialEquations.jl ODE Solvers,Dynamical ODE Solvers, and theSplit ODE Solvers pages.
About
High performance ordinary differential equation (ODE) and differential-algebraic equation (DAE) solvers, including neural ordinary differential equations (neural ODEs) and scientific machine learning (SciML)
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.