I am trying to solve a 1st order non-linear ODE
W[y]*W'[y] + W[y]*v + Fnum == 0 /. v -> 10
Fnum = 0.05 - 1.66667 y + (270.27 y)/(1 + 270.27 y) - (660. y)/(1 + 1666.67 y)
The function Fnum has three zeros. two of them are at y=StartY and y=EndY.
In[1]:= StartY = 0.00021578513459560855`;
In[2]:= EndY = 0.3870868735615052`;
In[3]:= Fnum = 0.05 - 1.66667 y + (270.27 y)/(1 + 270.27 y) - (660. y)/(1 +
1666.67 y)
Out[3]= 0.05 - 1.66667 y + (270.27 y)/(1 + 270.27 y) - (660. y)/(1 + 1666.67 y)
In[4]:= Fnum /. y -> StartY
Out[4]= 2.62289*10^-9
In[5]:= Fnum /. y -> EndY
Out[5]= -5.10119*10^-7
My boundary condition is W[y=StartY] == 0. However, if it set this NDSolve gives an error
s = NDSolve[{W[y]*W'[y] + W[y]*v + Fnum == 0 /. v -> 10,
W[StartY] == 0 /. v -> 10}, W, {y, StartY, EndY}];
Power::infy: Infinite expression 1/0. encountered. >>
NDSolve::ndnum: Encountered non-numerical value for a derivative at y == 0.00021578513459560855`. >>
I am guessing this happens because Mathematica cannot solve W[y]' at y=StratY
W'[y] = -v + Fum[y]/W[y] ~ -v + 0/0.
So, I am now trying to find W'[y=StartY] analytically by expanding Fnum near y=StartY and I find that W'[y=StartY]=dW. I show here only that my solution satisfies the differential equation with Fnum[StartY]=0 and boundary condition W[StartY=0]:
In[8]:= Slope = Coefficient[Normal[Chop[Series[Fnum, {y, StartY, 1}]]], y, 1]
Out[8]= -117.385
In[13]:= dW = (Sqrt[v^2 - 4*Slope] - v)/2;
In[14]:= Solve[W*dW + W*v + Fnum == 0 /. {y -> StartY, v -> 10}, W]
Out[14]= {{W -> -1.54903*10^-10}}
Now I go back to NDSolve and I am trying W'[StartY] = dW as boundary condition
s = NDSolve[{W[y]*W'[y] + W[y]*v + Fnum == 0 /. v -> 10, W'[StartY] == (Sqrt[v^2 - 4*Slope] - v)/2 /. v -> 10}, W, {y, StartY, EndY}]
I get the following error:
NDSolve::icordinit: The initial values for all the dependent variables are not explicitly specified. NDSolve will attempt to find consistent initial conditions for all the variables. >>
NDSolve::icres: NDSolve has computed initial values that give a zero residual for the differential system, but some components are different from those specified. If you need them to be satisfied, giving explicit initial values to all dependent variables is recommended. >>
NDSolve::ndsz: At y == 0.0854996004928462`, step size is effectively zero; singularity or stiff system suspected. >>
In spite of the errors, NDsolve does manage to find a solution. However, NDSolve does find a solution which with W[StartY]=1, which is not consistent.
In[15]:= Evaluate[W[StartY] /. s]
Out[15]= {1.}
What am I doing wrong? What do the error mean? Why NDSolve finds a solution which is not consistent with my boundary conditions?
In[4]:= Fnum /. y -> StartY
,Out[4]= 2.62289*10^-9
. Execute2.62289*10^-9 == 0
to check. (Another side point: It will encourage more users to try out your code if they can copy and paste it in Mathematica without editing it. The In and Out tags make it inconvenient. A convention many follow is to put output in comments.) $\endgroup$