Error in boundary condition corrected
To solve this ODE system, begin by determining its behavior near r == 0
.
In other words, g[r]
vanishes to all orders at the origin for most values of n
. However, if n == 1
is a positive integer, the same set of commands leaves g'[0]Derivative[n][g][0]
undetermined. So, ng[eps]
must be equalis approximately proportional to unityeps^n
. Next, solve the equations numerically by shooting, using the method previously employed here and elsewhere on this site. (As noted in my comment above, DSolve
returns unevaluated when applied to these equations.) A typical calculation for n == 5
is given by
eps = 10^-5; end = 20;
sp = ParametricNDSolveValue[{g'[r] == a[r] g[r]/r, a'[r]/r == g[r]^2 - 1,
a[eps] == 1n0, g[eps] == epseps^n0 gp,
WhenEvent[g[r] > 101/100, {bool = 1, "StopIntegration"}],
WhenEvent[a[r] < 0, {bool = 0, "StopIntegration"}]},
{a[r], g[r]}, {r, eps, end + 5}, {gp, wp0, n0},
WorkingPrecision -> wp0, Method -> "StiffnessSwitching"];
bl = 1/2;0; bu = 2; imax = 100; wp = 75; n = 5;
Do[bool = -1; bmiddle = (bl + bu)/2; st = sp[bmiddle, wp];wp, n];
rm = (First[st] /. r -> "Domain")[[1, 2]];
If[bool == 0, bl = bmiddle, bu = bmiddle]; ip = i;
If[bool == -1, Return[]], {i, imax}];
s[n] = st;
For larger values of n
, wp
must be increased. For instance, with n = 10
, wp = 90
is required. Results for n = {1, 2, 5, 10}
are plotted below.
Plot[{sts[1], s[2], s[5], s[10]}, {r, eps, Min[rm, end]10}, PlotRange -> All, AxesLabel -> {r, "a, g"},
ImageSize -> Large, LabelStyle -> {Black, Bold, Medium}]
The solutions takes only a fewno more than several seconds each.