0
$\begingroup$
s = 
  NDSolve[
    {m'[r] == α*r^2 ϵ[r], 
     p'[r] == -(r0/r)*((p[r] + ϵ[r]) (m[r] + α r^3* p[r]))/(r - 2 r0*m[r]), 
     m[10] == 1, p[10.] == 1}, 
    {m, p}, 
    {r, 10, 100}]

I have given all the values of the parameters. Need solution for p[r], m[r]. But it is showing :

NDSolve:: ndnum, r, 10.] NDSolve:Encountered non-numerical value for a derivative at r == 10.

Can any one solve the problem?

$\endgroup$

closed as off-topic by Michael E2, m_goldberg, MarcoB, Henrik Schumacher, user21 Jun 12 at 7:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Michael E2, m_goldberg, MarcoB, Henrik Schumacher, user21
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ If my answer works for you, please consider upvoting and accepting it! $\endgroup$ – Rebel-Scum Jun 1 at 19:21
  • $\begingroup$ What happens when you plug in r = 10 and the initial condition into the DE and solve for r’? Do you get a numeric value? Or are there undefined symbols? $\endgroup$ – Michael E2 Jun 1 at 20:37
  • $\begingroup$ It is writing the same equation replacing every parameter with there values except p[r], m[r] and r. $\endgroup$ – Sovan Jun 2 at 20:47
  • $\begingroup$ You should post complete code that will reproduce the problem. $\endgroup$ – Michael E2 Jun 5 at 21:17
2
$\begingroup$

You need to give values to both of the parameters and define $\epsilon[r]$. Doing so, works nicely:

a=1;
r0=1/100;
e[r_]:=1/r
s=NDSolve[{m'[r]==a*r^2 e[r],p'[r]==-(r0/r)*((p[r]+e[r]) 
(m[r]+a r^3*p[r]))/(r-2r0*m[r]),m[10]==1,p[10]==1},{m,p},{r,10,100}][[1]];

LogPlot[{m[r],p[r]}/.s//Evaluate,{r,10,100},Frame->True,PlotLegends->{"m(r)", "p(r)"}]

Feel free to adapt this to your problem.

$\endgroup$
  • 1
    $\begingroup$ Ok. Thanks for your reply. I will do this and let you know tomorrow. $\endgroup$ – Sovan Jun 2 at 20:48
  • $\begingroup$ Actually my e[r_] is a little complicated. e[r_]:=3p[r]+4B-(16/27)*mu*T(mu^2-2 mu*T+T^2). where B :=160 and mu := 10^19 $\endgroup$ – Sovan Jun 5 at 8:25
  • $\begingroup$ I have posted my problem in the answer section of the post. Please check and give me a solution if possible $\endgroup$ – Sovan Jun 5 at 8:27
  • $\begingroup$ Thee problem in this case is that mu (the Planck mass?) is too large and then Mathematica complains about stiffness. Also, you don't give the value of T in your problem. One possible solution would be to redefine all quantities in terms of mu (ie absorb it), so that you don't have huge numbers. $\endgroup$ – Rebel-Scum Jun 5 at 15:35
  • $\begingroup$ Btw, for future reference, please always try to post questions will fully working code (=all definitions and values for all parameters) as otherwise we cannot fix the code. $\endgroup$ – Rebel-Scum Jun 5 at 15:36

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