Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function psat=psat(t,const)
- for i=1:rows(const)
- psat(i)=exp(const(i,1)-const(i,2)/(t+const(i,3)));
- end
- endfunction
- function tsat=tsat(p,const)
- for i=1:rows(const)
- tsat(i)=const(i,2)/(const(i,1)-log(p))-const(i,3);
- end
- endfunction
- function pbr=pbr(t,x,const)
- psats=psat(t,const);
- p=sum(x.*psats);
- y=x.*psats/p;
- pbr=[y p];
- endfunction
- x=[0.3,0.7];
- ctes=[14.2724,2945.47,224;14.2043,2972.64,209];
- res=pbr(75,x,ctes)
- function prr=prr(t,y,const)
- psats=psat(t,const);
- p=1/sum(y./psats);
- x=p*y./psats;
- for i=1:length(y)
- prr.(['x',num2str(i)])=x(i);
- end
- prr.('P')=p;
- endfunction
- ctes=[14.2724,2945.47,224;14.2043,2972.64,209];;
- ys=[0.3,0.7];
- res=prr(75,ys,ctes)
- function tbr=tbr(p,x,const,ref)
- tsats=tsat(p,const);
- tguess=mean(tsats);
- tol=0.001;
- while 1
- psats=psat(tguess,const);
- alfas=psats/psats(ref);
- psatrefn=p/sum(x.*alfas);
- tsatrefn=tsat(psatrefn,const(ref,:));
- if abs(tguess-tsatrefn)<=tol
- break
- else
- tguess=tsatrefn;
- end
- end
- y=x.*psats/p;
- tbr=[y tsatrefn];
- endfunction
- const=[14.2724,2945.47,224;14.2043,2972.64,209];
- xs=[0.6,0.4];
- res=tbr(70,xs,const,2)
- function trr=trr(p,y,const,ref)
- tsats=tsat(p,const);
- tguess=mean(tsats);
- tol=0.001;
- while 1
- psats=psat(tguess,const);
- alfas=psats/psats(ref);
- psatrefn=p*sum(y./alfas);
- tsatrefn=tsat(psatrefn,const(ref,:));
- if abs(tguess-tsatrefn)<=tol
- break
- else
- tguess=tsatrefn;
- end
- end
- x=p*(y./psats);
- trr=[x tsatrefn];
- endfunction
- const=[14.2724,2945.47,224;14.2043,2972.64,209];
- ys=[0.3,0.7];
- res=trr(70,ys,const,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement