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.
|
||||
|
14
blflow.py
Normal file → Executable file
14
blflow.py
Normal file → Executable file
@ -46,15 +46,13 @@ def u_np1(un, tn, dt):
|
||||
un0 = np.zeros(n, float)
|
||||
t = 0
|
||||
un = un0
|
||||
# un.append(un0)
|
||||
|
||||
# Make the plot
|
||||
# plt.ioff()
|
||||
f = plt.figure(1, figsize=(12, 6))
|
||||
|
||||
linefd, = 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.xlim(-1.5, 1.5)
|
||||
plt.ylabel('Distance from wall [m]')
|
||||
@ -69,13 +67,13 @@ try:
|
||||
t += dt
|
||||
uold = un
|
||||
un = u_np1(uold, t, dt)
|
||||
if(i % 100 == 0):
|
||||
if(i % 25 == 0):
|
||||
linefd.set_xdata(un)
|
||||
linee.set_xdata(u_ex(t))
|
||||
f.canvas.draw_idle()
|
||||
plt.pause(.00001)
|
||||
if not plt.fignum_exists(1):
|
||||
break
|
||||
plt.pause(.000005)
|
||||
if not plt.fignum_exists(1):
|
||||
break
|
||||
i += 1
|
||||
except Exception:
|
||||
pass
|
||||
|
42
parplateflow.py
Normal file → Executable file
42
parplateflow.py
Normal file → Executable file
@ -41,26 +41,36 @@ def u_np1(un, tn, dt):
|
||||
un0 = zeros(n, float)
|
||||
t = 0
|
||||
un = un0
|
||||
# un.append(un0)
|
||||
|
||||
# Make the plot
|
||||
f = plt.figure(1, figsize=(12, 6))
|
||||
linefd, = 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.xlim(-1.5, 1.5)
|
||||
plt.ylabel('y')
|
||||
plt.xlabel('u')
|
||||
plt.grid('on')
|
||||
plt.ylabel('y [m]')
|
||||
plt.xlabel('Velocity [m/s]')
|
||||
plt.grid(True)
|
||||
plt.show(block=False)
|
||||
i = 0
|
||||
uold = un
|
||||
while(True):
|
||||
t += dt
|
||||
uold = un
|
||||
un = u_np1(uold, t, dt)
|
||||
if(i % 100 == 0):
|
||||
linefd.set_xdata(un)
|
||||
linee.set_xdata(u_ex(t))
|
||||
plt.draw()
|
||||
# print("Time:",t)
|
||||
i += 1
|
||||
|
||||
|
||||
try:
|
||||
while(True):
|
||||
t += dt
|
||||
uold = un
|
||||
un = u_np1(uold, t, dt)
|
||||
if(i % 25 == 0):
|
||||
linefd.set_xdata(un)
|
||||
linee.set_xdata(u_ex(t))
|
||||
f.canvas.draw_idle()
|
||||
plt.pause(.000005)
|
||||
if not plt.fignum_exists(1):
|
||||
break
|
||||
i += 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
exit(0)
|
||||
|
Loading…
Reference in New Issue
Block a user