function r=Rr(y,T,P)
% y : Mole fractions      [mol/mol]
% P : Reactor pressure    [bar]
% T : Reactor temperature [K]

r=zeros(4,1);
H2=1;
Ga=2;
Pa=3;
Na=4;
Ar=5;

P=P*100;                                                     % Total pressure [kPa]
p=P*y;                                                       % Component Partial pressure [kpa]
k=kf(T);
K=Keq(T);

r(1)=k(1)/K(1)*(K(1)*p(Na)-p(Ar)*p(H2)^3);   % N <=> A + 3H2  [mol/(kg*s)]   Conversion of naphthenes to aromatics
r(2)=k(2)/K(2)*(K(2)*p(Na)*p(H2)-p(Pa));     % N + H2 <=> P   [mol/(kg*s)]   Conversion of naphthenes to paraffins
r(3)=k(3)*p(Na)/P;                           % N + H2 <=> 2G  [mol/(kg*s)]   Hydrocracking of naphthenes(first order reaction)
r(4)=k(4)*p(Pa)/P;                           % P + H2 <=> 2G  [mol/(kg*s)]   Hydrocracking of paraffins (first order reaction)

% Unit change from [kmol/(kg*h)] to [kmol/(kg*s)]
r=r./3600;

return