Skip to content

Commit 42f40f8

Browse files
committed
Fix DAE initial derivative computation using mass matrix approach
- Compute initial derivatives from ODE function evaluation at t=0 - For differential equations: du0[i] = f_eval[i] / capacitance - For algebraic equations: du0[i] = 0 (KCL constraints) - Ensures consistent initial conditions between mass matrix and DAE formulations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 0d698e8 commit 42f40f8

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

benchmarks/DAE/NANDGateProblem.jmd

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,29 @@ function nand_dae!(out, du, u, p, t)
243243
return nothing
244244
end
245245

246-
# Create DAE problem
246+
# Create DAE problem with proper initial derivatives
247+
# Compute initial derivatives from mass matrix formulation
248+
f_eval = zeros(14)
249+
mmf(f_eval, y0, nothing, 0.0)
250+
251+
# Initial derivatives: M⁻¹ * f for differential equations, 0 for algebraic
247252
du0_dae = zeros(14)
253+
# For differential equations (indices with non-zero mass matrix entries)
254+
du0_dae[1] = f_eval[1] / CGS # y1 derivative
255+
du0_dae[2] = f_eval[2] / CGD # y2 derivative
256+
du0_dae[3] = f_eval[3] / CBS # y3 derivative
257+
du0_dae[4] = f_eval[4] / CBD # y4 derivative
258+
# du0_dae[5] = 0 (algebraic - y5)
259+
du0_dae[6] = f_eval[6] / CGS # y6 derivative
260+
du0_dae[7] = f_eval[7] / CGD # y7 derivative
261+
du0_dae[8] = f_eval[8] / CBS # y8 derivative
262+
du0_dae[9] = f_eval[9] / CBD # y9 derivative
263+
# du0_dae[10] = 0 (algebraic - y10)
264+
du0_dae[11] = f_eval[11] / CGS # y11 derivative
265+
du0_dae[12] = f_eval[12] / CGD # y12 derivative
266+
du0_dae[13] = f_eval[13] / CBS # y13 derivative
267+
du0_dae[14] = f_eval[14] / CBD # y14 derivative
268+
248269
daeprob = DAEProblem(nand_dae!, du0_dae, y0, tspan)
249270

250271
# Generate reference solutions

0 commit comments

Comments
 (0)