Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.78 KB | None | 0 0
  1. function psat=psat(t,const)
  2.   for i=1:rows(const)
  3.     psat(i)=exp(const(i,1)-const(i,2)/(t+const(i,3)));
  4.   end
  5. endfunction
  6.  
  7. function tsat=tsat(p,const)
  8.   for i=1:rows(const)
  9.     tsat(i)=const(i,2)/(const(i,1)-log(p))-const(i,3);
  10.   end
  11. endfunction
  12.  
  13. function pbr=pbr(t,x,const)
  14.     psats=psat(t,const);
  15.     p=sum(x.*psats);
  16.     y=x.*psats/p;
  17.     pbr=[y p];
  18. endfunction
  19.  
  20. x=[0.3,0.7];
  21. ctes=[14.2724,2945.47,224;14.2043,2972.64,209];
  22. res=pbr(75,x,ctes)
  23.  
  24. function prr=prr(t,y,const)
  25.     psats=psat(t,const);
  26.     p=1/sum(y./psats);
  27.     x=p*y./psats;
  28.     for i=1:length(y)
  29.         prr.(['x',num2str(i)])=x(i);
  30.     end
  31.     prr.('P')=p;
  32. endfunction
  33.  
  34. ctes=[14.2724,2945.47,224;14.2043,2972.64,209];;
  35. ys=[0.3,0.7];
  36. res=prr(75,ys,ctes)
  37.  
  38. function tbr=tbr(p,x,const,ref)
  39.     tsats=tsat(p,const);
  40.     tguess=mean(tsats);
  41.     tol=0.001;
  42.     while 1
  43.         psats=psat(tguess,const);
  44.         alfas=psats/psats(ref);
  45.         psatrefn=p/sum(x.*alfas);
  46.         tsatrefn=tsat(psatrefn,const(ref,:));
  47.         if abs(tguess-tsatrefn)<=tol
  48.             break
  49.         else
  50.             tguess=tsatrefn;
  51.         end
  52.     end
  53.     y=x.*psats/p;
  54.     tbr=[y tsatrefn];
  55. endfunction
  56.  
  57. const=[14.2724,2945.47,224;14.2043,2972.64,209];
  58. xs=[0.6,0.4];
  59. res=tbr(70,xs,const,2)
  60.  
  61. function trr=trr(p,y,const,ref)
  62.     tsats=tsat(p,const);
  63.     tguess=mean(tsats);
  64.     tol=0.001;
  65.     while 1
  66.         psats=psat(tguess,const);
  67.         alfas=psats/psats(ref);
  68.         psatrefn=p*sum(y./alfas);
  69.         tsatrefn=tsat(psatrefn,const(ref,:));
  70.         if abs(tguess-tsatrefn)<=tol
  71.             break
  72.         else
  73.             tguess=tsatrefn;
  74.         end
  75.     end
  76.     x=p*(y./psats);
  77.     trr=[x tsatrefn];
  78. endfunction
  79.  
  80. const=[14.2724,2945.47,224;14.2043,2972.64,209];
  81. ys=[0.3,0.7];
  82. res=trr(70,ys,const,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement