please help me with the code for table 13.2 of example 13.6 in (attached file) as it is not providing me the correct + all values of the equation.
2 ビュー (過去 30 日間)
古いコメントを表示
%%calculation for example of shortcut method distillation column
%%calculation for D
D = V/(1+R);
%%calculation for xD(c);xD(a);xD(b)
%%Taking C reference to r
xdc = xwc/(xwa*alphaAC^N + xwb*alphaBC^N + xwc*alphaCC^N);
xda = xwa*(xdc/xwc)*alphaAC^N;
xdb = xwb*(xdc/xwc)*alphaBC^N;
%% change in delta(t)= 0.5 hrs
for delta_t1 = [0 0.5 1 1.5 2]
W1 = W0-D*delta_t1;
%% with K=0
xwa1 = xwa+(xda-xwa)*((W1-W0)/W0);
xwb1 = xwb+(xdb-xwb)*((W1-W0)/W0);
xwc1 = xwc+(xdc-xwc)*((W1-W0)/W0);
%% Calculation of Nmin;Rmin
syms Rmin Nmin
solve(Rmin+(1.5835*(Nmin^1.7643))-10, Rmin-((2^Nmin-2)/(xwa1*(alphaAC)^Nmin+xwb1*(alphaBC)^Nmin+xwc1*(alphaCC)^Nmin)))
xdc1 = xwc1/(xwa1*alphaAC^Nmin + xwb1*alphaBC^Nmin + xwc1*alphaCC^Nmin);
xda1 = xwa1*(xdc1/xwc1)*alphaAC^Nmin;
xdb1 = xwb1*(xdc1/xwc1)*alphaBC^Nmin;
end
採用された回答
Voss
2022 年 11 月 15 日
編集済み: Voss
2022 年 11 月 15 日
The main thing you're missing is that the equations (e.g., Eq 13-22 and 13-23) are expressing the result at time k+1 in terms of the result at time k. That is, the result at any given time is calculated in terms of the result at the previous time (not in terms of the initial result at time 0), so you must update your variables on each iteration of the loop in order to use them for the calculation in the next iteration.
Doing that gives pretty close agreement with the table in the paper:
V = 110;
R = 10;
xwa = 0.33;
xwb = 0.33;
xwc = 0.34;
alphaAC = 2;
alphaBC = 1.5;
alphaCC = 1;
N = 3;
W0 = 100;
%%calculation for example of shortcut method distillation column
%%calculation for D
D = V/(1+R);
%%calculation for xD(c);xD(a);xD(b)
%%Taking C reference to r
xdc = xwc/(xwa*alphaAC^N + xwb*alphaBC^N + xwc*alphaCC^N);
xda = xwa*(xdc/xwc)*alphaAC^N;
xdb = xwb*(xdc/xwc)*alphaBC^N;
%% change in delta(t)= 0.5 hrs
t = 0;
delta_t = 0.5;
n_t_steps = 4;
% initialize a results table with the results at time 0:
results = table( ...
0,W0,xwa,xwb,xwc,NaN,NaN,xda,xdb,xdc, ...
'VariableNames',{'Time, h','W, kmol','xWA','xWB','xWC','Nmin','Rmin','xDA','xDB','xDC'});
for t_step = 1:n_t_steps
t = t+delta_t;
W1 = W0-D*delta_t;
%% with K=0
xwa1 = xwa+(xda-xwa)*((W1-W0)/W0);
xwb1 = xwb+(xdb-xwb)*((W1-W0)/W0);
xwc1 = xwc+(xdc-xwc)*((W1-W0)/W0);
%% Calculation of Nmin;Rmin
syms Rmin Nmin
soln = solve( ...
Rmin+(1.5835*(Nmin^1.7643))-10, ...
Rmin-((2^Nmin-2)/(xwa1*(alphaAC)^Nmin+xwb1*(alphaBC)^Nmin+xwc1*(alphaCC)^Nmin)));
xdc1 = xwc1/(xwa1*alphaAC^soln.Nmin + xwb1*alphaBC^soln.Nmin + xwc1*alphaCC^soln.Nmin);
xda1 = xwa1*(xdc1/xwc1)*alphaAC^soln.Nmin;
xdb1 = xwb1*(xdc1/xwc1)*alphaBC^soln.Nmin;
% update these variables to be used next time around:
W0 = W1;
xwa = xwa1;
xwb = xwb1;
xwc = xwc1;
xda = xda1;
xdb = xdb1;
xdc = xdc1;
% append them to the results table:
results{end+1,:} = [t,W0,xwa,xwb,xwc,soln.Nmin,soln.Rmin,xda,xdb,xdc];
end
disp(results);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!