# Using integrator time derivative for implementing residual viscosity with DiffEq.jl

**URL:** <https://discourse.julialang.org/t/using-integrator-time-derivative-for-implementing-residual-viscosity-with-diffeq-jl/90216>\
**Category:** Modelling & Simulations\
**Created:** [November 14, 2022, 1:48am UTC](https://discourse.julialang.org/t/using-integrator-time-derivative-for-implementing-residual-viscosity-with-diffeq-jl/90216 "2022-11-14T01:48:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarias9](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jarias9](https://discourse.julialang.org/u/jarias9)\
**Post date:** [November 14, 2022, 1:48am UTC](https://discourse.julialang.org/t/using-integrator-time-derivative-for-implementing-residual-viscosity-with-diffeq-jl/90216/1 "2022-11-14T01:48:46Z")

</div>

Hello all,

I have been trying to implement a concept known as residual viscosity to stabilize a fluid simulation inside of DiffEq.jl.

In general, I would need access to the derivative of the integrator in order to do this. I know there is a way to access the value after the fact, such as with the `SciMLBase.get_du` function, however I need the derivative value inside the hot loop for my du function. I currently have tried a very hacky way of doing this where I save previous timesteps in cache variables and then calculate what the derivative is via the previous timesteps and a BDF4 formula. Just thought I would post here since I am not sure of what I could try as far as just directly accessing the integrator. To elaborate, I am using the problem interface in DiffEq.jl.

Thanks

---

<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:** [November 15, 2022, 8:42am UTC](https://discourse.julialang.org/t/using-integrator-time-derivative-for-implementing-residual-viscosity-with-diffeq-jl/90216/2 "2022-11-15T08:42:04Z")

</div>

This isn’t an ODE, it’s a DDE.

---

<div class="post-metadata">

**Author:** ![jarias9](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jarias9](https://discourse.julialang.org/u/jarias9)\
**Post date:** [November 15, 2022, 3:39pm UTC](https://discourse.julialang.org/t/using-integrator-time-derivative-for-implementing-residual-viscosity-with-diffeq-jl/90216/3 "2022-11-15T15:39:38Z")

</div>

Ah I see. Looking at the DDE interface, it looks like exactly what I need. Thanks again.
