Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

According to the IDA manual, when solving DAEs, there is an option to supply $J = df/dx + c*df/dx'$ (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..., zetas1 };

tvars = { alphan0[t], alphan1[t], alphan2[t], alphan3[t], alphan4[t], alphan5[t], ..., zetas1[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. Many thanks!

share|improve this question
    
can supply the rest of the code? –  user21 Jul 9 '13 at 12:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.