I'd like to extend my comments to an answer. First of all, forFor those in v12 or higher, FiniteElement
is the besta possible choice for this problem, as shown in user21's answer. But, if you're in a version lower than v12 but higher than v9, it becomes a littlebit more troublesome, because
nonlinear
FiniteElement
isn't implemented yet.Shooting
method can't handle the problem well, which is an arguable backslide.
As we can see, though ndsz
warning is generated, NDSolve
manages to find the desired result in v9.
OK, so what to do? Well, to be honest I don't know if the following solution will cause other problem in v10.0, because v10.0 is a quite unstable version, but it does work in v9 and v12.1:
rin = 10^-30;
psol = ParametricNDSolveValue[{D[χ[x], {x, 2}] == (χ[x]^(3/2))/Sqrt[x], χ'[
10] == d, χ[10] == 0}, χ, {x, rin, 10}, d]
drule = FindRoot[psol[d][rin] == 1, {d, 0 (* choose -1/10 if in v9 *)}] // Quiet
(* {d -> -0.0116574} *)
Plot[psol[d /. drule][r] // Evaluate, {r, rin, 10}, PlotRange -> All]
Alternatively, we can turn to finite difference method (FDM). I'll use pdetoae
for the generation of finite difference equations:
rin = 0;
eq = D[χ[x], {x, 2}] Sqrt[x] == (χ[x]^(3/2));
bc = {χ[rin] == 1, χ[10] == 0};
points = 25; domain = {rin, 10}; grid = Array[# &, points, domain]; difforder = 2;
del = #[[2 ;; -2]] &;
(* Definition of pdetoae isn't included in this post,
please find it in the link above. *)
ptoafunc = pdetoae[χ[x], grid, difforder];
ae = ptoafunc@eq // del;
initialguess[x_] = 0;
solrule = FindRoot[{ae, bc}, Table[{χ[x], initialguess[x]}, {x, grid}]]
sol = ListInterpolation[solrule[[All, -1]], grid]