function [dxdt]=CLC_tank_func(p,m_dot,x,T_j)


m_M = x(1);
m_P = x(2);
T = x(3);

c_pM = p(7);
c_pP = p(8);
c_pW = p(9);
k_0= p(14);
k_1= p(15);
k_2= p(16);
E= p(17);
R= p(30);
c_0= p(18);
c_1= p(19);
c_2=p(20);
c_3 = p(21);
a_0=p(22);
m_W = p(3);
imp=0.8;
T_amb = p(43);
UA_loss = p(31);
delH = p(23);
rho_M = p(4);
rho_P = p(5);
rho_W = p(6);
P = p(50);
B_1 = p(49);
B_2 = p(51);
d_0 = p(24);
d_1 = p(25);
MW = p(10);


f=m_P/(m_M+m_P+m_W);
mu = c_0*exp(c_1*f)*10^(c_2*((a_0/T)-c_3));
k=k_0*exp(-E/(R*T))*((k_1*mu)^k_2);
Rp = imp*k*m_M;

A = ((m_M/rho_M)+(m_P/rho_P)+(m_W/rho_W))*(P/B_1)+B_2;

T_wall = (T+T_j)/2;
mu_wall = c_0*exp(c_1*f)*10^(c_2*((a_0/T_wall)-c_3));
h = d_0 * exp(d_1*mu_wall);
U = h;

dxdt(1) = m_dot-Rp;
dxdt(2)= Rp;
dxdt(3)= (1/(m_M*c_pM+m_P*c_pP+m_W*c_pW))*(m_dot*c_pM*(T_amb-T)...
            - U*A*(T-T_j)-(UA_loss*(T-T_amb))+(delH*Rp)/MW);


end