How can you do an inner and outer loop with different convergence criteria ?
5 views (last 30 days)
Show older comments
I have attempted to solve a non linear PDE using the attached algorithm from the pic. I am struggling to implement in particular step 4 and 5 to do the outer loop. Please could you help me to solve that particular problem?? Thanks in advance.
clear;
clc
% initialise number of nodes
L=10,
M=21; % number of x nodes
dx=L/(M-1);
x=linspace(0,L,M) % discreet x values
T_alpha=200;
h_p=0.05;
Alpha_p=2.7*10^-9;
% initialise Guess
u=linspace(0,400,M);
% initialise Boundary conditions
u(1)=300;% right boundary
u(M)=400; % top boundary
% calculate temperature distribution
%
% for i=2:M-1
%
% end
err=1
for k=1:100
flag=1;
while flag==1
flag=0;
uold = u
% step 3
for i=2:M-1
f(i)=uold(i-1)-((2+dx^2*h_p)*uold(i))-(dx^2*Alpha_p*uold(i)^4+uold(i+1)+(dx^2*(h_p*T_alpha+Alpha_p*T_alpha^4)))
u(i)=(f(i)+uold(i-1)+uold(i+1))/(2+dx^2*h_p)+(4*dx^2*Alpha_p*(uold(i))^3);
error=abs(u(i)-uold(i))/uold(i);
if error > 10^-2
flag=1
end
end
end
end
plot(x,u,'rp--')
0 Comments
Answers (0)
See Also
Categories
Find more on Boundary Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!