function dx=cstr_dist_fun(u,V,ko,ER,DH,r,cp,UA)
%
% V:		reactor volume      				[L]
% ko:       costant 							[1/min]
% ER:       costant      						[K]
% DH:       molar enthalpy                   	[J/mol]
% r:      	liquid density  					[g/L]
% cp:       specific heat capacity       		[J/gK]
% UA:       heat transfer coefficient * area	[J/minK]
%
% u(1)=c:   concentration in the tank			[mol/L]
% u(2)=T:	temperature in the tank				[K]
% u(3)=cf:  concentration of the inflow     	[mol/L]
% u(4)=Tc:  temperature of the walls			[K]
% u(5)=q:   flow rate            				[L/min]
% u(6)=Tf:  input temperature        			[K]
%
% from the input vector u, we extract the states:
x=u(1:2);
%
% from the input vector u, we extract the controlled inputs to the system:
ui=u(3:4);
%
% from the input vector u, we extract the disturbance inputs to the system:
q=u(5);
Tf=u(6);
%
% We calculate the output:
%
dx(1)=(q/V)*[ui(1)-x(1)] - ko*[exp(-ER/x(2))]*x(1);
dx(2)=(q/V)*[Tf-x(2)] + [(-DH)/(r*cp)]*ko*[exp(-ER/x(2))]*x(1) + [UA/(V*r*cp)]*[ui(2)-x(2)];

