# Transient Stokes - Mass Matrix DAE - Dirichlet Boundary Conditions - Jacobian

**URL:** <https://discourse.julialang.org/t/transient-stokes-mass-matrix-dae-dirichlet-boundary-conditions-jacobian/129459>\
**Category:** Numerics\
**Tags:** question\
**Created:** [May 30, 2025, 8:33am UTC](https://discourse.julialang.org/t/transient-stokes-mass-matrix-dae-dirichlet-boundary-conditions-jacobian/129459 "2025-05-30T08:33:29Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [May 30, 2025, 8:33am UTC](https://discourse.julialang.org/t/transient-stokes-mass-matrix-dae-dirichlet-boundary-conditions-jacobian/129459/1 "2025-05-30T08:33:29Z")

</div>

I am attempting to solve transient Stokes flow in a canonical channel (parabolic inlet, no-slip bottom and top wall, fixed pressure and inlet).  
The Stokes problem leads to a mass-matrix DAE. A naive hand code backward Euler works fine. Next, I an attempting to use DifferentialEquations.jl. The DAE solvers provided by this package are implicit. A Jacobian is thus required.

A finite difference approximation of the Jacobian (using autodiff=AutoFiniteDiff()) fails (I guess) to take the boundary conditions properly into account. Time integration fails.

Is there literature and/or examples of how mass matrix, stiffness matrix and Jacobian ought to be constructed (including boundary conditions) for the DAE solver to converge?

A small example showing what goes wrong is at

> <https://github.com/ziolai/finite_element_electrical_engineering/blob/main/project-based-assignment/metal-hydride-storage/notebooks/stokes_2d_channel_quad_transient.ipynb>

---

<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:** [May 30, 2025, 1:24pm UTC](https://discourse.julialang.org/t/transient-stokes-mass-matrix-dae-dirichlet-boundary-conditions-jacobian/129459/2 "2025-05-30T13:24:44Z")

</div>

All good. Need to read some documentation first.
