NDSolve::icfail for a VERY LARGE system of ODEs

I have a very large system of ODEs (up to several thousands ODEs and up to several hundreds of thousands of various coefficients, which power these ODEs). The ODEs and coefficients are generated based on some model parameters and statistical distributions of coefficients. As the number of ODEs and coefficients increase, the probability that Mathematica will fail with "NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions." substantially increases. Several consecutive runs with the same model parameters, which result in the same number of equations but different values of coefficients may work or may fail. I wonder if anyone has any ideas what to do with that.

Here is and example of a failing ODE system: https://drive.google.com/file/d/0B92m3iuLY2XPZ1ZCUVBsUllSWkE/view?usp=sharing . It is too big to post here. The example fails in 11.2 but works in 10.0!!! However, 10.0 still fails for larger systems.

Thanks a lot.

UPDATE

Ok. I looked at what was going on under the hood and the issue seems to be with Method -> {"EquationSimplification" -> "Residual"} . Once this is removed, then everything works as a clock. The problem is that I personally set this method a while ago because for some values of parameters the resulting system is DAEs rather than pure ODEs and that method was the only, which worked...

• If you don't have good starting values for your parameters/coefficients to begin with, then you're pretty much doomed, no? Commented Oct 15, 2017 at 3:00
• It is a first order ODE system with just initial values and no constraints. Give it anything as an input and it must solve it. But it does not! Commented Oct 15, 2017 at 3:05
• Haven't looked, but if the system is linear and first-order, you should be able to use MatrixExp[]. If it's nonlinear... good luck, dude. Commented Oct 15, 2017 at 3:07
• Of course, it is non linear and even if it were linear MatrixExp is doomed for very large matrices. The question is how to tweak various parameters spread out inside 300+ pages of documentation for NDSolve, so that to coerce it to work. Commented Oct 15, 2017 at 3:10
• My point was that for nonlinear equations, you really don't have a guarantee of "niceness", in that if it works, consider yourself lucky (cf. the Lorenz equations). Commented Oct 15, 2017 at 4:37

There exist a number of posts related to this issue in this site, for example:

What's behind Method -> {"EquationSimplification" -> "Residual"}

Why does NDSolve need to solve for the derivatives if the equations are already explicitly solved?

Introduction to Vectors and NDSolve with System of Equations

Plot with different colors the results of an NDSolve with vector solution

Numerically solve large ODE system

System of ODEs specified by large coefficient matrices

There should be more. In short, large symbolic ODE system is burdensome, it's better to vectorize the system or make small black-box function if possible. In your case, the system can be transformed to the following form:

$$U'(t)=m_0+m_1.U(t)+m_2.U(t).U(t)$$

According to your statement here, I guess you already have $$m_0$$ etc. at hand, so it should be easy for you to build such a equation, but here I'll rebuild this equation from the code given by you with the help of powerful CoefficientArrays:

{ode, ic} =   Uncompress@"1:eJy9nXdgFdW2xpNQpEkISFWKSFBAkRhCUUxO6CEkAYL0GkhCIJQUEFApGkpURKTKNaBE6U0UQcSEoIBIFQiEegEBBURB6hWEp55598zMW+s7a/aZ8+4fXJU9vzOz91prt7W//Xjc8E4Jfj4+PmmF//qjfVJaekJdw7/983dF/vqjVcrI/skJvn/9k+uPtBJ//dEyPjVpVP/0pFHxSf/8t7+fSO2RVuyv/0uvFRQU1LRpcKqP9j9VXHcDLqGBr/aKHZJHprmYnZOGxqelli/6waoDp0PCElyP9zc+bnpg65HjyVc21Qpz/fcOw1+OT2WfT/IzfAn7q+HGXy1kfKD5kWEBs0Jag9dkSZbfP9z9+/v5PujQsf9L+teJg79KPNAcPhCbtbZ8bP9h+gcGWH2gBXxg0derVgaOCdQ/MBC2wcBKF0ftm1MGvJKU1OfV2h9lXy4D3pUluf+IllZ/mv0ITCKqg/2IlvAjCkXu/3Ti9MF6UrzVB1rBB/pUXu2IfyNe/0AC/Lj+rX+Z8HVKgEPib5j0Ysb0n8qcnQxcXUq6UzWoYutLZ4DTSUkrouu/3i490CExAkz6cn9uwLaKD4ATSUl7boXXaHf3OQdvBFLSJkeXiBMbGwLrYEkms7k4ZlvDCzvLOvhYmeA+VhK219qqxbC2h0mEFbO2h0mE7TVXIxG2x4YNTCJsr6UaibAY1vYwibBi1vZae2h7rd3b3vLRVT//tUQn/YclwveflZPjt7PVJpHtYdLdXZVjNp7cKYp7mHT6t4CP5ywOdvBuy5JM1fHL7KeTShy8BsY+iUp12sZqTbB1iklE67B1iklEnbZWI+VEXX193yu+Dr4RWJLl1mnjvnVGr7rTLCA6Vl9Fg+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o+IPDhy5n7fX3pFpYlECEyyex2YRIhesvI5mEQITLJrs5hEiF6ym6r4kJ9lqUpCYFJRl4gQvVSUqiQEJhV3qwnRS+ludd3/9an2SWnplJ86n+qR6qP977//wBfubqVwuKvwmWHPrUvLHuHgCzd3FQ6Y5Oga80gvULiFq/CLK0Nvz2uSBgq3dBXeX6ps5KUlo0HhVq7ClZ/e3qjH4+mgcGtX4at+gys8vSkVFG7jKvxhtTt1Lm/oDgq3dRV+v/DW2ilvoHeOcBW+1fbs7FGjkkHhdq7Cg0/+MqTo4fwwvnCkq/C19V8UhJVuBsjtXYVvjx+ePfzhIaBwlKvwyrMJn7YvPBAUjnYVjj2QEjvnShIoHOMqnDUhNPxS1ZdB4Q6uwmk+fhUvR40ChTu6Ck+ufzfiYI/hoHAnV+EijWZ9kRM8EhSOdRXOnX4983z/FFC4s6vw1N6/7WhdD9lGf1fh5LgeUS2ikQ/GuQoX5C4PeiujJyg8wFV4zNWlE589jIx/oKtw/NoZEavqoHeOdxUufGdDqYhNyLsTXIW3vuZ7JaIHeo1EV+Gnx9ab8GJD5IODXIXXN07+8dci6J2TXIWbJuw999U5ZPyDXYV/rhs2rmkC8sEhrsLdMndsmj/uBUBOdhVu+H1B4pXXB4PCQ12F/Rukt9mfNQAUHqar55yaZ/IHIR8c7ircduqCKe8sQW41wlW4TvVT0RuPI09J0VndU6OuRWwaBgqnugpPuL1maYMdKJinuQp/sXZYwIViyAfTXYVbjDz/y5Q1Lzv+B81nuaA=";

{m0, m1, m2} =
CoefficientArrays[Last /@ ode,
Through[{rZ, rY, rA, rB, rC, rD, rE, rF, rG, rH, rI, rJ, rK, rL, rM, rN, rO, rP, rQ,
rR, rS, rT, ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro, rp, rq,
rr, rs, rt}[t\$111993]]];
icvalue = Last /@ ic;

Clear@rhs; rhs[var_?VectorQ] := m0 + m1.var + m2.var.var

sol = NDSolveValue[{var'[t] == rhs@var[t], var[0] == icvalue},
var, {t, 0, 10^4}]; // AbsoluteTiming
(* {0.917296, Null} *)
sol // ListLinePlot


• Thanks. Almost any approach works when the number of parameters is small. It is the things like that: github.com/kkkmail/ClmFSharp/blob/master/Clm/Model/Models/… that I am after. And before it can be run, it must be generated. Current F# algorithm (please, see below) needs about 7-9 GB of ram and about 3-5 minutes to generate the file like that, though it can be improved to take much less memory and time. Commented Dec 29, 2018 at 0:11
• @KonstantinKonstantinov Well, I know nothing about F#, but since SparseArray is a built-in function, I believe similar performance can be achieved with Mathematica. If you can show us the model with Mathematica code or traditional math notation, I can have a try. Commented Dec 29, 2018 at 3:24

I have not been able to determine why it does not work, But there are other methods that return results. One of them is Method -> {"DAEInitialization" -> {"Collocation", "CollocationDirection" -> "Forward"}}

Technically, this is not an answer, but it works. I moved these models to F# sparse matrices based generator / engine along with a very thin wrapper around ALGLIB (http://www.alglib.net/) vector ODE solver and it just works.

F# takes care of simple, structured, and controlled code generation and ALGLIB is robust enough to handle at least up to 1M variables (yes I tested that and it survived).

• If you plug-in the initial conditions found/used with this approach do you get better results with Mathematica? Commented Dec 28, 2018 at 15:13
• The results are comparable when both work. However, F# / Alglib works for large models where Mathematica fails. My guess is that the main reason is that generation stage gets very demanding even in F# - it could consume 50-60 GB of ram and may run for over an hour. This is due to very large sparse matrices which have only 0.01 to 0.1% of non-zero elements. The resulting F# code file is only about 2 to 10 MB in size and it needs about 100-300 MB to run. Commented Dec 28, 2018 at 17:50