1
$\begingroup$

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!

$\endgroup$
5
  • $\begingroup$ ?Manipulate and setup a slider for a and b, and click the play arrow. $\endgroup$
    – Nasser
    Commented Jan 29, 2014 at 15:29
  • 2
    $\begingroup$ 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. $\endgroup$
    – MRN16
    Commented Jan 29, 2014 at 15:35
  • $\begingroup$ ParametricNDSolve might be the answer to the problem. $\endgroup$ Commented Jan 29, 2014 at 15:48
  • $\begingroup$ Thanks folks; I'll experiment with all these approaches! $\endgroup$
    – DRG
    Commented Jan 30, 2014 at 1:26
  • $\begingroup$ Any of the optimizations in this Q&A may apply depending on what your PDEs are: link $\endgroup$
    – C. E.
    Commented Feb 2, 2014 at 13:49

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.