# How to define the DAE using du\[\] style

**URL:** <https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 9, 2024, 7:26am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392 "2024-03-09T07:26:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![whucsu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/whucsu/32/207015_2.png) [@whucsu](https://discourse.julialang.org/u/whucsu)\
**Post date:** [March 9, 2024, 7:26am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/1 "2024-03-09T07:26:58Z")

</div>

here is another windkessel model in the simulation, from “The differential-algebraic Windkessel model with power as input” by Henry Pigot.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/6/867d4ef78efe40318a2f4def1f137decc3b345a6.png)  
I don’t know to define the DAE using Julia common package like [DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/), as the bellow style.  
function lorenz(u, p, t)  
dx = 10.0 \* (u[2] - u[1])  
dy = u[1] \* (28.0 - u[3]) - u[2]  
dz = u[1] \* u[2] - (8 / 3) \* u[3]  
[dx, dy, dz]  
end  
Finally, I want to use the ODEProblem() to solve it and do some parameter estimations.  
thanks for any suggestions.  
whu

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [March 9, 2024, 9:12am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/2 "2024-03-09T09:12:05Z")

</div>

You can either define a mass matrix (with zeros on the diagonal for algebraic equations).

Or, you could provide a vector of Booleans for denoting which variables are differential/algebraic.

See the examples here: [Differential Algebraic Equations · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/dae_example/)

---

<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:** [March 14, 2024, 7:45am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/4 "2024-03-14T07:45:39Z")

</div>

What have you tried?

---

<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:** [March 14, 2024, 9:43am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/6 "2024-03-14T09:43:28Z")

</div>

Did you follow the tutorial and try writing one?

---

<div class="post-metadata">

**Author:** ![whucsu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/whucsu/32/207015_2.png) [@whucsu](https://discourse.julialang.org/u/whucsu)\
**Post date:** [March 15, 2024, 4:21am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/8 "2024-03-15T04:21:33Z")

</div>

[elbert5770](https://discourse.julialang.org/u/elbert5770)  
would you please give any suggestions?

---

<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:** [March 15, 2024, 9:45am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/10 "2024-03-15T09:45:32Z")

</div>

I don’t think it’s ethical for us to do your homework for you. But the advice I would have is to just use ModelingToolkit.jl for defining and solving the DAE system.

> **[Home · ModelingToolkit.jl](https://docs.sciml.ai/ModelingToolkit/stable/)**
>
> Documentation for ModelingToolkit.jl.

There’s some other real-world advantages you’d get from that as well, since it would ensure the DAE is lowered to index 1 form.

---

<div class="post-metadata">

**Author:** ![whucsu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/whucsu/32/207015_2.png) [@whucsu](https://discourse.julialang.org/u/whucsu)\
**Post date:** [March 16, 2024, 12:58am UTC](https://discourse.julialang.org/t/how-to-define-the-dae-using-du-style/111392/11 "2024-03-16T00:58:03Z")

</div>

> [@ChrisRackauckas](#):
>
> I don’t think it’s ethical for us to do your homework for you

thanks. I am learning Julia following the examples, not mean my homework.  
this is open discourse, anyone who once solved the samilary question can give suggestion or just pass by.  
I am always grateful for the helps I got here.
