I am writing a code using the 4th order runge kutta method, for heat transfer through an adiabatic fin, i am having some problems getting the code to work, any advice?

17 Ansichten (letzte 30 Tage)
%%4th order runge kutta-uniform cross section fins
%circular pin fin- pure aluminium
%assumptions
%1D steady state heat transfer
%dimensions
L=0.05;
D=0.005;
%parameters
h=50;
k=237;
Tb=60;
Ta=15;
P=pi*D;
Ac=pi*D^2/4;
m=sqrt(h*P/k*Ac);
%Boundary conditions
%BC1 Theta(0)=Tb-Ta
%BC2 dtheta/dx at x=L =0
%inputs
H=0.0004; %step size
Lmax=0.05; %total length
N=Lmax/H; %Number of steps
%Initial conditions
L(1)=0;
T(1)=60;
z(1)=0;
m=1;
z(100)=0;
x(1)=0;
while m>0.00001;
for i=1:N
%equations for k values
k1=z(i);
k2=z(i)+(H*L1/2);
k3=z(i)+(H*L2/2);
k4=z(i)+(H*L3);
%equation for T(i+1)
T(i+1)=T(i)+(H/6)*(k1+(2*k2)+(2*k3)+k4);
%equations for L values
L1=((h*P/k*Ac).*(T(i)));
L2=((h*P/k*Ac).*(T(i)+(H*k1/2)));
L3=((h*P/k*Ac).*(T(i)+(H*k2/2)));
L4=((h*P/k*Ac).*(T(i)+(H*k3)));
%equation for z(i+1)
z(i+1)=z(i)+(H/6)*(L1+(2*L2)+(2*L3)+L4);
%equation for x(i+1)
x(i+1)=x(i)+H;
end
z(1)=z(1)-z(i+1);
m=abs(z(i+1)-z100);
end
  4 Kommentare
Torsten
Torsten am 6 Apr. 2022
Bearbeitet: Torsten am 6 Apr. 2022
You solve the boundary value problem
d^2T/dx^2 = 0
T(x=0) = 60
dT/dx(x=0.05) = 0
don't you ?
If this is the case, the solution should be clear:
T(x) = a*x + b
where the constants a and b follow from the boundary conditions (in your case T=60 for all x).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by