Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to pass Jacobian to IDA via NDSolve
Replies: 0

 Cheol Posts: 1 Registered: 7/11/13
How to pass Jacobian to IDA via NDSolve
Posted: Jul 11, 2013 1:57 AM

According to the IDA manual, when solving DAEs, there is an option to supply J=df/dx+c=E2=88=97df/dx=E2=80=B2(where d is for partial derivatives) to the IDA module. How can I do the same via NDSolve? I tried the following just to see what happens:

vars = { alphan0, alphan1, alphan2, alphan3, alphan4, alphan5};

tvars = { alphan0[t], alphan1[t], alphan2[t], alphan3[t], alphan4[t], alphan5[t};

tvarsp = D[tvars, t];
Jdae1 = D[dae1[[All, 1]], {tvars}] - D[dae1[[All, 2]], {tvars}];
Jdae2 = D[dae1[[All, 1]], {tvarsp}] - D[dae1[[All, 2]], {tvarsp}];
jfun[t_, x_, xp_, c_] := Module[{j, jj},
j = (Jdae1 /. tvars -> x) + c (Jdae2 /. tvarsp -> xp);
Function[# jj] /. jj -> j];

sol3 = First@
NDSolve[{dae1, ic}, vars, {t, 0, 10},
WorkingPrecision -> 25, AccuracyGoal -> 5, PrecisionGoal -> 5,
Method -> {
IDA,
"ImplicitSolver" -> {
"Newton",
"LinearSolveMethod" -> {"Dense", "Jacobian" -> jfun}
}
}
]

Mathematica did not generate any error messages, however I am certain I am not doing it correctly since no difference in output can be observed. Many thanks!