# Current state of reaction-diffusion solvers with ModelingToolkit

**URL:** <https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492>\
**Category:** General Usage\
**Tags:** modelingtoolkit, differentialequation\
**Created:** [August 22, 2024, 4:32pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492 "2024-08-22T16:32:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alicanter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alicanter/32/34615_2.png) [@Alicanter](https://discourse.julialang.org/u/Alicanter)\
**Post date:** [August 22, 2024, 4:32pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/1 "2024-08-22T16:32:54Z")

</div>

I am trying to solve a reaction-diffusion in Julia.  
I’ve worked with ModelingToolkit and the SciML ecosystem before, but it seems that with PDEs there is not a single best way to solve them.

The simplest way I found to solve the PDE is using MethodOfLines.jl, but the discretization is quite slow for slightly large 2D problems.  
I’ve also seen ParallelStencil.jl which looks promising and has been suggested ([Issue solving 2D wave equation with ModelingToolkit.jl - #10 by ChrisRackauckas](https://discourse.julialang.org/t/issue-solving-2d-wave-equation-with-modelingtoolkit-jl/62963/10)), but I was not able to figure it out how to use with ModelingToolkit.jl.

I am in no need of complex geometries or anything, just want to work with simple rectangular toroidal domains or use Neumann boundary conditions at the edges (du/dt = 0).  
Is there a simple way to solve a system like that? Any reccomendations are appreciated.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 26, 2024, 11:03am UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/2 "2024-08-26T11:03:47Z")

</div>

There is not a single best way to solve such systems right now. The best way performance is still to write it out by hand, and there are some tutorials that show how to do this the best way:

> **[Code Optimization for Differential Equations · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/faster_ode_example/#Example-Accelerating-Linear-Algebra-PDE-Semi-Discretization)**
>
> Documentation for DifferentialEquations.jl.

> **[Solving Large Stiff Equations · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/)**
>
> Documentation for DifferentialEquations.jl.

ParallelStencil does not make sense for these types of equations as the overhead of the reaction term makes it so that way the stenciling loop shouldn’t be optimized and instead its more optimal to fold it in with the reaction loop, meaning that you do a single naive pass. This is only not true if the reactions are linear, and thus you have a fully linear system, and then you would still merge the two components into a loop but now you’d have a fully linear stencil and use ParallelStencil. But having a linear reaction essentially never happens so that’s just an oddity to mention in passing.

MethodOfLines.jl does this codegen to the fused form but is currently not loop preserving. We’re working on getting that into JuliaSimCompiler and via array equation support, but currently it won’t do as the by-hand solution here.

---

<div class="post-metadata">

**Author:** ![Alicanter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alicanter/32/34615_2.png) [@Alicanter](https://discourse.julialang.org/u/Alicanter)\
**Post date:** [August 27, 2024, 1:20pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/3 "2024-08-27T13:20:04Z")

</div>

So the best solution is to keep using DifferentialEquations.jl and writing the equations as functions by hand instead of creating ModelingToolkit.jl models? Or is there a way to do the same with ModelingToolkit.jl?

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [August 27, 2024, 1:25pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/4 "2024-08-27T13:25:27Z")

</div>

Alternative to MTK, there is also FiniteVolumeMethod.jl for this which is made for reaction-diffusion type problems, depending on what you need.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [August 27, 2024, 4:15pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/5 "2024-08-27T16:15:30Z")

</div>

There is `Gridap.jl` which is great!

---

<div class="post-metadata">

**Author:** ![Alicanter](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alicanter/32/34615_2.png) [@Alicanter](https://discourse.julialang.org/u/Alicanter)\
**Post date:** [August 27, 2024, 5:48pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/6 "2024-08-27T17:48:29Z")

</div>

Is there a way to use ModelingToolkit.jl models/equations in Gridap.jl? Or interoperability with SciML packages? I know about the package and would be awesome if that’s the case.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 27, 2024, 7:36pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/7 "2024-08-27T19:36:05Z")

</div>

It’s generally easier to connect to Ferrite.jl

---

<div class="post-metadata">

**Author:** ![j-fu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j-fu/32/11373_2.png) [@j-fu](https://discourse.julialang.org/u/j-fu)\
**Post date:** [August 27, 2024, 9:03pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/8 "2024-08-27T21:03:27Z")

</div>

We recently set up an example for connecting VoronoiFVM.jl with Catalyst.jl, which is bases on ModelingToolkit.jl: [Coupling with Catalyst.jl · VoronoiFVM.jl](https://j-fu.github.io/VoronoiFVM.jl/dev/plutostatichtml_examples/heterogeneous-catalysis/) This is an example for hererogeneous reactions. May be I will make another example just for reaction-diffusion.

---

<div class="post-metadata">

**Author:** ![jewh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jewh/32/28586_2.png) [@jewh](https://discourse.julialang.org/u/jewh)\
**Post date:** [December 17, 2025, 4:33pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/9 "2025-12-17T16:33:07Z")

</div>

Bit late but [GitHub - hiscocklab/ReactionDiffusion.jl](https://github.com/hiscocklab/ReactionDiffusion.jl)

---

<div class="post-metadata">

**Author:** ![ziolai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ziolai/32/23422_2.png) [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Post date:** [December 17, 2025, 5:33pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/10 "2025-12-17T17:33:18Z")

</div>

What does “fused form” mean here? My students stumbled into MethodOfLines generating much smaller systems than expected. How does the use of method.symplify feed into this?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [December 18, 2025, 9:49pm UTC](https://discourse.julialang.org/t/current-state-of-reaction-diffusion-solvers-with-modelingtoolkit/118492/11 "2025-12-18T21:49:48Z")

</div>

See the final form here:

> **[Example Accelerating Linear Algebra PDE Semi-Discretization - Code Optimization...](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/faster_ode_example/#Example-Accelerating-Linear-Algebra-PDE-Semi-Discretization)**
>
> See this FAQ for information on common pitfalls and how to improve performance. | Documentation for DifferentialEquations.jl.
