In [1]:
%matplotlib inline
# plots graphs within the notebook
%config InlineBackend.figure_format='svg' # not sure what this does, may be default images to svg format
from IPython.display import Image
from IPython.core.display import HTML
def header(text):
raw_html = '<h4>' + str(text) + '</h4>'
return raw_html
def box(text):
raw_html = '<div style="border:1px dotted black;padding:2em;">'+str(text)+'</div>'
return HTML(raw_html)
def nobox(text):
raw_html = '<p>'+str(text)+'</p>'
return HTML(raw_html)
def addContent(raw_html):
global htmlContent
htmlContent += raw_html
class PDF(object):
def __init__(self, pdf, size=(200,200)):
self.pdf = pdf
self.size = size
def _repr_html_(self):
return '<iframe src={0} width={1[0]} height={1[1]}></iframe>'.format(self.pdf, self.size)
def _repr_latex_(self):
return r'\includegraphics[width=1.0\textwidth]{{{0}}}'.format(self.pdf)
class ListTable(list):
""" Overridden list class which takes a 2-dimensional list of
the form [[1,2,3],[4,5,6]], and renders an HTML Table in
IPython Notebook. """
def _repr_html_(self):
html = ["<table>"]
for row in self:
html.append("<tr>")
for col in row:
html.append("<td>{0}</td>".format(col))
html.append("</tr>")
html.append("</table>")
return ''.join(html)
font = {'family' : 'serif',
'color' : 'black',
'weight' : 'normal',
'size' : 18,
}
This notebook lists the guidelines for a successful final exam. You will find also an example of velocity profile for a jet and a small python code to provide turbulent inlet conditions for the $k-\omega$ model.
The following describes the slides expected during the presentation
Name of the project and a picture of your CAD
Describe the purpose of your simulation, which could be:
Self-explanatory: Velocity and length scales, Re, Ma (if necessary), any non-dimensional number that characterizes the flow, do you think the flow is turbulent or laminar?
Provide a sketch of screen grab of your bounding box and any region of refinement you defined. Define boundary conditions on the faces of your computational domain
Show evidence that you did some mesh refinement study. Two level of refinements would be fine, higher level of convergence would be appreciated if the CPU cost is low enough. You need to clearly define and justify the metric (variable) used for assessing the adequacy of the mesh.
Show what worked and did not work. Show velocity profiles and contours, same for pressure or anything that you found interesting and characteristic of your flow.
In [2]:
import matplotlib.pyplot as plt
import numpy as np
r = np.linspace(0.,5.,1000)
r0 = 0.8
r1 = 1.0
u = 0.5*(np.power(np.abs(1-r/r0),1./7.))*0.5*((r0-r)+np.abs(r0-r))/(np.abs(r0-r)+1e-6) \
+0.01*0.5*((r-r1)+np.abs(r-r1))/(np.abs(r-r1)+1e-6)
plt.plot(r,u,lw = 2)
#plt.legend(loc=3, bbox_to_anchor=[0, 1],
# ncol=3, shadow=True, fancybox=True)
plt.xlabel('$r$', fontdict = font)
plt.ylabel('$U$', fontdict = font)
plt.xticks(fontsize = 16)
plt.yticks(fontsize = 16)
plt.show()
Internal flows are defined as cylindrical pipes, ducts and annulus. The flow is characterized by:
In [3]:
geo = input('Boundary layer (b), channel (c), pipe (p), duct (d), or annulus (a)?')
if geo == 'b':
D = float(input('boundary layer thickness (m):'))
elif geo == 'c':
D = float(input('Channel height (m):'))
elif geo == 'p':
D = float(input('Diameter (m):'))
elif geo == 'd':
a = float(input('first dimension (m):'))
b = float(input('second dimension (m):'))
D = 4.*a*b/(2.*(a+b))
elif geo == 'a':
Di = float(input('Inner diameter (m):'))
Do = float(input('Outer diameter (m):'))
D = Do - Di
else:
print('your geometry is unknown')
u_cal = input('for velocity scale: mass flow (m) or bulk velocity (u)?')
if u_cal == 'u':
U_b = float(input('Velocity scale (m/s):'))
elif u_cal == 'm':
m = float(input('mass flow rate (kg/s):'))
rho = float(input('fluid density (kg/m^3):'))
if geo == 'p':
area = np.pi*(D**2)/4.
elif geo == 'd':
area = a*b
elif geo == 'a':
area = np.pi/4.*(Do**2-Di**2)
U_b = m/(rho*area)
print('bulk velocity: %10.3e m/s' %U_b)
nu = float(input('Kinematic viscosity (m^2/s):'))
Re = U_b*D/nu
print("Reynolds number: %10.3e" %Re)
I_rec = 0.16*Re**(-1./8.)
print("Recommended turbulent intensity for pipe/duct: %10.3e" %I_rec)
I = float(input('Turbulent intensity:'))
if 'geo' == 'b':
l = 0.04 * D
else:
l = 0.07 * D
TKE = 3./2.*(I*U_b)**2
print("TKE = %10.3e m^2/s^2" %TKE)
omega = TKE**0.5/(0.09)**0.25/l
print("omega = %10.3e 1/s" %omega)
In [ ]: