Skip to main content
added 1723 characters in body
Source Link
user21
  • 40.7k
  • 8
  • 114
  • 170

Update:

Alex noted a typo in my answer. Sorry about this. You can still solve this equation with the nonlinear FEM solver, thought it's not a as straight forward as for the miss typed equation.

Using

NDSolveValue[{D[\[Chi][x], {x, 2}] == \[Chi][x]^(3/2)/Sqrt[x], \[Chi][
    rin] == 1, \[Chi][10] == 0}, \[Chi], {x, 0, 10}, 
 Method -> "FiniteElement"]

gives an error message:

enter image description here

This is a fairly general failure message. The reason it is so general is that for the code it's impossible to say why it failed. One cause can the that there is a transition from the real to the complex plain. An easy way to try this is to either give an complex valued initial seed or, alternatively, to add a 0. I complex component to the equation:

sol = NDSolveValue[{D[\[Chi][x], {x, 2}] == \[Chi][x]^(3/2)/
      Sqrt[x], \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, 0, 10},
    Method -> "FiniteElement", InitialSeeding -> \[Chi][x] == 0. I];
Plot[Re[sol[x]], {x, 0, 10}, PlotRange -> All]

enter image description here

Note the Re in the plot. Now, there is also a small complex component in the solution:

Plot[Im[sol[x]], {x, 0, 10}, PlotRange -> All]

enter image description here

But the solution compares favorably to other solutions presented here:

Plot[Evaluate[psol[d /. drule][r] - Re[sol[r]]], {r, rin, 10}, 
 PlotRange -> All]

enter image description here

Old answer:

How about:

rin = 0;
sol = NDSolve[{D[\[Chi][x], {x, 2}] == (\[Chi][x]^3/2)/
      Sqrt[x] , \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, rin, 
    10}, Method -> "FiniteElement"];
Chi[x_] := Evaluate[\[Chi][x] /. sol[[1]]];
Plot[Chi[x], {x, 0, 10}]

enter image description here

If you are interested in why I reformulated the equations then this section from the documentation is a good starting point.

How about:

rin = 0;
sol = NDSolve[{D[\[Chi][x], {x, 2}] == (\[Chi][x]^3/2)/
      Sqrt[x] , \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, rin, 
    10}, Method -> "FiniteElement"];
Chi[x_] := Evaluate[\[Chi][x] /. sol[[1]]];
Plot[Chi[x], {x, 0, 10}]

enter image description here

If you are interested in why I reformulated the equations then this section from the documentation is a good starting point.

Update:

Alex noted a typo in my answer. Sorry about this. You can still solve this equation with the nonlinear FEM solver, thought it's not a as straight forward as for the miss typed equation.

Using

NDSolveValue[{D[\[Chi][x], {x, 2}] == \[Chi][x]^(3/2)/Sqrt[x], \[Chi][
    rin] == 1, \[Chi][10] == 0}, \[Chi], {x, 0, 10}, 
 Method -> "FiniteElement"]

gives an error message:

enter image description here

This is a fairly general failure message. The reason it is so general is that for the code it's impossible to say why it failed. One cause can the that there is a transition from the real to the complex plain. An easy way to try this is to either give an complex valued initial seed or, alternatively, to add a 0. I complex component to the equation:

sol = NDSolveValue[{D[\[Chi][x], {x, 2}] == \[Chi][x]^(3/2)/
      Sqrt[x], \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, 0, 10},
    Method -> "FiniteElement", InitialSeeding -> \[Chi][x] == 0. I];
Plot[Re[sol[x]], {x, 0, 10}, PlotRange -> All]

enter image description here

Note the Re in the plot. Now, there is also a small complex component in the solution:

Plot[Im[sol[x]], {x, 0, 10}, PlotRange -> All]

enter image description here

But the solution compares favorably to other solutions presented here:

Plot[Evaluate[psol[d /. drule][r] - Re[sol[r]]], {r, rin, 10}, 
 PlotRange -> All]

enter image description here

Old answer:

How about:

rin = 0;
sol = NDSolve[{D[\[Chi][x], {x, 2}] == (\[Chi][x]^3/2)/
      Sqrt[x] , \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, rin, 
    10}, Method -> "FiniteElement"];
Chi[x_] := Evaluate[\[Chi][x] /. sol[[1]]];
Plot[Chi[x], {x, 0, 10}]

enter image description here

If you are interested in why I reformulated the equations then this section from the documentation is a good starting point.

Source Link
user21
  • 40.7k
  • 8
  • 114
  • 170

How about:

rin = 0;
sol = NDSolve[{D[\[Chi][x], {x, 2}] == (\[Chi][x]^3/2)/
      Sqrt[x] , \[Chi][rin] == 1, \[Chi][10] == 0}, \[Chi], {x, rin, 
    10}, Method -> "FiniteElement"];
Chi[x_] := Evaluate[\[Chi][x] /. sol[[1]]];
Plot[Chi[x], {x, 0, 10}]

enter image description here

If you are interested in why I reformulated the equations then this section from the documentation is a good starting point.