# Is solving a PDE using ParallelStencil an explicit method?

**URL:** <https://discourse.julialang.org/t/is-solving-a-pde-using-parallelstencil-an-explicit-method/114785>\
**Category:** Modelling & Simulations\
**Created:** [May 27, 2024, 2:15pm UTC](https://discourse.julialang.org/t/is-solving-a-pde-using-parallelstencil-an-explicit-method/114785 "2024-05-27T14:15:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdm204](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdm204/32/39289_2.png) [@jdm204](https://discourse.julialang.org/u/jdm204)\
**Post date:** [May 27, 2024, 2:15pm UTC](https://discourse.julialang.org/t/is-solving-a-pde-using-parallelstencil-an-explicit-method/114785/1 "2024-05-27T14:15:46Z")

</div>

Hi all, I’m trying to implement diffusion in my 3D Agents.jl agent-based model. The “agents” produce or consume substance at each time step, thus changing the local concentration at their grid position x,y,z. I then run Δt diffusion using a stencil from ParallelStencil.jl’s heat equation example.

```julia
function diffusion3D_step!(T2, T, λ, dt, dx, dy, dz)
    @inn(T2) = @inn(T) + dt*(λ*(@d2_xi(T)/dx^2 + @d2_yi(T)/dy^2 + @d2_zi(T)/dz^2));
end

```

My question is, does this amount to an explicit method for solving the heat equation? If so, are there any automated methods in the Julia ecosystem that could slot in here that are implicit? Or should I be looking at linear algebra packages to invert a big matrix?

Apologies if this doesn’t really make sense, I am very new to this, thanks for reading.

---

<div class="post-metadata">

**Author:** ![luraess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luraess/32/16189_2.png) [@luraess](https://discourse.julialang.org/u/luraess)\
**Post date:** [May 27, 2024, 2:28pm UTC](https://discourse.julialang.org/t/is-solving-a-pde-using-parallelstencil-an-explicit-method/114785/2 "2024-05-27T14:28:04Z")

</div>

Hi @jdm204, nice to see your using [ParallelStencil.jl](https://github.com/omlins/ParallelStencil.jl) in your work. The above snippet represents in this context an explicit update. However, depending on your needs, you could use various iterative-based solution approaches to achieve an implicit solution. Relying on direct-iterative approaches (“inverting a big matrix”) may be a bottleneck in 3D. Some hints about (GPU-friendly) iterative implicit approaches in [this paper](https://doi.org/10.5194/gmd-15-5757-2022) and this [course](https://pde-on-gpu.vaw.ethz.ch/lecture3/).

---

<div class="post-metadata">

**Author:** ![jdm204](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jdm204/32/39289_2.png) [@jdm204](https://discourse.julialang.org/u/jdm204)\
**Post date:** [May 27, 2024, 2:39pm UTC](https://discourse.julialang.org/t/is-solving-a-pde-using-parallelstencil-an-explicit-method/114785/3 "2024-05-27T14:39:11Z")

</div>

Hi @luraess - that’s incredibly helpful, thank you! ParallelStencil is great.
