I'm trying to solve a non linear ODE numerically with ParametricNDSolve
, but as far as I got is shown below. My problem is to set the find root correctly.
What I know is this: x'[0] == 0, x[R] == 0, x'[R] == 0
.
Any help?
Here is my code:
c = -0.7177;
r1 = 0.8;
r2 = 125;
R = 1.39;
f[r_] := Piecewise[{{0, 0 <= r <= r1}, {900/(1 - r1^3),
r1 < r <= 1}, {0, 1 < r <= R}}]
ps = ParametricNDSolveValue[{x''[r] + (1/r) x'[r] ==
c n Exp[-x[r]] + f[r], x'[0] == 0, x[0] == x0}, {x, x'}, {r, 0,
R}, {x0,n}, Method -> "StiffnessSwitching"]
ff = FindRoot[{Last[ps[x0,n]][R] == 0, First[ps[x0,n]][R] == 0}, {x0, -2}]