I have a differential equation and I need to obtain the solution and evaluate it just after. The reason for this is that I need to give the values x, u and t as parameters, which I think should be done in a module. Somehow when I evaluate, I get the error "ReplaceAll::reps: {sol} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing." This only happens the first time I run it, if I run it a second time, it is like mathematica realizes that the solution does exist and lets me use it as replace just fine. This is my specific problem with some parameters:
σA = 0.2;
σX = 0.4;
sD = 0.13;
sS = 0.2;
ϕ = 95/100;
gA = (σX^2 (σX^2 (1 - ϕ) + \
σA^2))/(σX^2 + σA^2);
gB = (σX^2 σA^2)/(σX^2 + σA^2);
γA1[t_] := 1/( t (1/sD^2 + ϕ^2/sS^2) + 1/gA);
γB1[t_] := sD^2/ (t + sD^2/gB);
PDEC = - 2 HC[
p] (γB1[-p + u]/sD^2 - (
x (γB1[-p + u] - γA1[-p + u]) )/sD^2) + ( (
x (x - 1))/(2 sD^2)) +
2 HC[p]^2 ((γB1[-p + u] - γA1[-p + u])^2/
sD^2 + (ϕ^2 (γA1[-p + u])^2)/sS^2) -
Derivative[1][HC][p];
x = 1/3; u = 25; t = 0.1; sol =
NDSolve[{PDEC == 0, HC[0] == 0},
HC, {p, Re[(u - t) - 0.1], Re[(u - t) + 0.1]}]; Evaluate[
HC[25 - 0.1] /. sol]