This sounds like a fairly trivial question, but I can't think of any way to solve it. I am doing an extensive parameter sampling where a set of ODEs is used together with NDSolve to find values of the dependent variables at certain time points. Yet, I am getting several different errors (e.g. convergence errors) when using certain parameters.
Thus, I would like to ask your help in getting a way to find which parameters yield the errors, not how to fix the errors themselves.
The algorithm uses the system of ODEs (with defined initial conditions) and defines the function to compute the concentrations at various time points. It is then used to do the parameter sampling
SysODEs={X'[t]==ba+k1 A - b1 X[t], Y'[t]==k2 X[t]-v1 Y[t]-k1,etc};
DFunction[{a1_,b1_,v1_,k1_},ba_]:=
Block[{sol1,c1,c2},
sol1=NDSolve[SysODEs/.k2->2,{X,Y},{t,0,300}];
c1=X[100]/.sol1;
c2=Y[300]/.sol1;
{c1,c2}
]
SampleP=Flatten[
Table[{h, j, k, l}, {h, 0, 5, 1}, {j, 0.1, 0.9, 0.1}, {k, 1,10, 1}, {l, 5, 10, 1}],3];
ParallelMap[DFunction[#, 0.1] &, SampleP]
Problem: I want to know which values of SampleP yield errors. Because my original functions SampleP, DFunction etc. are much more complex, I didn't include them in here (SampleP has size ~200 000 in my problem). Is there any way of doing it? I was thinking about some kind of Trace, but this will give me too much unneeded information.
Edit: I was searching and found this link with information about the functions MLCreateMark() and MLSeekMark() that are used in MathLink. Maybe this helps in finding something similar in Mathematica?
ParallelMap[Check[DFunction[#, 0.1],errorWith[#]] &, SampleP]– Sjoerd C. de Vries Jun 12 '13 at 18:27vars = {a1, b1, v1, k1};as anotherBlockvariable and ranMap[DFunction[#, 0.1] &, SampleP] // withTaggedMsg[vars]. At issue,a1, etc., are not the same variable as defined in your equation because function parameters effectively haveModulescope, i.e. they're unique, so they're not replaced. Also,k1is a function in the second equation. – rcollyer Jun 12 '13 at 19:38DFunctiontoDFunction[vars:{_,_,_,_}, b_]:= Block[{a1, b1, v1, k1, ba}, {a1, b1, v1, k1, ba} = vars~Join~{b}; .... Then,a1, etc., are scoped correctly. – rcollyer Jun 12 '13 at 19:51ParallelMap, but that's okay, you can debug usingMap. – rcollyer Jun 13 '13 at 01:15ParallelMapwould bring many advantages. I'm wondering if it doesn't work because by splitting computations among cores,ParallelMapis not sequentially computing thus affecting the way it outputs errors – Sos Jun 13 '13 at 09:53