Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.6K Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

A problem with using NDsolve, please help.

Posted 10 years ago
POSTED BY: Gil Bor
7 Replies
Posted 10 years ago

That's the whole issue, that NDSolve, just like you, wants to see an explicit form of the RHS of the DE p'[t]==pflow[p], but I dont have one, since the function pflow[p] is given by some complicated program, which cannot be summarized by a "formula" (probably it can, in my case, with some effort, but it's very unnatural, and one should not be obliged to do it, the program should serve me, not the other way around). In particular, pflow can only accept as input vectors p with numerical entries, not abstract symbols.

OK, so I can tell you that after searching around and asking some experts, I learnt that there is a very simple solution to this problem in Mathematica, but which is not obvious at all and is not mentioned in the documentation (at least I couldnt find it). You just add the single word "List" after the argument in the definition of pflow (the RHS of the DE)

pflow[p_List] := Module[{...}, etc

That's all. After this you can write

psol = NDSolveValue[{p'[t] == pflow[p[t]], p[0] == p0}, p, {t, 0, T}];

and all goes well. Maybe it's in the documentation somewhere, but I didnt find it. It somehow tells NDSolve, when trying to acces pflow before starting the integration process, not to use it prematurely, but wait patiently, start with the available initial conditions which turn p into a List of numbers (without them p is just a symbol without any meaning), which will be then accepted by pflow and produce, using the integrating scheme used by NDSolve, the next value of p, etc.

Thanks again for trying to help.

POSTED BY: Gil Bor
Posted 10 years ago

Would it be possible, perhaps just to make your problem simple enough for me to understand, for you to expand your y'[t]=pflow[y[t]] into a list of explicit differential equations in terms of your y1[t], y2[t],...y6[t] and the derivatives of those and the coefficient variables that you have constructed? If that could be done then it might be possible for someone to see how to then translate that into a notation that NDSolve would correctly accept.

POSTED BY: Bill Simpson
Posted 10 years ago
POSTED BY: Gil Bor
Posted 10 years ago
POSTED BY: Gil Bor
Posted 10 years ago
POSTED BY: Bill Simpson
Posted 10 years ago

Thank you very much Bill for trying to help.

The data structure that the function pflow uses, both for input and output, is a nested list of n pairs of real numbers (a vector of n points in R^2). For example, for n=3, something like {{1,2}, {3,4}, {5,6}}. I tested it by inserting the command pflow[p0] before the NDsolve command, and it seems to do its job properly. But somehow, when NDsolve calls pflow, something goes wrong.

Thanks again for yr effort, I really appreciate it.

POSTED BY: Gil Bor
Posted 10 years ago
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard