GitPedia

DiffEqCallbacks.jl

A library of useful callbacks for hybrid scientific machine learning (SciML) with augmented differential equation solvers

From SciML·Updated June 26, 2026·View on GitHub·

[DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/) has an expressive callback system which allows for customizable transformations of the solver behavior. DiffEqCallbacks.jl is a library of pre-built callbacks which makes it easy to transform the solver into a domain-specific simulation tool. The project is written primarily in Julia, distributed under the Other license, first published in 2017. Key topics include: callback, dae, dde, differential-equations, julia.

Latest release: v4.18.0
June 25, 2026View Changelog →

DiffEqCallbacks.jl: Prebuilt Callbacks for extending the solvers of DifferentialEquations.jl

Join the chat at https://julialang.zulipchat.com #sciml-bridged
Global Docs

codecov
Build Status

ColPrac: Contributor's Guide on Collaborative Practices for Community Packages
SciML Code Style

DifferentialEquations.jl has an expressive callback system
which allows for customizable transformations of the solver behavior. DiffEqCallbacks.jl
is a library of pre-built callbacks which makes it easy to transform the solver into a
domain-specific simulation tool.

Tutorials and Documentation

For information on using the package,
see the stable documentation. Use the
in-development documentation for the version of
the documentation, which contains the unreleased features.

Manifold Projection Example

Here we solve the harmonic oscillator:

julia
using OrdinaryDiffEq u0 = ones(2) function f(du, u, p, t) du[1] = u[2] du[2] = -u[1] end prob = ODEProblem(f, u0, (0.0, 100.0))

However, this problem is supposed to conserve energy, and thus we define our manifold
to conserve the sum of squares:

julia
function g(resid, u, p, t) resid[1] = u[2]^2 + u[1]^2 - 2 end

To build the callback, we call

julia
using DiffEqCallbacks, ADTypes cb = ManifoldProjection(g, autodiff = AutoForwardDiff(), resid_prototype = zeros(1))

Using this callback, the Runge-Kutta method Vern7 conserves energy. Note that the
standard saving occurs after the step and before the callback, and thus we set
save_everystep=false to turn off all standard saving and let the callback
save after the projection is applied.

julia
using Test sol = solve(prob, Vern7(), save_everystep = false, callback = cb) @test sol.u[end][1]^2 + sol.u[end][2]^22

manifold_projection

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from SciML/DiffEqCallbacks.jl via the GitHub API.Last fetched: 6/27/2026