# Looping with NDSolve?

I have a series of PDE equations that are solved with NDSolve for certain variables $a$ and $b$ - Now, I want to see the output at a time $t$ as $a$ and $b$ change; so I was thinking of a loop formulation, where both variables increment , the PDEs are solved and the output for time $t$ saved.

I am not sure how to implement this in mathematica, or whether it's even the best way to do it - I will eventually want to use the outputs for curve fitting to some data.

Any suggestions would be appreciated!

-
?Manipulate and setup a slider for a and b, and click the play arrow. –  Nasser Jan 29 at 15:29
It might good to run Table[] in the initialization of Manipulate, save the output to a variable, and have it show the results from that ... depending on how intensive the calcs are. I really don't like putting too much into manipulate. –  MRN16 Jan 29 at 15:35
ParametricNDSolve might be the answer to the problem. –  Oliver Jennrich Jan 29 at 15:48
Thanks folks; I'll experiment with all these approaches! –  DRG Jan 30 at 1:26
Any of the optimizations in this Q&A may apply depending on what your PDEs are: link –  Pickett Feb 2 at 13:49

I had to to do the same thing recently:

Let's suppose we want to solve y1'[x] = b^2/a y1 + y2^2, y2'[x]= a y2^2 - b y1^2. Start by defining the module to solve the equation:

solution[a_,b_,t_]:= Module[{xend =t},
sol = NDSolve [{y1'[x] == b^2/a y1[x] + y2[x]^2,  y2'[x]== a y2[x]^2 - b y1[x]^2, y1[x1]== Yin, y2[x1]==Yin},{y1, y2}, {x, x1, xend}];
Evaluate[y2[xend] /. sol]]


Then you run Table as has been suggested:

t = 20;
mylist = Table [
solution[a, b, t]
,{a,amin, amax, step}, {b, bmin,bmax, bstep}]


You can use an interpolation function to navigate different values of a and b.

Hope it helps, L.

-