4
$\begingroup$

I am trying to solve the following ODE using Mathematica:

0=-f''[r]-(3/r)f'[r]+f[r]-3/2 f[r]^2 + a/2 f[r]^3

with the boundary conditions f'[0]=0 and f[r->infty]=0. a is just a number between 0 and 1.

I am quite new to Mathematica so am not sure of the technical details but I am currently using NDSolve. According to a paper that I have lifted the equation from, this is solved using the shooting method and 4th order Runge-Kutta; however, I thought NDSolve would do this for me. My Mathematica code is

f[r] /. NDSolve[{-f''[r] - 3/r f'[r] + f[r] - 3/2 f[r]^2 + a/2 f[r]^3 == 0, f'[0.1] == 0, f[120] == 0}, f[r], {r, 0.1, 120}][[1]]

which outputs an Interpolating Function which is just a horizontal line at the x-axis, which is clearly wrong. Can anyone help please?

$\endgroup$
8
  • 1
    $\begingroup$ Parameter a isn't defined, that's why NDSolve doesn't evaluate! $\endgroup$ Commented Jul 19, 2019 at 13:48
  • $\begingroup$ Why do you think the solution is wrong? You are saying the solution is zero at $\infty$ and slope is zero at the other end. So zero solution does satisfy the ODE. (replace $f(r)$ by zero) you get $0=0$. Doe the paper shows other solutions? $\endgroup$
    – Nasser
    Commented Jul 19, 2019 at 13:49
  • $\begingroup$ @Nasser At r=0, I just require the first derivative df/dr=0. I understand that f(r)=0 is a solution, but it's trivial. I think I phrased wrong to say that it's the "wrong" solution; more, it's not a very interesting solution and I know there exist other solutions $\endgroup$ Commented Jul 19, 2019 at 13:56
  • $\begingroup$ Your boundary conditions correspond to the trivial solution. Naturally, it is this solution that will be returned. Did this equation come from phase transition theory? $\endgroup$ Commented Jul 19, 2019 at 14:00
  • $\begingroup$ @AlexeiBoulbitch it is, in vacuum decay in field theory. The aim is to solve this to calculate f(r) which is the solution to the classical equations of motion. There is then the trivial solution, which it is outputting. The paper I am reading says the method is forward/backward shooting with 4th order R-K in order to match the boundary conditions. I assumed that this is how NDSolve worked; is there a way I can explicitly say for it not to consider the trivial solution? $\endgroup$ Commented Jul 19, 2019 at 14:05

1 Answer 1

3
$\begingroup$

Here is an idea for how set up to a different initial seeding that then gives a non-zero solution.

res = NDSolveValue[{-f''[r] - 3/r f'[r] + f[r] - 3/2 f[r]^2 + 
      1/2 f[r]^3 == 0, f[120] == 0}, f, {r, 0, 120}, 
   Method -> {"FiniteElement", 
     "MeshOptions" -> "MaxCellMeasure" -> 1}, 
   InitialSeeding -> {f[r] == 0.25}];
Plot[res[r], {r, 0, 120}, PlotRange -> All]

enter image description here

For more ideas see also this answer. But in general changing the initial seeding to find solutions can be very challenging.

$\endgroup$
4
  • $\begingroup$ Ok thanks. So then the boundary conditions are correct and I have a non-trivial solution. How then, using this method, does one find the 'correct' solution. The one I have in the paper is more like a step function such that the values of f[r] are always positive. I don't really understand how, if I didn't have the solution beforehand, how I would be able to tell which solution to use $\endgroup$ Commented Jul 19, 2019 at 14:47
  • $\begingroup$ @ArchieCable, I would not conclude that just because the BCs work with an InitialSeed that they are the correct BCs for the problem your are trying to solve. And yes, nonlinear DEs can be tricky. $\endgroup$
    – user21
    Commented Jul 19, 2019 at 14:58
  • $\begingroup$ So how would one go about finding the correct solution via this method? $\endgroup$ Commented Jul 19, 2019 at 15:03
  • $\begingroup$ @ArchieCable As I have done in the answer I linked to: try a less nonlinear problem and use that as a starting value. Better understand the physics of the DE you want to solve. Make sure the DE and BCs are correct. $\endgroup$
    – user21
    Commented Jul 19, 2019 at 15:06

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.