0
$\begingroup$

I am solving a set of 4 different ODEs with ParametricNDSolve. When I specify the a value for the parameter instead of getting out an interpolating function, I keep getting back a parameter function. Any helps?

Mukh1 = 0 == u''[x] + (h'[x]/h[x] + 1)*u'[x] + k^2/(ainit^2*Exp[2*x]*h[x]^2) - 
2 + 4 h'[x]*\[Psi]''[x]/(h[x]*\[Psi]'[x]) + 2 (h'[x]/h[x])^2 + 
5*h'[x]/h[x] + 
1/h[x]^2* D[D[V[\[Psi][x]], \[Psi][x]], \[Psi][x]];

Mukh2 = 0 == v''[x] + (h'[x]/h[x] + 1)*v'[x] + k^2/(ainit^2*Exp[2*x]*h[x]^2) - 
2 + 4 h'[x]*\[Psi]''[x]/(h[x]*\[Psi]'[x]) + 2 (h'[x]/h[x])^2 + 
5*h'[x]/h[x] + 
1/h[x]^2* D[D[V[\[Psi][x]], \[Psi][x]], \[Psi][x]];

Eq3 = h'[x] == -1/2*h[x]*\[Psi]'[x]^2;

Eq4 = 0 == \[Psi]''[x] + (h'[x]/h[x] + 3) \[Psi]'[x] + 
1/h[x]^2*D[V[\[Psi][x]], \[Psi][x]];

m = ParametricNDSolve[{Mukh1, Mukh2, Eq3,Eq4, \[Psi][\[Alpha]0] == P0, h[\[Alpha]0] == H0, \[Psi]'[\[Alpha]0] == DP0, u[0] == 1,u'[0] == 0, v[0] == 0, v'[0] == 1}, {u, v, \[Psi]}, {x, -150, 160}, k]

When I run sol= m[0.3] I get:

enter image description here

The final goal is to plot asymptotic values of u and v as a function of k. Any ideas on how I can get it to work? Also, the initial conditions are defined earlier in my code, so don't worry about that.

$\endgroup$
2
  • $\begingroup$ What is V? In you code, there are v and V, but V doesn't in the variables. What is ainit,What is P0,What is H0? $\endgroup$
    – cvgmt
    Nov 25, 2020 at 7:48
  • $\begingroup$ as I said, these are defined earlier in my code. The entire code is quite long, so I didn't post all of it. $\endgroup$ Nov 25, 2020 at 8:13

1 Answer 1

1
$\begingroup$

Try ParametricNDSolveValue. Because you couldn't provide code here my example

sol = ParametricNDSolveValue[{x'[t] == Cos[om t], y'[t] == Sin[om t], x[0] == 0, y[0] == 0}, {x, y}, {t, 0, 10}, om]

Access of solution

Plot[Through[sol[1][t]], {t, 0, 10}]

enter image description here

$\endgroup$
1
  • $\begingroup$ OMG! thank you so much! I can't believe I was missing that. $\endgroup$ Nov 25, 2020 at 20:49

Your Answer

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

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