Dear all, I am having a problem with the code enclosed. I can not get any results of the for loop as the results of for loop still zeros plus plotting these results. Any help please.

7 visualizaciones (últimos 30 días)
clc
clear all
close
tic
K = 273.15; % conversion constant Celcius to Kelvin
Tev = 10+K;
Tcond = 40+K;
%Tgen = 200+K;
delT = .1;
dT = delT*2;
Mz = 1; %mass of zeolite in kg. Bed1 and Bed2 have equal masses
Cz = 0.920; %specific heat of zeolite [kJ/kg K]
Cw = 4.187; %specific heat of water [kJ/kg K]
Cv = 1.85; %specific heat of water vapor [kJ/kg K]
Pcond =(Tcond-K);
Pev =(Tev-K);
k=100;
%Maximum Adsorbate/Adsorbent ratio is found by using evaporator
%temperature (Tev) and adsorption equilibrium equation function AdsW.
run = 40;
Qreg = zeros(run,1);
Qads = zeros(run,1);
Qsa = zeros(run,1);
Qsve = zeros(run,1);
Qe = zeros(run,1);
Qa = zeros(run,1);
Qa1 = zeros(run,1);
Qic1 = zeros(run,1);
Qd1 = zeros(run,1);
Qtot = zeros(run,1);
COP = zeros(run,2);
Ta1 = zeros(run,1);
T1new = zeros(run,1);
Thot = zeros(run,1);
count = zeros(run,1);
count2 = zeros(run,1);
WWmin = zeros(run,1);
sayac = zeros(run,1);
Temp = zeros(run,1);
Tint = zeros(run,2);
Ta2new = zeros(run,1);
P_hot = zeros(run,1);
P_cool = zeros(run,1);
threshold = 0.01;
regtemp = 59; %initial regeneration temperature
function AdsW = AdsW(Tgen,Pcond)
for i = 1:length (run)
Tgen = regtemp+K+i;
Wmin = AdsW1_TP(Tgen,Pcond);
%assuming adsorption temp (Ta2) is equal to Tcond
Wmax = AdsW1_TP(Tcond,Pev);
Tg1 = AdsW3_PW(Pcond,Wmax);
Ta2 = AdsW3_PW(Pev,Wmax);
Ta1(i) = AdsW3_PW(Pev,Wmin);
WWmin(i) = Wmin;
T1new(i) = Ta2; %Bed 1 is assumed to be cool
count2(i) = (Tgen-Ta1(i))/delT;
Qdes = 0;
Qsd = 0;
W2 = Wmin;
W1 = Wmax;
Ta2new(i) = Ta2; %used in modeling mass recovery
%Mass Recovery Process
for T=Tgen:-delT:(Ta1+delT)
delW = (Cz + W2*Cw)*delT / AdsH(W2);
Wnew = W2-delW;
if ((abs((W2-Wnew)/W2)) > threshold)
delW = (Cz + (W2-delW/2)*Cw)*delT / AdsH(W2-delW/2);
Wnew = W2-delW;
end
P_hot(i) = AdsW2_TW(T,Wnew);
A = (AdsH(W1+delW/2)*delW)/(Cz + (W1+delW/2)*Cw);
T_cool = Ta2new(i) + A;
Ta2new(i) = T_cool;
P_cool(i) = AdsW2_TW(T_cool,W1+delW/2);
W1 = W1+delW/2;
W2 = W2-delW/2;
if(P_cool(i) > P_hot(i))
break
end
end
T1new(i) = AdsW3_PW(P_cool(i),W1);
Tint(i) = T1new(i);
Tg1 = AdsW3_PW(Pcond,W1);
Tgen = AdsW3_PW(P_hot(i),W2);
Wmin = W2;
Wmax = W1;
%Heat Recovery Process
for T=Tgen:-delT:(Ta2+delT)
Thot(i) = T;
Qic = 0;
if (T > T1new(i) && T1new(i) < Tg1) %defines isosteric cooling
%Isosteric cooling process for BED2 (3->4) in P-T-w diagram
Qic = Mz*(Cz + Cw*Wmin)*(delT);
Qic1(i) = Qic1(i) + Qic;
%Isosteric heating process for BED1 (1->2) in P-T-w diagram
T1new(i) = T1new(i) + Qic / (Mz*(Cz + Cw*Wmax));
% count(i) = count(i)+1;
elseif (T > T1new(i) && T1new(i) > Tg1)
%Resorption process (2->3) in P-T-w diagram
W_before = AdsW1_TP(T,Pev);
W_after = AdsW1_TP((T-delT),Pev);
%Average heat of desorption for each step
H_avg = (AdsH(W_before) + AdsH(W_after))/2;
%heat relased as a result of desorption
Qads(i) = Mz*H_avg*(W_after-W_before);
%heat released as a result of sensible cooling
Qsa(i) = Mz*(Cz + Cw*(W_after-W_before))*delT;
%heat absorbed as a result of heating up the vapor from
%evaporation to adsorption temperature
Qsve(i) = Mz*(W_after-W_before)*Cv*((0.5*(b(W_after)/...
(log(Pev)-a(W_after)))+(b(W_before)/...
(log(Pev)-a(W_before))))-Tev);
Qa(i) = Qads(i) + Qsa(i) - Qsve(i);
Qa1(i) = Qa1(i) + Qads(i) + Qsa(i) - Qsve(i);
for Tvar=T1new(i):(dT/k):(T1new(i)+dT)
if (Qa(i) > Qd1(i))
W_before = AdsW1_TP(Tvar,Pcond);
W_after = AdsW1_TP((Tvar+dT/k),Pcond);
%Average heat of desorption for each step
H_avg = (AdsH(W_before) + AdsH(W_after))/2;
%heat of desorption
Qdes = Qdes + Mz*H_avg*(W_before-W_after);
%sensible heat
Qsd = Qsd + Mz*(Cz + Cw*(W_before-W_after))*(dT/k);
Qd1(i) = Qdes + Qsd;
sayac(i) = sayac(i)+1;
else
break
end
end
T1new(i) = T1new(i)+ (sayac(i)*(dT/k));
else
break %recovery process finished
end
Temp(i) = T;
end
Qreg(i) = Qic1(i) + Qa1(i);
%intermiitent cycle (heat necessary without heat recovery)
Tgen = regtemp+K+i;
%Wmax = AdsW1_TP(Tcond, Pev);
Wmin = AdsW1_TP(Tgen,Pcond);
%Tg1 = AdsW3_PW(Pcond,Wmax);
Qih = 0;
Qdes = 0;
Qsd = 0;
%Heat that must be supplied to the adsorbent for its isosteric heating
Qih = Qih + Mz*(Cz + Cw*Wmax)*(Tg1-Tint(i));
for T=Tg1:delT:(Tgen-delT)
W_before = AdsW1_TP(T,Pcond);
W_after = AdsW1_TP((T+delT),Pcond);
%Average heat of desorption for each step
H_avg = (AdsH(W_before) + AdsH(W_after))/2;
%heat of desorption
Qdes = Qdes + Mz*H_avg*(W_before-W_after);
Qsd = Qsd + Mz*(Cz + Cw*(W_before-W_after))*delT;
end
%From Cacciola & Restuccia "influence of HEX design...
LH2O = 3172-2.4425*Tev;
Qe(i) = Mz*(W1-W2)*(LH2O - Cw*(Tcond-Tev));
Qd = Qdes + Qsd;
Qtot(i) = Qd + Qih - Qreg(i);
COP(i,1) = Tgen-K;
COP(i,2) = Qe(i)/Qtot(i);
Qd=0;
end
toc
t = toc/60 %#ok<NOPTS>
i = 1:run;
plot(COP(i,1),COP(i,2),'-');
end

Respuestas (2)

Image Analyst
Image Analyst el 26 de Dic. de 2018
Your code just simply assigns a bunch of variables and then quits. It never calls any of the functions in the file. Why not? That's why nothing gets plotted - you never called a function that will do any plotting.

Vova
Vova el 28 de Mzo. de 2019
Did you solve out the problem?

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by