function [v] = CLTAA_transform1(p,A_tr,x,m_dot)

m_M0 = p(1); %initial mass of monomer in tank [kg]
m_P0 = p(2); %initial mass of polymer in tank [kg]
m_W0 =p(3); %initial mass of water in tank [kg]
rho_M = p(4); %density of monomer [kg/m3]
rho_P = p(5); %density of polymer [kg/m3]
rho_W = p(6); %density of water [kg/m3]
c_pM = p(7); %heat capacity of monomer [kJ/kgK]
c_pP = p(8); %heat capacity of polymer [kJ/kgK]
c_pW = p(9); %heat capacity of water [kJ/kgK]
MW_M = p(10); %molecular weight of monomer [kg/kmol]
m_c = p(11); %mass of coolant in system [kg]
mdot_c = p(12); %mass flowrate of coolant [kg/s]
c_pc = p(13); %heat capacity of coolant [kJ/kgK]
k_0 = p(14); %pre-exponential rate constant [s-1]
k_1 = p(15); %rate constant correction [ms/kg]
k_2 = p(16); %rate constant correction [-]
E = p(17); %activation energy [kJ/kmol]
c_0 = p(18); %batch viscosity correction [-]
c_1 = p(19); %batch viscosity correction [-]
c_2 = p(20); %batch viscosity correction [-]
c_3 = p(21); %batch viscosity correction [-]
a_0 = p(22); %batch viscosity correction [K]
del_Hp = p(23); %heat of polymerization [kJ/kmol]
d_0 = p(24); %heat transfer coefficient correction [kW/m2K]
d_1 = p(25); %heat transfer coefficient correction [ms/kg]
mdot_m = p(26); %mass flowrate of monomer - subject to scheduling [kg/s]
t_m0_in = p(27); %start time of monomer flow [s]
t_m1_in = p(28); %end time of monmomer flow [s]
T_set = p(29); %set-point of reactor temp [K]

R = p(30); %universal gas constant [kJ/kmolK]
UA_loss = p(31); %heat loss to surroundings coefficient [kW/K]
tau_p = p(32); %heating/cooling time constant [s]
theta_1= p(33); %time delay 1 [s]
theta_2= p(34); %time delay 2 [s]
i_top = p(35); %highest impurity factor
i_bot = p(36); %lowest impurity factor
ff_1 = p(37); %fouling factor for first batch [m2K/kW]
ff_2 = p(38); %fouling factor for second batch [m2K/kW]
ff_3 = p(39); %fouluing factor for third batch [m2K/kW]
ff_4 = p(40); %fouling factor for fourth batch [m2K/kW]
ff_5 = p(41); %fouling factor for fifth batch [m2K/kW]
T_ambW = p(42); %ambient temperature for winter [K]
T_ambS = p(43); %ambient temperature for summer [K]
T_inlet = p(44); %inlet temperature of cooling water [K]
T_steam = p(45); %inlet temperature of steam [K]
a_3 = p(46); %temp set-point parameter [-]
a_4 = p(47); %temp set-point parameter [-]
a_5 = p(48); %temp set-point parameter [-]
B_1 = p(49); %reactor bottom area [m2]
P = p(50); %jacket perimeter [m]
B_2 = p(51); %jacket bottom area [m2]

T_jin  = p(53);
T_jout = p(55);

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

m_W = m_W0;

T_jav = (T_jout+T_jin)/2;
T_wall = (T+T_jav)/2;

f = m_P/(m_M+m_P+m_W);

mu_wall = c_0 * exp(c_1*f)*10^(c_2*((a_0/T_wall)-c_3));
mu = c_0 * exp(c_1*f)*10^(c_2*((a_0/T)-c_3));

h = d_0 * exp(d_1 * mu_wall);
U = h; % first batch has no fouling

k = k_0 * exp(-E/(R*T))*(k_1*mu)^(k_2);

R_p = 1 * k * m_M; % take impurity factor = 1

Q_rx = R_p * (del_Hp/MW_M) ;

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

dTdt = (1/(m_M*c_pM + m_P*c_pP+m_W0*c_pW))*(m_dot*c_pM*(T_ambS-T)-...
U*A*(T-T_jav)-UA_loss*(T-T_ambS)+Q_rx);

one = (1/(m_M*c_pM + m_P*c_pP+m_W0*c_pW));
two = (m_dot*c_pM*(T_ambS-T));
three = U*A*(T-T_jav);
four = UA_loss * (T-T_ambS);
five= Q_rx;

v = dTdt -A_tr*T;


end

