Hello Anirudh,
I'm not sure that I completely understand what you're attempting here, but let me answer some at-least-hopefully-related questions.
While ARKODE is designed to solve ODE IVPs that include a potentially time-dependent mass matrix, e.g., M(t) ds/dt = f1(s,t) + f2(s,t), where f1 is treated implicitly and f2 explicitly, it currently requires that the matrix M(t) be nonsingular. Thus, it is
not currently designed to support DAEs (that would typically have singular M), although that kind of extension is under consideration. If you truly have a DAE, then IDA is the best option in SUNDIALS.
Turning to your KINSOL issues, it is unclear to me what you implemented in Python, so I cannot comment on how that implementation differs from your use of KINSOL.
However, if your CSR implementation of the Jacobian is correct (and a direct solve is not too costly with respect to memory or computational time), then the KLU solve should be more robust than GMRES (even with a preconditioner). However, given that KLU fails
for you, then I question (a) the accuracy of the CSR Jacobian, and/or (b) the initial guess provided to KINSOL. If your Python implementation uses the same initial guess as you supply to KINSOL, then that would leave only the CSR Jacobian. Is it possible
to coarsen the problem somewhat and try to use the dense linear solver with difference-quotient Jacobian approximation (i.e., you just don't provide a Jacobian construction routine)? This would help isolate whether the issue is with your CSR Jacobian, or
something else.
On the other hand, I'm perplexed by the error that you get when trying non-preconditioned GMRES. The
KIN_LINSOLV_NO_RECOVERY error should indicate a "recoverable" failure in the linear solver where the residual is
not reduced, and that KINSOL cannot remedy within the nonlinear solve. However, without preconditioning there are very few "recoverable" but non-residual-reduced failure modes from our GMRES solver. If you want to pursue the GMRES option further, then
immediately after it fails can you call the function
KINGetLastLinFlag, and share the last value returned by the linear solver?