I have a question please. I have an issue with my code while trying to solve an equation. Here it is :

sol = Block[{\[Epsilon] = $MachineEpsilon}, NDSolve[{Div[(f[x])*(1 - f[x])*Grad[(-2 f[x] + 4*f[x]^2) - Laplacian[f[x], {x, y, z}, "Spherical"], {x, y, z}, "Spherical"], {x, y, z}, "Spherical"] == \[Epsilon], f[1] == 0.6, f'[5] == \[Epsilon], f[5] == \[Epsilon],f'[\[Epsilon]]==\[Epsilon]}, f, {x, \[Epsilon], 5}]]

I get the following messages :

Power::infy: Infinite expression 1/0. encountered. >>

And others of the same type. The last one is

NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 1.`. >>

I don't get why since I suppressed all the zeros from my boundaries and values.

I then tried, following (105714) :

xmax = 5
e = $MachineEpsilon

sol = ParametricNDSolve[{Div[(f[x])*(1 - f[x])*Grad[(-2 f[x] + 4*f[x]^3) - Laplacian[f[x], {x, y, z}, "Spherical"], {x, y, z}, "Spherical"], {x, y, z}, "Spherical"] == 0, f[1] == 0.6, f[xmax] == bc1, f'[e] == bc2, f'[xmax] == bc3}, f, {x, e, xmax}, {bc1, bc2, bc3}]

obj[bc1_?NumericQ, bc2_?NumericQ, bc3_?NumericQ] := sol[bc1, bc2, bc3][xmax]

solpc = FindRoot[obj[bc1, bc2, bc3] == 0, {{bc1, 0.1}, {bc2, 0.1}, {bc3, 0.1}}]

sols = f -> sol[bc1, bc2, bc3] /. solpc

Plot[Evaluate[f /. sols], {x, 0, 10}] 

But I assume I made mistakes, since I get error messages from the line with solpc :

The function value...s not a list of numbers with dimensions {1} at {bc1,bc2,bc3} = \ {0.1,0.1,0.1}

Thx in advance !

  • $\begingroup$ From the posted code, I get the error, "NDSolve::ndnco: The number of constraints (3) (initial conditions) is not equal to the total differential order of the system plus the number of discrete variables (4)." $\endgroup$ – Michael E2 May 14 '18 at 11:02
  • $\begingroup$ thx but I don't get that error in the messages ! And even when I add the constraint f'[[Epsilon]] == [Epsilon] they still say me NDSolve::ndnum: Encountered non-numerical value for a derivative at x == 2.220446049250313`*^-16. >> $\endgroup$ – J.A May 14 '18 at 11:12
  • $\begingroup$ The code you posted has only three boundary conditions but the DE is 4th order. You need 4 BCs. If you're not getting that error, I think you're not using the posted code. $\endgroup$ – Michael E2 May 14 '18 at 11:25
  • $\begingroup$ In any case, I think the problem is likely to be with "StartingInitialConditions". There are several problems similar to this one on the site, which you can find if you search for "StartingInitialConditions". $\endgroup$ – Michael E2 May 14 '18 at 11:45
  • $\begingroup$ Ah, in V10.4.3, I don't get the error message, but in V11.2, I do. So the version seems important. Which version are you using? $\endgroup$ – Michael E2 May 14 '18 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.