From 73493854efff0f785a39593ecc0cf641be63264b Mon Sep 17 00:00:00 2001 From: "J.A. de Jong - ASCEE" Date: Sun, 16 Dec 2018 13:40:05 +0100 Subject: [PATCH] Updated files to work correctly. --- README.md | 7 ++++++- blflow.py | 14 ++++++-------- parplateflow.py | 42 ++++++++++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 25 deletions(-) mode change 100644 => 100755 blflow.py mode change 100644 => 100755 parplateflow.py diff --git a/README.md b/README.md index 751ecf7..e77301c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/blflow.py b/blflow.py old mode 100644 new mode 100755 index 5cdb65f..8b58365 --- a/blflow.py +++ b/blflow.py @@ -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 diff --git a/parplateflow.py b/parplateflow.py old mode 100644 new mode 100755 index d2c1b94..9642c8b --- a/parplateflow.py +++ b/parplateflow.py @@ -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)