2D finite difference method
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm trying to solve for for the node temperatures for a 2d finite difference method problem after a certain number of time interval have passed. I see that it is using the calculated temperatures within the for loop instead of the values from the previous iteration. I don't know how to overcome this to save the values from each iteration seperately until the next loop starts. I feel like i might need to scratch this and start over...? Suggestions?
clear
M = 76;
meshsize=0.2;
m = 1+(0.8/meshsize);
n = 1+(0.4/meshsize);
N=(((1498.6/meshsize^.2)*meshsize)/20); %heat transfer rate varies with y
A1=1-2/M;
A2=1-4/M;
A3=1-22.677/M;
A4=1-((4+2*(N))/M);
A5=1-(10/M);
A6=1-((2.5+(N))/M);
qg=400000*((meshsize^2)/20);
Ts = 60; %Fluid temp
dt=.004;
t = .5;
A=t/dt;
T = zeros(m,n);
%set starting temperature at nodes
for y = 1:m;
for x = 1:n;
T(y,x) = 60; %initial temperature throughout
end
end
for c = 1:A;
T1(1,1) = (1/M)*(T(2,1)+T(1,2)+0.5*qg)+(1-2.5/M)*T(1,1);
for x = 2:n-1;
for y = 2:m-1;
T1(y,1) = (1/M)*(2*T(y,2)+T(y-1,1)+T(y+1,1)+qg)+A2*T(y,1);
T1(1,x) = (1/M)*(2*T(y+1,x)+T(y,x+1)+T(y,x-1)+qg)+A2*T(2,x);
T1(y,x) = (1/M)*(2*T(y+1,x)+2*T(y-1,x)+2*T(y,x+1)+2*T(y,x-1)+2*qg)+A5*(T(y,x));
T1(y,n) = (1/M)*(2*T(y,n-1)+T(y-1,n)+T(y+1,n)+2*N*Ts+qg)+A4*T(y,n);
T1(1,n) = (1/M)*(T(1,n-1)+T(2,n)+N*Ts+.5*qg)+A6*T(1,n);
end
end
end
1 Commento
Torsten
il 20 Nov 2018
Use a three-dimensional matrix T1 where the first dimension saves time instants and the last two the spatial coordinate position.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Fluid Network Interfaces Library in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!