Visualizing transient laminar pipeflow

Posted in math on Thursday, July 24 2014

transient pipe flow

In a previous post I derived some equations for the velocity distribution as a function of time in transient pipe flow. Here it is visualized by Sage.

The Sage code is as follows

import mpmath as mp
xi, tau = var('xi tau')

def phi(xi,tau,n):
    sum = 0
    for i in range(1,n):
        l = float(mp.besseljzero(0,i))
        sum += (bessel_J(0,l*xi)/((l**3)*bessel_J(1,l)))*exp(-(l**2)*tau)
    phi = 0.25*(1-xi**2) - 2*sum
    return phi

g = Graphics()
for tau in sxrange(0,0.2,0.05):
    lbl_loc = (phi(0,tau,10),tau)
    lbl_txt = r"$\tau$ = %.2f" % (tau)
    g+= parametric_plot( (phi(xi,tau,10),xi), (xi,-1,1), aspect_ratio=0.25)
    g+= text(lbl_txt,lbl_loc, rgbcolor=(0,0,0) )


lbl_loc = (phi(0,10,10),0.2)
lbl_txt = r"$\tau$ = %.2f"" % (10)
g += parametric_plot( (phi(xi,10,10),xi), (xi,-1,1), aspect_ratio=0.25)
g += text(lbl_txt,lbl_loc, rgbcolor=(0,0,0) )
g += text(r"Plot of $\phi (\xi, \tau)$ for various values of $\tau", (0.15, 1), rgbcolor=(0,0,0))
g.axes_labels([r'$\phi$ axis (z axis)', r'$\xi$ axis'])
g.show()