tadded new plot method, lid driven cavity test wrong - ns2dfd - 2D finite difference Navier Stokes solver for fluid dynamics
(HTM) git clone git://src.adamsgaard.dk/ns2dfd
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit bf5ef45d90b3c9dec5ae699056e61e6b137621f8
(DIR) parent 863e92eefbec760f48edd317013494c76d2972de
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Thu, 6 Mar 2014 16:25:09 +0100
added new plot method, lid driven cavity test wrong
Diffstat:
M lid_driven_cavity.py | 5 ++---
M ns2dfd.py | 47 +++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/lid_driven_cavity.py b/lid_driven_cavity.py
t@@ -8,6 +8,5 @@ sim.reynolds_number(1000)
sim.end_time(20.0)
sim.boundary_conditions(2, 2, 2, 2)
sim.run()
-sim.read(sim.sim_id + '00004.dat')
-print(sim.U)
-sim.writeVTK()
+sim.read(sim.sim_id + '00008.dat')
+sim.plot_PUV()
(DIR) diff --git a/ns2dfd.py b/ns2dfd.py
t@@ -3,6 +3,9 @@
import numpy
import subprocess
import vtk
+import matplotlib
+matplotlib.use('Agg')
+import matplotlib.pyplot as plt
class fluid:
t@@ -341,3 +344,47 @@ class fluid:
if (verbose == True):
print('Output file: {0}'.format(filename))
+ def plot_PUV(self, format = 'png'):
+ plt.figure(figsize=[8,8])
+
+ #ax = plt.subplot(1, 3, 1)
+ plt.title("Pressure")
+ imgplt = plt.imshow(self.P.T, origin='lower')
+ imgplt.set_interpolation('nearest')
+ #imgplt.set_interpolation('bicubic')
+ #imgplt.set_cmap('hot')
+ plt.xlabel('$x$')
+ plt.ylabel('$y$')
+ plt.colorbar()
+
+ # show velocities as arrows
+ Q = plt.quiver(self.U, self.V)
+
+ # show velocities as stream lines
+ #plt.streamplot(numpy.arange(self.nx+2),numpy.arange(self.ny+2),\
+ #self.U, self.V)
+
+ '''
+ # show velocities as heat maps
+ ax = plt.subplot(1, 3, 2)
+ plt.title("U")
+ imgplt = plt.imshow(self.U.T, origin='lower')
+ imgplt.set_interpolation('nearest')
+ #imgplt.set_interpolation('bicubic')
+ #imgplt.set_cmap('hot')
+ plt.xlabel('$x$')
+ plt.ylabel('$y$')
+ plt.colorbar()
+
+ ax = plt.subplot(1, 3, 3)
+ plt.title("V")
+ imgplt = plt.imshow(self.V.T, origin='lower')
+ imgplt.set_interpolation('nearest')
+ #imgplt.set_interpolation('bicubic')
+ #imgplt.set_cmap('hot')
+ plt.xlabel('$x$')
+ plt.ylabel('$y$')
+ plt.colorbar()
+ '''
+
+ plt.savefig(self.sim_id + '-PUV.' + format, transparent=False)