|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
各位大虾 ,偶碰到这个问题n久也没弄明白怎么回事,请各位指点一下
哦,对了,补充一下,程序里所有的输出变量的值都能算出来,然后最后出现这个报错的
function CeqHE=Heater(HEObj)
% Heater calculates the residual error of a Heater block.
% Input: HEObj is a block with the following structure
% HEObj = struct('T',[],'P',[],'Q',[],'Sin',[],'SoutL',[],'SoutV',[],'r1',[],'r2',[]);
% T: Heater temperature (K);
% P: Heater pressure (psi);
% Q: Heater input duty (MJ/s);
% Sin: Heater feed(s), stream structure;
% SoutL: Heater liquid product, stream structure;
% SoutV: Heater vapor product, stream structure;
% Output:CeqHE is the residual error of block HEObj;
%
% For DOF analysis reference:
% DOF = No.(Sin)*NV(Stream) + 2; Degree of freedom;
% NFreeVar = No.(SoutL,SoutV)*NV(Stream) + 1; No. of free variables;
Stream = struct('T',[],'P',[],'F',[],'C',[]);
SinL = Stream;
SinV = Stream;
disp(HEObj.Sin);
disp(HEObj.SoutL);
disp(HEObj.SoutV);
[SinV,SinL,K] = VL(HEObj.Sin,HEObj.r1,HEObj.Sin.T);
SinL.F = HEObj.Sin.F*HEObj.Sin.C'*K';
SinV.F = HEObj.Sin.F-SinL.F;
disp(SinL);
disp(SinV);
disp(K);
TBub = 290;
TDew = 310;
% NC: Number of components;
NC = length(HEObj.Sin.C);
% Calculation of the enthalpies of the feeds using srk function;
% Temporarily,to be revised later;
%[Sin_K,SinL_H,SinV_H] = srk(HEObj.Sin.T,HEObj.Sin.P,SinL.C(:),SinV.C(:)); %MJ/kmol;43682458.1/1e6;
SinL_H = 2;
SinV_H = 3;
Sout_K = [.4 .3 .2 .3];
SoutL_H = 4;
SoutV_H = 5;
% Residual error between temperature and pressure state of the heater object and the product streams;
CeqF(1) = HEObj.SoutL.T-HEObj.T;
CeqF(2) = HEObj.SoutV.T-HEObj.T;
CeqF(3) = HEObj.SoutL.P-HEObj.P;
CeqF(4) = HEObj.SoutV.P-HEObj.P;
disp(CeqF);
% Residual error of Equilibrium equations
for i=1:NC
CeqE(i) = - HEObj.SoutV.C(i) + Sout_K(i)*HEObj.SoutL.C(i);
end
Sin = HEObj.Sin;
SoutL = HEObj.SoutL;
SoutV = HEObj.SoutV;
T = SoutL.T;
if T<TBub
SoutV() = 0;
CeqE = zeros(1,NC);
elseif T>TDew
SoutL() = 0;
CeqE = zeros(1,NC);
end
disp(CeqE);
% Efficiency of the followings can be enhanced later by removing the original 'for' statement using vector operations
% Residual error of Mass balance equations;
for i=1:NC
SumSinMi = Sin.F*HEObj.Sin.C(i);
CeqM(i) = -SumSinMi + SoutL.F*HEObj.SoutL.C(i) + SoutV.F*HEObj.SoutV.C(i);
end
disp(CeqM);
% Conditional Modeling %
% Residual error of Summation equations
CeqSx = sum( HEObj.SoutL.C)-1;
CeqSy = sum( HEObj.SoutV.C)-1;
if T<TBub
CeqSy = (sum(HEObj.SoutV.C)-1)*SoutV.F;
elseif T>TDew
CeqSx = (sum(HEObj.SoutL.C)-1)*SoutL.F;
end
disp(CeqSx);
disp(CeqSy);
% Conditional Modeling %
% Residual error of entHalpy equations % with potential problem
SumSinH = SinL.F*SinL_H + SinV.F*SinV_H;
CeqH = - SumSinH - HEObj.Q + SoutV.F*SoutV_H+ SoutL.F*SoutL_H;
disp(CeqH);
% Residual error of r
r1 = HEObj.r1;
disp(r1);
CeqSum1 = 0;
disp(CeqSum1);
r2 = HEObj.r2;
disp(r2);
CeqSum2 = 0;
disp(CeqSum2);
% Total residual errors of HEObj
CeqPA = [CeqF(:)' CeqM(:)' CeqE(:)' CeqSx CeqSy CeqH CeqSum1 CeqSum1];
disp(CeqPA);
程序就是这样的,执行到最后的disp(CeqPA)结果可以出的,然后就是报错……
[ 本帖最后由 sdzx112233 于 2006-10-26 10:40 编辑 ] |
|