Hi Aryo,
It seems like you are facing an issue while implementing the Newton-Raphson method correctly.
I suspect that you are getting inaccurate results for “alpha_k” and “Ra” where the Newton-Raphson method is converging. This might be due to the existence of multiple solutions. The function in question has multiple roots, specifically, 10 and -10. If you initialize "x0" with a negative number, for instance, -100, the Newton-Raphson method will converge to the root -10 after a sufficient number of iterations.
Refer to the following code:
x0 = 80;
eps = 0.4;
c_s = 5.67*10^(-8);
s1 = 0.250;
s2 = 0.015;
lamda1 = 0.35;
lamda2 = 22.7;
Tw_1 = 1200;
T_l = 10;
Tw_1 = 1200;
T_l = 10;
lambda_L = 25.12;
betha = 3.543*10^(-3);
v = 144.0*10^(-7);
L = 7;
B = 15;
A = B * L;
g = 9.81;
Pr = 0.7095;
Ra = @(x)Pr*(g*L^3*betha*(x-T_l))/v^2;
alpha_k = @(x)((0.825+(0.387*Ra(x)^1/6)/(1+(0.492/Pr)^9/16)^8/27)^2)*lambda_L/L;
func = @(x) (eps * c_s * x^4) + (alpha_k(x) + 1/(s1/lamda1+s2/lamda2)) * x - ((1/(s1/lamda1+s2/lamda2)) * Tw_1) + (alpha_k(x) * T_l);
% calculate root of func using fzero
x_true = fzero(func,x0,optimset("Display","iter"));
% initialize x0 to a negative value
x = -100;
x_old = 1000;
iter = 0;
while abs(x_old-x) > 1e-10 && iter <= 20 % x ~= 0
x_old = x;
dfunc = (func(x+1e-6)-func(x))*1e6; % derivative of func
x = x - func(x)/dfunc;
iter = iter + 1;
fprintf('Iteration %d: x=%.18f, err=%.18f\n', iter, x, x_true-x);
pause(1);
end
ak = alpha_k(x_true)
alpha_ges = ak + (eps *c_s*(x_true.^4-T_l.^4)/(x_true-T_l))
Q_ges = (1/((s1/lamda1+s2/lamda2)+1/alpha_ges))*A*(Tw_1-T_l)
(1/(s1/lamda1+s2/lamda2))*(Tw_1-x_true) % heat conduction
ak * (x_true-T_l) + (eps*c_s*x_true^4) % convection + thermal radiation
I have used the "fzero" function rather than the Newton-Raphson method you implemented. "fzero" incorporates a mix of bisection, secant, and inverse quadratic interpolation techniques. To verify, consider comparing your outcomes with those obtained using this method.
Refer to the following MATLAB documentation for further reference:
Hope this helps!
Best regards,
Saarthak