Newton Raphson method for Colburn equation
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
Hi all
I'm trying to solve the Colburn Equation using the Newton Raphson method with defined Re values.

Here's my code :
H = 10^(-4); %Epsilon/D = H
Re = 10e+4;
f_guess = 1; %initial guess for f
es = 0.0001; %desired relative error
max_it = 50; %maximum allowable iterations
F = @(f) -0.86*log(H/3.7 + 2.51/Re*f^(-0.5))-f^(-0.5);
dF = @(f) -0.5*f^(-1.5)*((-2.1586/Re)/(H/3.7+2.51/Re*f^(-0.5))-1);
f = newtraph(F,dF,f_guess,es,max_it);
newtraph is another function that was coded before (I checked it and it works for other equations)
For the given Re value, I'm trying to compute f but the f value returned is NaN + NaNi. Can I know what am I doing wrong here? Thanks
1 个评论
John D'Errico
2016-9-11
编辑:John D'Errico
2016-9-11
Why do you feel you need to write your own code (or use homegrown code) to solve a nonlinear equation? This is rarely a good idea.
回答(1 个)
John D'Errico
2016-9-11
编辑:John D'Errico
2016-9-11
I'll do a little transformation first to make things easy to write. So u=1/sqrt(f).
H = 1e-4;
Re = 10e4;
syms u
u0 = solve(-0.86*log(H/3.7 + 2.51/Re*u) == u,u)
u0 =
(43*wrightOmega(log(2951479051793528258560/63710626812015093) + 73786976294838206464/58932329801113961025))/50 - 36893488147419103232/34262982442508116875
vpa(u0)
ans =
7.2834730704352278783610246724575
f = 1/vpa(u0^2)
ans =
0.01885050382887345557780234289806
So pretty easy to solve it using symbolic tools.
If you intend to solve it numerically, then use fzero. Again, use u instead of f. It will make things work better. Believe me.
fun = @(u) -0.86*log(H/3.7 + 2.51/Re*u) - u;
u0 = fzero(fun,5)
u0 =
7.28347307043523
f = 1/u0^2
f =
0.0188505038288735
Absolutely no problem. Don't use homegrown code if there is no reason to do so, especially when you don't really know what you are doing in terms of numerical methods.
(Hint: If you really need to know why your home grown code failed, then learn to use the debugger. Look where the first Newton step probably took you.)
0 个评论
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!