2
$\begingroup$

This question is related to an earlier question I had asked, regarding coupled first order odes. I'll add the system of odes with their boundary conditions again here. enter image description here.

The comments for the previous post were helpful.

I was wondering if the following could be done. Start with the first two boundary conditions and impose them at $r=0$, namely,$ \phi(0)=0 $and $f(0)=1$. We know how the functions behave close to zero: $\phi(r) = c_1*r+c_2*r^2+... $and $f(r)= 1+f_1 * r+ f_2*r^2+..$. If we perform this Taylor expansion around zero and plug it into the coupled system, we generate a recursion relation between the coefficients $c_n$ and $f_n$. All these coefficients can be expressed as a function of $c_1$. I tried this by hand upto $O(r^5)$. If we consider the value of these Taylor expanded functions at some $r=0.01$ and use that as the initial condition for my system of ODEs, can I try and sweep over the free parameter $c_1$ so as to get the desired behaviour I want.

I'm attaching the desired graphs which satisfy all four conditions enter image description here. I've been trying to do this "sweeping" on Mathematica in the following manner. The $c$ used in the code is the same as the $c_1$ coefficient I'm referring to here in the text :

f[c_, r_] := 1 - (1/2) r^2 + (c^2/4  ) r^4 - (c^2/12) r^6
\[Phi][c_, r_] := c*r - (c/4) r^3 + ((c^3/16) + c/32) r^5
soln = ParametricNDSolve[{f'[r] == 
    r  (\[Phi][r]^2 - 1), \[Phi]'[r] ==  f[r] \[Phi][r]/r, 
   f[0.1] == f[c, 0.1], \[Phi][0.1] == \[Phi][c, 0.1]}, {\[Phi], 
   f}, {r, 0.1, 10}, c]

and

Plot[Evaluate[Table[f[c][r] /. soln, {c, 0.84, 0.85, 0.001}]], {r, 
  0.1, 10}, PlotRange -> {0, 2}]
Plot[Evaluate[
  Table[\[Phi][c][r] /. soln, {c, 0.84, 0.85, 0.001}]], {r, 0.1, 10}, 
 PlotRange -> {0, 2}]

For c lying between 0.84 and 0.85, I get the following graphs: enter image description here

and for c lying between 0.85 and 0.86 I get the following graphs: enter image description here

So I know that c should lie somewhere in this regime but I do not know of a way to isolate the number. Also, from fig.3, we can see that $\phi(r)$ approaches its desired behaviour better than $f(r)$.Unfortunately, I do not know of an efficient way to get my desired graphs by varying c.

$\endgroup$
3
  • $\begingroup$ This seems like an ideal problem to be solved by applying a root-finding algorithm like the bisection method. You’d set the x-coordinate for which you want to find the “root”, that is, where the function should go to zero. Then, choose two points along c that lie on either side of this zero (you already have these!) and use these to begin the finding the root via the bisection method. Such a method can be coded by hand, or likely the built-in root finding functions can be used. $\endgroup$ Commented Feb 13, 2022 at 2:20
  • $\begingroup$ If $\phi\rightarrow0$ as $r\rightarrow0$, I don't see how phi[c_, r_] can have the c/r term. It goes to infinity at $r=0$ unless $c=0$. And $c=0$ would seem to correspond to the solution $f(r)=1=r^2/2,\;\phi(r)=0$. You wrote $c_1*r\dots$ above the code. Is there a mistake? $\endgroup$
    – Michael E2
    Commented Feb 13, 2022 at 4:47
  • $\begingroup$ Thanks for pointing that out @MichaelE2. I have corrected it. I tried running the corrected code and I got better graphs. But unfortunately, as stated in the edit, I'm still finding it a bit challenging to isolate the constant c which will give me the desired graph. $\endgroup$
    – Impala
    Commented Feb 13, 2022 at 6:43

1 Answer 1

3
$\begingroup$

Instead of starting at the singular point, why not start at the other end?

One trick to dealing with a singular point in the formula for a derivative is to use Piecewise to give the numeric value of the derivative at the singular point and use the formula elsewhere. The trouble here is that we don't seem to know the derivative at r == 0, but we could try to solve for it. One nice thing about the ODE system is that it's likely going to force $\phi(r)\rightarrow0$ as $r\rightarrow0$. So what we'll do is make a guess what $\phi'(0)$ will be -- I don't believe it has to be very close, since it will only make a difference in the last integration step -- and then iteratively adjust the initial condition at r == 10 to shoot for the boundary condition at r == 0 and update the derivative value after each step. (We estimate the derivative $\phi'(0)$ by the solution at r == 10^-6 because the derivative at zero is set equal to the current estimate and would never change. This introduces a small error, but singular points are difficult.)

ClearAll[f, ϕ, r, c, ϕp];
sys = {
   f'[r] == r (ϕ[r]^2 - 1),
   ϕ'[r] == Piecewise[{
      {f[r] ϕ[r]/r, r > 0}
      }, ϕp],  (* value at r == 0 *)
   f[10] == f0, ϕ[10] == ϕ0};
ϕp = 1.; (* educated(?) guess; set AFTER sys *)
obj[a0_?NumericQ] := Block[{a = a0, b = 1 - 0 1*^-8},
   soln = 
    ParametricNDSolve[sys, {ϕ, f}, {r, 0, 10}, {f0, ϕ0},
     AccuracyGoal -> 12, (* makes it strive for ϕ[0] == 0 *)
     Method -> {"Extrapolation", Method -> "LinearlyImplicitEuler"},
     InterpolationOrder -> All];
   ϕp = D[ϕ[a, b][r] /. soln, r] /. 
     r -> (ϕ[a, b]["Domain"] /. soln)[[1, 1]] + 1*^-6;
   f[a, b][0] /. soln
   ];
logf0 = a /. FindRoot[obj[Exp@a] == 1, {a, -5, -6}] (* Exp keeps parameter >0 *)

(*  -11.3726  *)

Block[{a = Exp@logf0, b = 1 - 0 1*^-8},
 Plot @@ {{f[a, b][r], ϕ[a, b][r]} /. soln, 
   Flatten@{r, f[a, b]["Domain"] /. soln},
   PlotLabel -> 
    Row[{f[0] == (f[a, b][0] /. soln), 
      ", ", ϕ[0] == (ϕ[a, b][0] /. soln)}]}
 ]
$\endgroup$
1
  • $\begingroup$ Thanks for the answer. It was helpful. I did try and find the value of $c$ by the method I had outlined. But I had to use "Manipulate" to decrease the window of possibilities and I had to go till the twelfth decimal place to make sure that the functions asymptote to their values at infinity. If there's a way to automate this process, it would be very helpful as well. I appreciate the present solution as well. $\endgroup$
    – Impala
    Commented Feb 17, 2022 at 7:36

Your Answer

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

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