3
$\begingroup$

I have a problem nesting the function ParametricNDSolveValue. The documentation does not help so I hope to find some answers here.

A minimalistic example for my problem is:

PF1 = ParametricNDSolveValue[{u/uT == f'[u], f[0] == 0}, f, {u, 0, 10}, {uT}]

PF2 = ParametricNDSolveValue[{PF1[uT][u] == f'[u], f[0] == 0}, 
  f, {u, 0, 10}, {uT}]

which yields the error

ParametricNDSolveValue::dsfun: ParametricFunction[1,Internal`Bag[<1>],<<2>>,{{uT$44821},<<26>>[<2>],{},<<1>>,{1},{Automatic,0,0}},{NDSolve`base$44828,NDSolve`NDSolveParametricFunction[0,{ParametricNDSolveValue,Internal`Bag[<2>],None,ParametricNDSolveValue},<<6>>,{},All]}]<<1>><<2>>] cannot be used as a function. >>

How can I make this work?

Note:

  • I'm aware that one can do this calculation in a much easier way, I am however concerned with a calculation where I have to nest the command ParametricNDSolveValue in the above way.
  • I am using Mathematica 10.4.
$\endgroup$
  • 1
    $\begingroup$ Actually, your code works fine as written, at least for version 11.3. Try running it in a fresh notebook. $\endgroup$ – bbgodfrey Sep 12 '18 at 4:11
2
$\begingroup$

Why not include both ODEs into a single ParametricNDSolveValue? For instance:

pf = ParametricNDSolveValue[
    {
    u/uT==f'[u],f[0]==0,
    f[u]==g'[u],g[0]==0
    },
    {f, g},
    {u,0,10},
    uT
];

Visualization:

Plot3D[Through[pf[uT][u]], {u, 0, 10}, {uT,0,10}]

enter image description here

$\endgroup$
2
$\begingroup$

Don't know why your approach doesn't work, but here is a workaround

PF1 = ParametricNDSolveValue[{u/uT == f'[u], f[0] == 0},f, {u, 0, 10}, {uT}]
sol2[uT_] :=NDSolveValue[{PF1[uT][u] == f'[u], f[0] == 0} , f, {u, 0, 10} ]
Plot[{PF1[1][u], sol2[1][u]} // Evaluate, {u, 0, 10}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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