I am very confused and even restarted Kernel several times (Mathematica 13.1 Windows 10). However, I fail to understand why one evaluation of NDSolve
works while a similar implementation in which I introduce the value of a scalar variable LK
into the equation via function definition does not work.
This works
dP = 17.48;
c0 = -4.0;
LK = -39.9968;
First@NDSolve[{c'[s] - (-2 d[s] Sqrt[1 - f[s] c[s]^2])/f[s] == 0,
f'[s] - 4 Sqrt[1 - f[s] c[s]^2] == 0,
d'[s] - (-(2 c[s]^2 (d[s] - c0) + c[s] (c0^2 - d[s]^2) + LK*c[s] +
dP + 4 d[s] (1 - f[s] c[s]^2)/f[s]))/(Sqrt[
1 - f[s] c[s]^2]) == 0, f[0.0005] == 0.0001,
c[0.0005] == -0.50, d[0.0005] == 0.0001}, {c, f, d}, {s, 0.0005, 0.5}]
But this does not
dP = 17.48;
c0 = -4.0;
psol[LK_?NumericQ] :=
First@NDSolve[{c'[s] - (-2 d[s] Sqrt[1 - f[s] c[s]^2])/f[s] == 0,
f'[s] - 4 Sqrt[1 - f[s] c[s]^2] == 0,
d'[s] - (-(2 c[s]^2 (d[s] - c0) + c[s] (c0^2 - d[s]^2) + LK*c[s] +
dP + 4 d[s] (1 - f[s] c[s]^2)/f[s]))/(Sqrt[
1 - f[s] c[s]^2]) == 0, f[0.0005] == 0.0001,
c[0.0005] == -0.50, d[0.0005] == 0.0001}, {c, f, d}, {s, 0.0005, 0.5}]
psol[-33.9968]
Does anyone experience the same issue? What am I possibly doing wrong here.