function r=rx(T,c)
% r - reaction rate [kg NH3/ kg cat, s]
% T - temperature [C]
% c - mass faction NH3 [-] 
% Tempkin-Pyzhev kinetics; see Froment and Bischoff (199) p. 433
% Assumes noe inert and stochiometric mixtures of N2 and H2

global mc mh Cp Cpc Q1 Q2 Q3 Npoint Tf cf dm1 dm2 dm3 dHrx conc p

mNH3=c;  % mass fraction ammonia
mH2=(1-c)*6/34; 
mN2=(1-c)*28/34; 
nNH3=mNH3/17; 
nH2=mH2/2; 
nN2=mN2/28; 
x=nNH3/(nNH3+nH2+nN2)*1;  % mole fraction ammonia

R=8.31;
k1=1.79e+4*exp(-87090/(R*(T+273))); 
k2=2.57e+16*exp(-198464/(R*(T+273)));
pnh3=x*p ;     % partial pressure (bar)
pn=(1-x)*0.25*p; 
ph=(1-x)*0.75*p;
r=k1*pn*ph^1.5/pnh3 - k2*pnh3/ph^1.5;  % [mol N2/ m3 cat, h]
r=r*34/2200/3600;                      % [kg NH3/ kg cat, s]
r=4.75*r;  % Multiply by 4.75 to match industrial instability

