function [res]=cstrPT(x)
% CSTRPT is a steady-state lumped model of an
% exothermic continuous stirred tank reactor.
% unknown variables
C=x(1);
T=x(2);
% parameters
q=1.1; % m^3/h
C0=9000; % mol/m^3
T0=273+21; % K
V=1.3; % m^3
k0=6.99E10; % h^-1
Ea=69.418; % kJ/mol
R=0.00833; % kJ/(mol K)
rho=800; % kg/m^3
Cp=3.142; % kJ/(kg K)
dH=-69.9; % kJ/mol
U=3070; % kJ/(h m^2 K)
A=23; % m^2
Tj0=273+21; % K
qj=1.4; % m^3
rhoj=1000; % kg/m^3
Cpj=4.19; % kJ/(kg K)
% equations
k=k0.*exp(-Ea./(R.*T));
ra=k.*C;
Tj=(rhoj*qj*Cpj*Tj0+U*A.*T)./(rhoj*qj*Cpj+U*A);
% balances
resCB=q.*(C0-C)-V.*ra;
resEB=rho*Cp*q.*(T0-T)-dH*V.*ra-U*A.*(T-Tj);
res=[resCB; resEB];