My problem is quite simple: I run a NDSolve
with a system of many ODEs, a calculation that will run for many hours, and I would like to know the progress of the calculation while it goes on.
More precisely, calling f[n][t]
the functions to be solved in the interval {tin,tfin}
, It will be sufficient to print at regular intervals t
the value of Sum[f[n][t]]
for example, and possibly to save them as well. As a side effect, this will also give me an idea of when the calculation is going to end.
However I don't want to sacrifice a significant amount of runtime for this monitoring. One option could be really to split the calculation in intervals (a table of NDSolve
) and print the intermediate results at each point. But I am afraid to have a significant overhead due to the reconstruction of the system of equations every time (I also use the method "EquationSimplification"->"Solve"
which I believe transforms symbolically the system before integrating it) so I hope that some wizards among you could help me out providing an efficient solution to this problem using perhaps EvaluationMonitor
or EventLocator
or StateData
?
Any example will be appreciated.
EDIT: here is an example I just invented (the real example is more complicated).
M = 100;
Clear[P];
eqns := Table[
P[k]'[t] == -(1/k) P[k][t] -
P[k][t]^2 Sum[Exp[-(k - q)^2/M] P[q][t], {q, 1, M}]
, {k, 1, M}];
initial = Table[P[k][0] == 0.2, {k, 1, M}];
spos = NDSolve[Join[{eqns, initial}],
Table[P[k], {k, 1, M}], {t, 0, 100},
Method -> {"EquationSimplification" -> "Solve"},
PrecisionGoal -> 3, AccuracyGoal -> 3];
Comments
Post a Comment