# How to solve partial differential algebraic equations

**URL:** <https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989>\
**Category:** New to Julia\
**Tags:** pde\
**Created:** [May 8, 2024, 10:26am UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989 "2024-05-08T10:26:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anish\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anish_kumar/32/202471_2.png) [@Anish\_Kumar](https://discourse.julialang.org/u/Anish_Kumar)\
**Post date:** [May 8, 2024, 10:26am UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/1 "2024-05-08T10:26:28Z")

</div>

Hi all,

I am quite new to Julia and programming in general. I am currently doing a modelling PhD and I have a set of couple Partial Differential Algebraic Equations (PDAE). I tried solving them on comsol but it is extremely cumbersome trying to rewrite the equations into a format that comsol accepts. So I was wondering if there is a PDAE solver in Julia since I want to eventually shift to a Julia solver for my PhD. Any help will be appreciated thanks in advance.

---

<div class="post-metadata">

**Author:** ![Albert\_Zevelev](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albert_zevelev/32/11844_2.png) [@Albert\_Zevelev](https://discourse.julialang.org/u/Albert_Zevelev)\
**Post date:** [May 8, 2024, 11:10am UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/2 "2024-05-08T11:10:56Z")

</div>

Here is a guide to the pde ecosystem in Julia: [GitHub - JuliaPDE/SurveyofPDEPackages: Survey of the packages of the Julia ecosystem for solving partial differential equations](https://github.com/JuliaPDE/SurveyofPDEPackages)

EconPDEs.jl for example solves pdaes, but a very specific type that arise in economics (from HJBs with nonlinear concave objective functions)…  
I don’t think there is a general package yet

---

<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:** [May 8, 2024, 1:04pm UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/3 "2024-05-08T13:04:28Z")

</div>

what kind of PDE do you have?

---

<div class="post-metadata">

**Author:** ![Anish\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anish_kumar/32/202471_2.png) [@Anish\_Kumar](https://discourse.julialang.org/u/Anish_Kumar)\
**Post date:** [May 8, 2024, 3:45pm UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/4 "2024-05-08T15:45:52Z")

</div>

Hi Chris,

Thank you for replying.

 ![WhatsApp Image 2024-05-08 at 17.41.06_340e01be](https://global.discourse-cdn.com/julialang/original/3X/0/2/02d750274abb876f2c2dd2af8b3fb6adb8381845.jpeg)  
The equations are a set of equations for modelling a battery but unfortunately I cannot use existing packages such as JuBatt since the configuration is very different than them. The solver needs to solve for 7 dependent variables - 5 concentration terms C\_OH, C\_Zn, C\_ZnO, C\_H20, C\_K and two potential variables phi\_l and phi\_s. So as you can see the equation 5 is the problematic term here since it is an algebraic equation so I am not sure how to write it in a PDE solver in Julia.

Also on top of that, the exponent adds non linearity to the equations so I am not to able to right away start solving this by direct discretization.

PS Apologies for the handwritten equations. Please let me know if you do not understand something in there.

---

<div class="post-metadata">

**Author:** ![MarcBerliner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcberliner/32/14883_2.png) [@MarcBerliner](https://discourse.julialang.org/u/MarcBerliner)\
**Post date:** [May 8, 2024, 6:04pm UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/5 "2024-05-08T18:04:55Z")

</div>

What assumptions are you making about this system? Is this within a single section of the cell, such as the electrode? Are the diffusivities and conductivities constant? I would check out MethodOfLines.jl for simulating coupled PDAEs. It handles the discretizations, boundary conditions, algebraic equations, and fully supports nonlinear terms such as the BV kinetics.

---

<div class="post-metadata">

**Author:** ![Anish\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anish_kumar/32/202471_2.png) [@Anish\_Kumar](https://discourse.julialang.org/u/Anish_Kumar)\
**Post date:** [May 9, 2024, 8:16pm UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/6 "2024-05-09T20:16:53Z")

</div>

Thank you for your reply @MarcBerliner. I will check MOL package first to look at the possibility.  
The diffusivities and conductivities are actually functions of concentration but now for the sake of simplicity to get started i am assuming them to be constant. The model is for a spherical coordinate system.

---

<div class="post-metadata">

**Author:** ![balaji\_sriram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balaji_sriram/32/208000_2.png) [@balaji\_sriram](https://discourse.julialang.org/u/balaji_sriram)\
**Post date:** [May 30, 2024, 7:45am UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/7 "2024-05-30T07:45:14Z")

</div>

@Anish_Kumar , I also solve similar equations for my research. I can see that you are solving, non-linear convection-diffusion-reaction problem. The usual procedure for solving such problems is this:

1. convert the differential-equations (time-independent- in your case i think it is 5,6 and 7) to difference equations. [MethodOfLines.jl](https://juliahub.com/ui/Packages/General/MethodOfLines) must surely be of help. Or if you are good at FEA coding, you can construct and load the sparse-stiffness matrix into julia. Even if youre good at FEA, its a good idea to use julia inbuit poisson solvers in case youre working with higher dimensions 3D problem.
2. I can see that you have 5 species, give appropriate initial conditions, and use [differentialEquations.jl] package to solve the ODEs. In case you are using your own FEA routine, In the ODE function definition -remember to include solution to potential (Phi = InvK\*F, ) using this command:  
prob = LinearProblem(K\_stiffness , Force);  
@time sol = solve(prob,LinearSolve.KrylovJL\_CG(),maxiter = 1000);  
Code the other dynamics appropriatey, look into differentialEquations.jl documentation for the same.

---

<div class="post-metadata">

**Author:** ![Anish\_Kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anish_kumar/32/202471_2.png) [@Anish\_Kumar](https://discourse.julialang.org/u/Anish_Kumar)\
**Post date:** [April 3, 2025, 3:04pm UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/8 "2025-04-03T15:04:34Z")

</div>

Thank you for your reply Balaji. Is there an example case or some write up I can follow to solve this? I come from a non numerical background so my numerical skills are pretty nascent at this point. Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![balaji\_sriram](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balaji_sriram/32/208000_2.png) [@balaji\_sriram](https://discourse.julialang.org/u/balaji_sriram)\
**Post date:** [April 15, 2025, 8:09am UTC](https://discourse.julialang.org/t/how-to-solve-partial-differential-algebraic-equations/113989/9 "2025-04-15T08:09:10Z")

</div>

Hi Anish. Contact me at balajis@iitk.ac.in. Ill find time to help you out with an online meeting.
