3

I have NDSolve` StateData from an NDSolve` ProcessEquations evaluation. I can NDSolve` Iterate from t0 to t1, but then my boundary condition (an interpolation function) runs out of data.

This interpolation function gets updated externally. I just want to continue iterating (t1 to t2) with the updated interpolation function. However, calling myStateData@"NumericalFunction" shows that NDSolve holds onto the old interpolation function, even though this function is defined with a delayed set i.e. myInterpFunction[t_]:=something[t]

Is there any way to update the functions inside of the state data?

Here is a simplified version of what I'm doing:

myStateData = NDSolve`ProcessEquations[
    {myPDE[x,t],
    (*boundary conditions*)
    T[xf, t] == myInterpolationFunction[t],
    T[0, t] == 0,
    (*Initial condition*)
    T[x, t0] == initialCondition[x]};
    T, t, {x, 0, xf}]

Then I need to solve so...

NDSolve`Iterate[myStateData,t1]

Then externally I update my boundary condition so that now it goes to t2 but when I evaluate

NDSolve`Iterate[myStateData,t2]

Mathematica returns an error saying that the interpolation function doesn't cover that range (t1 - t2) because it's holding onto the old interpolating function. In other words, looking at

myStateData@"NumericalFunction"

shows myInterpolationFunction has a domain of {t0,t1}

  • Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Apr 12 '15 at 19:42
  • Please include your actual code, or a simplified version of it if practical, so that readers can understand what you are doing. – bbgodfrey Apr 12 '15 at 19:43
  • I've added simplified code. My interpolation function is good from "t0" to "t1", once I update the function to go to "t2" I need NDSolve to continue Iterating/integrating to t2 – Eric William Smith Apr 12 '15 at 19:51
  • Try myInterpolationFunction[t_?NumericQ] := something[t]. See also http://mathematica.stackexchange.com/questions/18393/what-are-the-most-common-pitfalls-awaiting-new-users/26037#26037 – Michael E2 Apr 12 '15 at 21:12
  • Thanks Michael, but that's not the issue. The interpolation function is completely numeric, but NDSolve isn't getting the latest version with the larger domain (t1 - t2). – Eric William Smith Apr 12 '15 at 23:48
  • It works for me, for reasons that have to do with how Mathematica evaluates expressions and has nothing to do with interpolating functions being numeric. Did you try it? I can update the function something[t] to a new interpolating function and the extend the integration by NDSolve, which automatically uses the new interpolating function. I thought that's what you wanted to do? – Michael E2 Apr 13 '15 at 01:57
  • 1
    (If you did try it and it did not work, then I suggest it is because the problem is not sufficiently described in the question. There must be something in the missing details that causes an unanticipated problem.) – Michael E2 Apr 13 '15 at 02:10
  • Michael, I tried it, but the code is more complex than what I showed so I can do some more troubleshooting. Thanks for confirming you understand the problem. Can you also confirm that you're changing the domain of the interpolation function? I can run just fine, but since I'm using a time outside of the (original) interpolation function it says it needs to extrapolate, that's the only indication that it was running with the wrong interpolation function – Eric William Smith Apr 13 '15 at 12:10
  • Michael, I've confirmed you're not smoking crack. I tested on a simpler NDSolve problem and was able to pick up the extended interpolation function. I tested first with t_?NumericQ and haven't tried t_ alone with the simple problem. Now to go fix the original NDSolve. Thanks for the help, how do I promote your comment to an answer? – Eric William Smith Apr 13 '15 at 14:04
  • @EricWilliamSmith You need to put an @ in front of non-author comments as I show here, or the person won't be notified of your response. Authors are automatically notified. I can write my comment up as an answer, but probably tomorrow. It's too late right now. Thanks. – Michael E2 Apr 14 '15 at 03:19

0 Answers0