Obtain imaginary numbers in for loop but running code at each step on its own produces absolute numbers
1 view (last 30 days)
Show older comments
The following is the code I have created. I know the equations are correct because running utside a forloops fofr each step gives me the corect values and the creating a table in excel gives me the correct values. I've also tried plotting (tr/tg, x), which should give a curve but these values give a linear trend.
%Constants
T = 375;% C
Tk = T+273.15; %Kelvin
a = 1;
b = 2;
c = 1;
d = 2;
densB = 3400; %kg/m3
mmB = 0.134452;%kg/mol
P = 100000; %Pa
R1 = 8.31446; %m3-Pa/K-mol
%Reaction kinetics
k = 0.00011; % m3/m2-s
De = 0.00000000203; %m2/s
Cb0 = densB/mmB; % mol/m3, average steam concentration
Ca0 = (0.21*P)/(R1*Tk); % mol/m3
%Time and SCM
d = 200;
x(1) = 0; %initial conversion values
n = 0.01;
for i=1:101
Rp = (d./2)./1000000
taug = ((Cb0.*(Rp.^2))./(6.*b.*De.*Ca0))
taur = ((Cb0.*Rp)./(b*k*Ca0))
diff = (1-(3.*((1-x).^(2/3)))+(2.*(1-x)))
reac = (1-((1-x).^(1/3)))
Tcg = (taug.*diff)/60
Tcr = (taur.*reac)/60
x(i+1) = x(i) + n;
end
0 Comments
Answers (1)
Torsten
on 20 Oct 2022
Edited: Torsten
on 20 Oct 2022
diff = (1-(3.*((1-x(i)).^(2/3)))+(2.*(1-x(i))))
reac = (1-((1-x(i)).^(1/3)))
instead of
diff = (1-(3.*((1-x).^(2/3)))+(2.*(1-x)))
reac = (1-((1-x).^(1/3)))
And make an array out of the variable you want to plot against x, e.g.
diff(i) = ...
reac(i) = ...
Tcg(i) = ...
Tcr(i) = ...
And the loop should run up to 100, not 101.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!