function [dxdt]=ODEs_chain(x,u,d,p)

c_A = x(1);
T = x(2);

Q = u(1);

T_1 = d(1);
c_Af = d(2);
q_1 = d(3);

T_ref = p(1);                         %reference temp for rate constant [K]
V = p(2);                                                 %tank volume [m3]
c_p = p(3);                                %specific heat capacity [kJ/kgK]
E = p(4);                                      %activation energy [kJ/kmol]
rho = p(5);                                                %density [kg/m3]
k_ref = p(6);                              %reference rate constant [min-1]
R = p(7);                                %universal gas constant [kJ/Kkmol]
H_rx = p(8);                                    %heat of reaction [kJ/kmol]
%q_1 = p(9);
 
k = k_ref*exp((-E/R)*((1/T)-(1/T_ref)));

dxdt(1) = (q_1/V)*c_Af - ((q_1/V)+k)*c_A;

dxdt(2)= (q_1/V)*(T_1-T)-(H_rx*k*c_A)/(rho*c_p)+(Q/(V*rho*c_p));

end


