Lid driven Cavity (GPU)

The following command is important to view matplotlib plots on a jupyter notebook


In [2]:
%matplotlib notebook

In [3]:
import matplotlib.pyplot as plt

In [4]:
from mpl_toolkits.mplot3d import Axes3D

In [5]:
import os, sys

In [6]:
from matplotlib.mlab import griddata

In [7]:
import numpy as np

In [8]:
os.getcwd() # current directory


Out[8]:
'/home/topolo/PropD/CUDACFD_out/NavSt2DIncompFiniteDiff'

In [22]:
os.listdir( os.getcwd() )


Out[22]:
['main.cu',
 'commonlib',
 'main_draft02.cu',
 'NavSt2DIncompFiniteDiff_out.ipynb',
 'main_draft00.cu',
 'main_draft03.cu',
 '.ipynb_checkpoints',
 'boundary.o',
 'main.exe',
 'main.o',
 'velocity_gput014.dat',
 'Makefile',
 'physlib',
 'R2grid.o',
 'velocity_gput024.dat',
 'velocity_gpu.dat',
 'main_draft01.cu',
 'u_p.o',
 'dev_R2grid.o']

In [10]:
import pandas as pd

In [11]:
u_data = pd.read_table( 'velocity_gpu.dat')  # t=1.4 or time=1.4

In [12]:
u_data.columns


Out[12]:
Index([u'#x', u'y', u'u', u'v'], dtype='object')

In [13]:
u_data.size


Out[13]:
1052676

In [14]:
u_data.head()


Out[14]:
#x y u v
0 0.000000 0.0 0.000000e+00 0.0
1 0.001953 0.0 -3.888510e-08 0.0
2 0.003906 0.0 -2.278310e-07 0.0
3 0.005859 0.0 -4.785980e-07 0.0
4 0.007812 0.0 -7.602580e-07 0.0

In [15]:
u_data.describe()


Out[15]:
#x y u v
count 263169.000000 263169.000000 2.631690e+05 263169.000000
mean 0.500000 0.500000 1.987921e-07 -0.000008
std 0.289239 0.289239 1.306252e-01 0.065207
min 0.000000 0.000000 -3.004170e-01 -0.668315
25% 0.250000 0.250000 -3.652550e-02 -0.004122
50% 0.500000 0.500000 -1.585410e-02 0.004196
75% 0.750000 0.750000 -5.205830e-03 0.023045
max 1.000000 1.000000 9.849440e-01 0.272820

In [16]:
xi = np.linspace(0.0, 1.0, 512)
yi = np.linspace(0.0, 1.0, 512)

In [17]:
zi = griddata( u_data.iloc[:,0], u_data.iloc[:,1], u_data.iloc[:,2], xi, yi,interp='linear') # t=1.4 or time = 1.4, 
# u velocity component or x-component of velocity

In [20]:
plt.contour( xi,yi,zi, 1000, cmap=plt.cm.rainbow, vmax=abs(zi).max(), vmin=-abs(zi).max() )
plt.colorbar()


Out[20]:
<matplotlib.colorbar.Colorbar at 0x7f690eae7790>

After $t=1.4$, i.e. time$ =1.4$


In [37]:
figure014 = plt.figure()
ax014     = figure014.add_subplot(121) # 2x1 grid, 1st subplot



In [26]:
u_datat014 = pd.read_table( 'velocity_gput014.dat')  # t=1.4 or time=1.4

In [28]:
u_t014i = griddata( u_datat014.iloc[:,0], u_datat014.iloc[:,1], u_datat014.iloc[:,2], xi, yi,interp='linear') # t=1.4 or time = 1.4, 
# u velocity component or x-component of velocity

In [29]:
v_t014i = griddata( u_datat014.iloc[:,0], u_datat014.iloc[:,1], u_datat014.iloc[:,3], xi, yi,interp='linear') # t=1.4 or time = 1.4, 
# v velocity component or y-component of velocity

In [43]:
ax014.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=1.4$ time evolution")


Out[43]:
<matplotlib.text.Text at 0x7f6906851f10>

In [39]:
plt.contour( xi,yi,u_t014i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t014i).max(), vmin=-abs(u_t014i).max() )
plt.colorbar()


Out[39]:
<matplotlib.colorbar.Colorbar at 0x7f6905a3bb50>

In [42]:
ax014v    = figure014.add_subplot(122) # 2x1 grid, 2nd subplot
ax014v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=1.4$ time evolution")


Out[42]:
<matplotlib.text.Text at 0x7f6905915f90>

In [41]:
plt.contour( xi,yi,v_t014i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t014i).max(), vmin=-abs(v_t014i).max() )
plt.colorbar()


Out[41]:
<matplotlib.colorbar.Colorbar at 0x7f690494c990>

In [66]:
figure014_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=1.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t014i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t014i).max(), vmin=-abs(u_t014i).max() )
plt.colorbar()


Out[66]:
<matplotlib.colorbar.Colorbar at 0x7f68fd715d10>

After $t=2.4$, i.e. time$ =2.4$


In [45]:
figure024 = plt.figure()
ax024     = figure024.add_subplot(121) # 2x1 grid, 1st subplot



In [46]:
u_datat024 = pd.read_table( 'velocity_gput024.dat')  # t=2.4 or time=2.4

In [47]:
u_t024i = griddata( u_datat024.iloc[:,0], u_datat024.iloc[:,1], u_datat024.iloc[:,2], xi, yi,interp='linear') # t=2.4 or time = 2.4, 
# u velocity component or x-component of velocity

In [48]:
v_t024i = griddata( u_datat024.iloc[:,0], u_datat024.iloc[:,1], u_datat024.iloc[:,3], xi, yi,interp='linear') # t=2.4 or time = 2.4, 
# v velocity component or y-component of velocity

In [49]:
ax024.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=2.4$ time evolution")


Out[49]:
<matplotlib.text.Text at 0x7f690483b490>

In [50]:
plt.contour( xi,yi,u_t024i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t024i).max(), vmin=-abs(u_t024i).max() )
plt.colorbar()


Out[50]:
<matplotlib.colorbar.Colorbar at 0x7f69039449d0>

In [51]:
ax024v    = figure024.add_subplot(122) # 2x1 grid, 2nd subplot
ax024v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=2.4$ time evolution")


Out[51]:
<matplotlib.text.Text at 0x7f69038499d0>

In [52]:
plt.contour( xi,yi,v_t024i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t024i).max(), vmin=-abs(v_t024i).max() )
plt.colorbar()


Out[52]:
<matplotlib.colorbar.Colorbar at 0x7f69028d4d50>

In [67]:
figure024_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=2.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t024i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t024i).max(), vmin=-abs(u_t024i).max() )
plt.colorbar()


Out[67]:
<matplotlib.colorbar.Colorbar at 0x7f68fc76a390>

After $t=3.4$, i.e. time$ =3.4$


In [60]:
figure034 = plt.figure()
ax034     = figure034.add_subplot(121) # 2x1 grid, 1st subplot



In [59]:
u_datat034 = pd.read_table( 'velocity_gput034.dat')  # t=3.4 or time=3.4
u_t034i = griddata( u_datat034.iloc[:,0], u_datat034.iloc[:,1], u_datat034.iloc[:,2], xi, yi,interp='linear') # t=3.4 or time = 3.4, 
# u velocity component or x-component of velocity
v_t034i = griddata( u_datat034.iloc[:,0], u_datat034.iloc[:,1], u_datat034.iloc[:,3], xi, yi,interp='linear') # t=3.4 or time = 3.4, 
# v velocity component or y-component of velocity

In [61]:
ax034.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=3.4$ time evolution")


Out[61]:
<matplotlib.text.Text at 0x7f690077c1d0>

In [62]:
plt.contour( xi,yi,u_t034i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t034i).max(), vmin=-abs(u_t034i).max() )
plt.colorbar()


Out[62]:
<matplotlib.colorbar.Colorbar at 0x7f68ff8abfd0>

In [63]:
ax034v    = figure034.add_subplot(122) # 2x1 grid, 2nd subplot
ax034v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=3.4$ time evolution")


Out[63]:
<matplotlib.text.Text at 0x7f68ff7aa550>

In [64]:
plt.contour( xi,yi,v_t034i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t034i).max(), vmin=-abs(v_t034i).max() )
plt.colorbar()


Out[64]:
<matplotlib.colorbar.Colorbar at 0x7f68fe7ff150>

In [68]:
figure034_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=3.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t034i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t034i).max(), vmin=-abs(u_t034i).max() )
plt.colorbar()


Out[68]:
<matplotlib.colorbar.Colorbar at 0x7f68fb78dc10>

After $t=4.4$, i.e. time$ =4.4$


In [69]:
figure044 = plt.figure()
ax044     = figure044.add_subplot(121) # 2x1 grid, 1st subplot



In [70]:
u_datat044 = pd.read_table( 'velocity_gput044.dat')  # t=4.4 or time=4.4
u_t044i = griddata( u_datat044.iloc[:,0], u_datat044.iloc[:,1], u_datat044.iloc[:,2], xi, yi,interp='linear') # t=4.4 or time = 4.4, 
# u velocity component or x-component of velocity
v_t044i = griddata( u_datat044.iloc[:,0], u_datat044.iloc[:,1], u_datat044.iloc[:,3], xi, yi,interp='linear') # t=4.4 or time = 4.4, 
# v velocity component or y-component of velocity

In [71]:
ax044.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=4.4$ time evolution")


Out[71]:
<matplotlib.text.Text at 0x7f68fb657a50>

In [72]:
plt.contour( xi,yi,u_t044i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t044i).max(), vmin=-abs(u_t044i).max() )
plt.colorbar()


Out[72]:
<matplotlib.colorbar.Colorbar at 0x7f68fa8301d0>

In [73]:
ax044v    = figure044.add_subplot(122) # 2x1 grid, 2nd subplot
ax044v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=4.4$ time evolution")


Out[73]:
<matplotlib.text.Text at 0x7f68fa684e50>

In [74]:
plt.contour( xi,yi,v_t044i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t044i).max(), vmin=-abs(v_t044i).max() )
plt.colorbar()


Out[74]:
<matplotlib.colorbar.Colorbar at 0x7f68f97a4510>

In [75]:
figure044_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=4.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t044i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t044i).max(), vmin=-abs(u_t044i).max() )
plt.colorbar()


Out[75]:
<matplotlib.colorbar.Colorbar at 0x7f68f87a8510>

After $t=5.4$, i.e. time$ =5.4$


In [76]:
figure054 = plt.figure()
ax054     = figure054.add_subplot(121) # 2x1 grid, 1st subplot



In [77]:
u_datat054 = pd.read_table( 'velocity_gput054.dat')  # t=5.4 or time=5.4
u_t054i = griddata( u_datat054.iloc[:,0], u_datat054.iloc[:,1], u_datat054.iloc[:,2], xi, yi,interp='linear') # t=5.4 or time = 5.4, 
# u velocity component or x-component of velocity
v_t054i = griddata( u_datat054.iloc[:,0], u_datat054.iloc[:,1], u_datat054.iloc[:,3], xi, yi,interp='linear') # t=5.4 or time = 5.4, 
# v velocity component or y-component of velocity

In [78]:
ax054.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=5.4$ time evolution")


Out[78]:
<matplotlib.text.Text at 0x7f68f8671b50>

In [79]:
plt.contour( xi,yi,u_t054i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t054i).max(), vmin=-abs(u_t054i).max() )
plt.colorbar()


Out[79]:
<matplotlib.colorbar.Colorbar at 0x7f68f7790a50>

In [80]:
ax054v    = figure054.add_subplot(122) # 2x1 grid, 2nd subplot
ax054v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=5.4$ time evolution")


Out[80]:
<matplotlib.text.Text at 0x7f68f7692710>

In [81]:
plt.contour( xi,yi,v_t054i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t054i).max(), vmin=-abs(v_t054i).max() )
plt.colorbar()


Out[81]:
<matplotlib.colorbar.Colorbar at 0x7f68f66d5310>

In [82]:
figure054_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=5.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t054i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t054i).max(), vmin=-abs(u_t054i).max() )
plt.colorbar()


Out[82]:
<matplotlib.colorbar.Colorbar at 0x7f68f575a790>

After $t=6.4$, i.e. time$ =6.4$


In [83]:
figure064 = plt.figure()
ax064     = figure064.add_subplot(121) # 2x1 grid, 1st subplot



In [84]:
u_datat064 = pd.read_table( 'velocity_gput064.dat')  # t=6.4 or time=6.4
u_t064i = griddata( u_datat064.iloc[:,0], u_datat064.iloc[:,1], u_datat064.iloc[:,2], xi, yi,interp='linear') # t=6.4 or time = 6.4, 
# u velocity component or x-component of velocity
v_t064i = griddata( u_datat064.iloc[:,0], u_datat064.iloc[:,1], u_datat064.iloc[:,3], xi, yi,interp='linear') # t=6.4 or time = 6.4, 
# v velocity component or y-component of velocity

In [85]:
ax064.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=6.4$ time evolution")


Out[85]:
<matplotlib.text.Text at 0x7f68f57e4c10>

In [86]:
plt.contour( xi,yi,u_t064i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t064i).max(), vmin=-abs(u_t064i).max() )
plt.colorbar()


Out[86]:
<matplotlib.colorbar.Colorbar at 0x7f68f47ebe50>

In [87]:
ax064v    = figure064.add_subplot(122) # 2x1 grid, 2nd subplot
ax064v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=6.4$ time evolution")


Out[87]:
<matplotlib.text.Text at 0x7f68f46fd310>

In [88]:
plt.contour( xi,yi,v_t064i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t064i).max(), vmin=-abs(v_t064i).max() )
plt.colorbar()


Out[88]:
<matplotlib.colorbar.Colorbar at 0x7f68f36c0590>

In [89]:
figure064_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=6.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t064i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t064i).max(), vmin=-abs(u_t064i).max() )
plt.colorbar()


Out[89]:
<matplotlib.colorbar.Colorbar at 0x7f68f27480d0>

After $t=7.4$, i.e. time$ =7.4$


In [90]:
figure074 = plt.figure()
ax074     = figure074.add_subplot(121) # 2x1 grid, 1st subplot



In [91]:
u_datat074 = pd.read_table( 'velocity_gput074.dat')  # t=7.4 or time=7.4
u_t074i = griddata( u_datat074.iloc[:,0], u_datat074.iloc[:,1], u_datat074.iloc[:,2], xi, yi,interp='linear') # t=7.4 or time = 7.4, 
# u velocity component or x-component of velocity
v_t074i = griddata( u_datat074.iloc[:,0], u_datat074.iloc[:,1], u_datat074.iloc[:,3], xi, yi,interp='linear') # t=7.4 or time = 7.4, 
# v velocity component or y-component of velocity

In [92]:
ax074.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=7.4$ time evolution")


Out[92]:
<matplotlib.text.Text at 0x7f68f267ac90>

In [93]:
plt.contour( xi,yi,u_t074i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t074i).max(), vmin=-abs(u_t074i).max() )
plt.colorbar()


Out[93]:
<matplotlib.colorbar.Colorbar at 0x7f68f17974d0>

In [94]:
ax074v    = figure074.add_subplot(122) # 2x1 grid, 2nd subplot
ax074v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=7.4$ time evolution")


Out[94]:
<matplotlib.text.Text at 0x7f68f168ac10>

In [95]:
plt.contour( xi,yi,v_t074i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t074i).max(), vmin=-abs(v_t074i).max() )
plt.colorbar()


Out[95]:
<matplotlib.colorbar.Colorbar at 0x7f68f06db3d0>

In [96]:
figure074_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=7.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t074i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t074i).max(), vmin=-abs(u_t074i).max() )
plt.colorbar()


Out[96]:
<matplotlib.colorbar.Colorbar at 0x7f68ef782310>

After $t=8.4$, i.e. time$ =8.4$


In [97]:
figure084 = plt.figure()
ax084     = figure084.add_subplot(121) # 2x1 grid, 1st subplot



In [98]:
u_datat084 = pd.read_table( 'velocity_gput084.dat')  # t=8.4 or time=8.4
u_t084i = griddata( u_datat084.iloc[:,0], u_datat084.iloc[:,1], u_datat084.iloc[:,2], xi, yi,interp='linear') # t=8.4 or time = 8.4, 
# u velocity component or x-component of velocity
v_t084i = griddata( u_datat084.iloc[:,0], u_datat084.iloc[:,1], u_datat084.iloc[:,3], xi, yi,interp='linear') # t=8.4 or time = 8.4, 
# v velocity component or y-component of velocity

In [99]:
ax084.set_title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=8.4$ time evolution")


Out[99]:
<matplotlib.text.Text at 0x7f68ef673050>

In [100]:
plt.contour( xi,yi,u_t084i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t084i).max(), vmin=-abs(u_t084i).max() )
plt.colorbar()


Out[100]:
<matplotlib.colorbar.Colorbar at 0x7f68ee7fee90>

In [101]:
ax084v    = figure084.add_subplot(122) # 2x1 grid, 2nd subplot
ax084v.set_title("$v$ or $y$-component of velocity field, \n $Re = 1000$, $t=8.4$ time evolution")


Out[101]:
<matplotlib.text.Text at 0x7f68ee6d93d0>

In [102]:
plt.contour( xi,yi,v_t084i, 1000, cmap=plt.cm.rainbow, vmax=abs(v_t084i).max(), vmin=-abs(v_t084i).max() )
plt.colorbar()


Out[102]:
<matplotlib.colorbar.Colorbar at 0x7f68ed6d5350>

In [103]:
figure084_u_only = plt.figure()
plt.title("$u$ or $x$-component of velocity field, \n $Re = 1000$, $t=8.4$ time evolution")
plt.xlabel('x')
plt.ylabel('y')
plt.contour( xi,yi,u_t084i, 1000, cmap=plt.cm.rainbow, vmax=abs(u_t084i).max(), vmin=-abs(u_t084i).max() )
plt.colorbar()


Out[103]:
<matplotlib.colorbar.Colorbar at 0x7f68ec76a190>

In [ ]: