Library / SDK
NeuroDiffGym/neurodiffeq avatar
NeuroDiffGym/neurodiffeq

neurodiffeq: Solving ODEs and PDEs with PyTorch Networks

A library for solving differential equations using neural networks based on PyTorch, used by multiple research groups around the world, including at Harvard IACS.

790 stars106 forksPythonMIT

At a glance

What is it?
neurodiffeq is an MIT-licensed Python library that turns differential equations into neural network training problems. It is a research tool for people who want a continuous, differentiable solution rather than a grid of numbers.
Who is it for?
Adopt neurodiffeq if you are doing research on physics-informed neural networks or need a differentiable, mesh-free solution to a low-dimensional ODE or PDE and are willing to tune network architecture and training yourself. Do not adopt it if you need a production-grade solver with error bounds, or if your problem is high-dimensional and well handled by finite element or finite difference code.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 146 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

What neurodiffeq replaces, and for whom

Traditional numerical solvers for differential equations, such as finite difference and finite element methods, represent the solution as values on a discretized grid. The README states that their expressibility is limited by that function representation, and that it would be interesting to compute solutions that are continuous and differentiable. neurodiffeq takes the other route: it approximates the unknown function with a neural network and trains it until the equation residual is small. The audience is narrow and identifiable. It is researchers in scientific computing and physics-informed machine learning who already work in PyTorch and want the solution as a callable object they can differentiate through, rather than a lookup table. The README notes the library is used by multiple research groups, including at Harvard IACS, and points to a 2020 JOSS paper plus a 2025 arXiv paper by Liu, Protopapas, Sondak and Chen. That publication trail matters more than any popularity metric: it tells you the method has been described and reviewed in a journal venue, not just pushed to a repository.

The mechanism: residual loss over collocation points

The architecture is visible in the two worked examples. You write the equation as a Python function that returns residuals. For the Lotka-Volterra system the function returns diff(u,t)-(u-u*v) and diff(v,t)-(u*v-v); for the Laplace problem it returns diff(u,x,order=2)+diff(u,y,order=2). The diff function is imported from neurodiffeq itself, which means differentiation is symbolic on the expression tree rather than numerical, and the derivative is evaluated at the network's output. Conditions are separate objects: IVP for initial values, DirichletBVP2D for boundary values, with callables such as lambda y: torch.sin(np.pi*y) supplying the boundary data. Networks come from the networks module, for instance FCNN with a SinActv activation, and are passed to the solver as a list, one network per unknown function. Solver1D and Solver2D take the residual function, the conditions, the domain bounds (t_min and t_max, or xy_min and xy_max) and the networks, then expose fit(max_epochs=...) and get_solution(). The returned solution is callable and accepts numpy arrays or torch tensors, with a to_numpy=True flag on the call. So the data flow is: sample points in the domain, push them through the network, differentiate the output symbolically, evaluate the residual and the condition violations, and backpropagate. Nothing in the README suggests adaptive meshing or error control. The accuracy you get is the accuracy the optimizer reaches.

Installation and the version question

The pip path is a single command: pip install -U neurodiffeq. The manual path is for contributors and gives early access to unreleased features: git clone the repository, cd into it, pip install -r requirements, then pip install . (or pip install -e . to edit the library in place). The README also lists pytest tests/ as an optional step. That last command is worth taking seriously rather than skipping, because the documented API has moved between releases. The release list shows v0.7.0 in July 2025, v0.6.3 in January 2024 and v0.6.2 in June 2023, and the README itself carries a note that a second paper was published and that users should cite both if they use features that became available after the 2020 version. In other words, the feature set is not frozen, and code written against an older tutorial may not match the current Solver1D signature. Pin your version in requirements and check the Read the Docs build for the matching tag before you copy example code.

Where the approach breaks down

The README is unusually candid on one point: the Laplace example was chosen for the simplicity of its analytical solution, and the text adds that in practice you can attempt any nonlinear, chaotic PDEs, provided you tune the solver well enough. That clause carries the real cost. There is no convergence guarantee in the material, no residual tolerance you can set and trust, and no stated bound on the error of the returned solution. Training is a hyperparameter search: network depth and width (the example uses hidden_units=(512,) and n_input_units=2), activation choice, learning rate, collocation sampling and epoch count all interact. A second limitation follows from the first. Because the solution is a global network fit rather than a local discretization, sharp gradients, shocks and boundary layers are exactly the regimes where a single smooth approximator struggles, and the README offers no specialized treatment for them. Finally, the dimensionality: Solver1D and Solver2D are the named solvers, so if your problem lives in three spatial dimensions plus time, the documented surface does not cover it. If you need a guaranteed error bar, a convergence proof, or a solver that a non-specialist can run unattended, this is the wrong tool and a classical package is the right one.

What it offers that a classical solver does not

The comparison that matters is not accuracy per step but what the output is. A finite element package returns nodal values on a mesh you had to build, and refining that mesh in high dimensions is where the cost explodes. neurodiffeq returns a function you can evaluate anywhere in the domain and differentiate symbolically, which is the property that makes it useful inside an inverse problem or an optimization loop. The README also advertises solution bundles and reverse problems, pointing to a dedicated section for them, which is the feature set the 2025 paper covers. If your goal is to infer an unknown coefficient or boundary condition from observations, having a differentiable surrogate as the forward model is a structural advantage, not a performance one. Against that, a mature finite difference or finite element stack gives you decades of validated error analysis, adaptive refinement and preconditioners. neurodiffeq gives you flexibility of representation and pays for it in tuning effort and the absence of guarantees. Choose based on which of those two you actually need.

Maintenance, licensing and upgrade cost

The licence is MIT, which is permissive: you can use, modify and redistribute the code, including in closed products, provided the copyright notice and permission notice are retained. That is a summary of the identifier, not legal advice, and if you are shipping this inside a commercial product you should read the LICENSE file in the repository yourself. On maintenance, the repository is not archived, the default branch is master, and the most recent push recorded is April 2026, with v0.7.0 released in July 2025. That is an active but slow cadence: roughly one feature release per year across the last three listed versions. The practical upgrade cost is the API drift already noted. Because the maintainers explicitly distinguish pre-2020 and post-2020 features, an upgrade can change both behaviour and which paper you are expected to cite. Budget for re-running your own convergence checks after any minor version bump, and keep your equations and conditions in separate modules so that a signature change in Solver1D or Solver2D touches one file rather than your whole codebase.

Editorial conclusion

Adopt neurodiffeq if you are doing research on physics-informed neural networks or need a differentiable, mesh-free solution to a low-dimensional ODE or PDE and are willing to tune network architecture and training yourself. Do not adopt it if you need a production-grade solver with error bounds, or if your problem is high-dimensional and well handled by finite element or finite difference code. Before committing, verify that the release you install matches the API in the README (v0.7.0 is the newest listed release), run the bundled test suite after a manual install, and confirm which of the two cited papers covers the features you actually use, since the maintainers ask you to cite both if you rely on post-2020 functionality.

Official sources

  1. License: MIT
  2. NeuroDiffGym/neurodiffeq on GitHub
  3. Project website
  4. README
  5. Releases
Community notes

Community notes