Value in Array does not Change
이전 댓글 표시
I'm simulating a Heat Exchanger Model with the HED Matrix in the program as discretized Heat Exchanger. The 1st row is the hot fluid matrix and 2nd row is the cold fluid matrix. The calculation is in a loop of timesteps. The temperature of the fluid changes as per the loss in enthalpy. But the temperature of the cold fluid does not change at all, it decreases at some timesteps when it should strictly increase. You can view the results at different time steps by tweaking the for loop with 't/j'. I have commented on the program, I'm stuck only on this, since the other part of program seems fine.
t = 25; % L/((m/rho)/CSArea); %Time for the fluid to cross Heat Exchanger
%Heat Transfer Coefficients
Hhot = 0.340;
Hcold = 0.400;
A = 1;
Cpcold = 4.179;
Cphot = 4.208;
%Initial Temperatures
Th = 363;
Tc = 303;
%number of fluids i
i = 1;
%discretization level; number of blocks fluid to be divided into j;
j = 100;
HED = zeros(i,j);
n=5; %timesteps
for j= 1:1:j
HED(i,j) = Th;
HED(i+1,j) = Tc;
end
Qrate = zeros(i,j);
for m = t/j:t/j:j*t/j
j=100;
for j =1:1:j
Qrate(i,j) = Hhot * A * (HED(i,j)-HED(i+1,j)); %Heat transfer Rate
end
Q1 = times(Qrate,t/j); %Heat transferred in timestep
for j = 0:1:j-1
%New Temperature of Cold Water after Heat Transfer
HED(i+1,j+1) = HED(i+1,j+1) + (Q1(i,j+1)/Cpcold);
%New Temperature of Hot Water after Heat Tranfer
HED(i,j+1) = HED(i,j+1) - (Q1(i,j+1)/Cphot);
end
for j=0:1:j-1
HED(i,j+1)=HED(i,j+2); %shifting row of hot fluid Row 1
HED(i+1,j+2)=HED(i+1,j+1); %shifting row of cold fluid Row 3
end
j=100;
HED(i,j) = Th;
HED(i+1,1) = Tc;
end
댓글 수: 1
the cyclist
2014년 10월 4일
The way that you use j as a constant and as a looping variable (and as the endpoint of that looping variable) is pretty confusing, and possibly the source of your bug. (MATLAB may interpret that correctly, but I'm not sure.)
답변 (1개)
the cyclist
2014년 10월 4일
This is a guess, because I have not run your code, but is the very last line right?
HED(i+1,1) = Tc;
Is that "1" right, or should it be j?
카테고리
도움말 센터 및 File Exchange에서 Fluid Network Interfaces Library에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!