Updated files to work correctly.
This commit is contained in:
parent
f0ec52f51f
commit
73493854ef
@ -1 +1,6 @@
|
|||||||
Solve the boundary layer velocity profile using a finite difference method. Directly animate the result.
|
# Blflow
|
||||||
|
|
||||||
|
This code solves the boundary layer velocity profile that occurs due to an
|
||||||
|
acoustic wave in the vicinity of a wall. In a small layer (the viscous boundary
|
||||||
|
layer thickness ($\delta_\nu$)), the presence of the wall affects the velocity
|
||||||
|
field which would otherwise be a "plug" flow.
|
||||||
|
10
blflow.py
Normal file → Executable file
10
blflow.py
Normal file → Executable file
@ -46,15 +46,13 @@ def u_np1(un, tn, dt):
|
|||||||
un0 = np.zeros(n, float)
|
un0 = np.zeros(n, float)
|
||||||
t = 0
|
t = 0
|
||||||
un = un0
|
un = un0
|
||||||
# un.append(un0)
|
|
||||||
|
|
||||||
# Make the plot
|
|
||||||
# plt.ioff()
|
|
||||||
f = plt.figure(1, figsize=(12, 6))
|
f = plt.figure(1, figsize=(12, 6))
|
||||||
|
|
||||||
linefd, = plt.plot(un0, y)
|
linefd, = plt.plot(un0, y)
|
||||||
linee, = plt.plot(un0, y)
|
linee, = plt.plot(un0, y)
|
||||||
plt.legend(('Finite difference', 'Periodic exact'))
|
plt.legend(('Finite difference', 'Periodic exact'),
|
||||||
|
loc='lower right')
|
||||||
plt.ylim(0, 1)
|
plt.ylim(0, 1)
|
||||||
plt.xlim(-1.5, 1.5)
|
plt.xlim(-1.5, 1.5)
|
||||||
plt.ylabel('Distance from wall [m]')
|
plt.ylabel('Distance from wall [m]')
|
||||||
@ -69,11 +67,11 @@ try:
|
|||||||
t += dt
|
t += dt
|
||||||
uold = un
|
uold = un
|
||||||
un = u_np1(uold, t, dt)
|
un = u_np1(uold, t, dt)
|
||||||
if(i % 100 == 0):
|
if(i % 25 == 0):
|
||||||
linefd.set_xdata(un)
|
linefd.set_xdata(un)
|
||||||
linee.set_xdata(u_ex(t))
|
linee.set_xdata(u_ex(t))
|
||||||
f.canvas.draw_idle()
|
f.canvas.draw_idle()
|
||||||
plt.pause(.00001)
|
plt.pause(.000005)
|
||||||
if not plt.fignum_exists(1):
|
if not plt.fignum_exists(1):
|
||||||
break
|
break
|
||||||
i += 1
|
i += 1
|
||||||
|
30
parplateflow.py
Normal file → Executable file
30
parplateflow.py
Normal file → Executable file
@ -41,26 +41,36 @@ def u_np1(un, tn, dt):
|
|||||||
un0 = zeros(n, float)
|
un0 = zeros(n, float)
|
||||||
t = 0
|
t = 0
|
||||||
un = un0
|
un = un0
|
||||||
# un.append(un0)
|
|
||||||
|
|
||||||
# Make the plot
|
f = plt.figure(1, figsize=(12, 6))
|
||||||
linefd, = plt.plot(un0, y)
|
linefd, = plt.plot(un0, y)
|
||||||
linee, = plt.plot(un0, y)
|
linee, = plt.plot(un0, y)
|
||||||
plt.legend(('Finite difference', 'Periodic exact'))
|
plt.legend(('Finite difference', 'Periodic exact'),
|
||||||
|
loc='lower right')
|
||||||
plt.ylim(-1, 1)
|
plt.ylim(-1, 1)
|
||||||
plt.xlim(-1.5, 1.5)
|
plt.xlim(-1.5, 1.5)
|
||||||
plt.ylabel('y')
|
plt.ylabel('y [m]')
|
||||||
plt.xlabel('u')
|
plt.xlabel('Velocity [m/s]')
|
||||||
plt.grid('on')
|
plt.grid(True)
|
||||||
|
plt.show(block=False)
|
||||||
i = 0
|
i = 0
|
||||||
uold = un
|
uold = un
|
||||||
while(True):
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
while(True):
|
||||||
t += dt
|
t += dt
|
||||||
uold = un
|
uold = un
|
||||||
un = u_np1(uold, t, dt)
|
un = u_np1(uold, t, dt)
|
||||||
if(i % 100 == 0):
|
if(i % 25 == 0):
|
||||||
linefd.set_xdata(un)
|
linefd.set_xdata(un)
|
||||||
linee.set_xdata(u_ex(t))
|
linee.set_xdata(u_ex(t))
|
||||||
plt.draw()
|
f.canvas.draw_idle()
|
||||||
# print("Time:",t)
|
plt.pause(.000005)
|
||||||
|
if not plt.fignum_exists(1):
|
||||||
|
break
|
||||||
i += 1
|
i += 1
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user