This is probably the simplest model of a dynamic heated/cooled pipe.
The equations "on paper" are:
min = mout
pin - pout = deltaP=K.min|min|
dU/dt = mout.hout - min.hin + Q
Representing the conservation of mass, momentum and energy where
U = m.u is the internal energy
m is the mass of the fluid inside the pipe
u is the specific internal energy defined as cp.T or h - p/rho