The next assignment was to rewrite the sliding plates using an implicit scheme. Here is a video of the animation produced using Visual Python arrows.
Colored according to speed. The initial velocity of the fluid is zero and the upper plate moves at a constant speed.
The visualization setup using Visual Python looks like this:
#SET UP VISUALIZATION SCENE
scene = display(title='Velocity profile', width=800, height=800, center=(u/2,y_divs/2,0),
autoscale=True, fullscreen=False)
base = box(pos=(u/2,-0.5,-2), length=u, height=0.4, width=4)
plate = box(pos=(u/2,y_divs+1.5,-2), length=u, height=0.4, width=4)
quiver = [] #TO HOLD ALL THE VELOCITY VECTOR ARROWS
quiver.append( arrow(pos=(0,0,0), axis=(BOUNDS[0,0],0,0),
shaftwidth=0.5, color=color.blue) )
for each in xrange(y_divs):
quiver.append( arrow(pos=(0,each+1,0), axis=(UM[each,0],0,0),
shaftwidth=0.5, color=color.blue) )
quiver.append( arrow(pos=(0,y_divs+1,0), axis=(BOUNDS[-1,0],0,0),
shaftwidth=0.5, color=color.red) )
scene.autoscale = False
The main loop with the visualization update looks like this:
for t in arange(t_divs-1): #START FROM 1, SKIP ZERO
B = zeros(y_divs)
B[:] = -1 * UM[:,t]
B[ 0] -= BOUNDS[ 0,t+1] * alpha
B[-1] -= BOUNDS[-1,t+1] * alpha
UMnext = linalg.solve( A, B )
UM[:,t+1] = UMnext[:]
for y in arange(y_divs):
#UPDATE VECTOR LENGTH BASED ON SPEED
quiver[y+1].axis = (UM[y,t+1],0,0)
#CHANGE ARROW COLOR BASED ON SPEED: Blue is slow, Red is fast
quiver[y+1].color = (UM[y,t+1]/u,0.3,1.-UM[y,t+1]/u)