% Dynamic model of the CSTR (adapted from srinivasan et al 2008)
% Johannes Jaeschke 
% June 2010
%
% States
%       na : V*ca          holdup a [mol a]
%		nb : V*cb          holdup b [mol b]
%		nc : V*c_c          holdup c [mol c]
%		nd : V*c_d          holdup d [mol d]
%		H  : H = rho*V*cp*T	reaction enthalpy [kJ]
%		V  : V              reaction volume [m3]




	
%State Equations 
xdot(1) =  Fa*cain - Fout*ca - k1*ca*cb*V;       % [mol A/h]
xdot(2) =  Fb*cbin - Fout*cb - k1*ca*cb*V - 2*k2*cb^2*V;	% [mol B/h]
xdot(3) = -Fout*cc + k1*ca*cb*V;		% [mol C/h]
xdot(4) = -Fout*cd + 2*k2*cb^2*V;		% [mol D/h]
xdot(5) =  Fa*cp*rho*(TinA-T) + Fb*cp*rho*(TinB-T) +  k1*ca*cb*V*(-DeltaH1) + 2*k2*cb^2*V*(-DeltaH2) - q; % [J/h]
xdot(6) =  Fa+Fb-Fout;				% [l/h]
		


