tadded missing self params - 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 fd992e44cc3ef9a8a55b0f36db39d5e76eb798b5
(DIR) parent d7c14c02d398035d751b2d5e7dee8896b9c53437
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Sun, 2 Mar 2014 10:13:59 +0100
added missing self params
Diffstat:
M ns2dfd.py | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
---
(DIR) diff --git a/ns2dfd.py b/ns2dfd.py
t@@ -4,7 +4,7 @@ import numpy
class fluid:
- def __init__(name = 'unnamed'):
+ def __init__(self, name = 'unnamed'):
'''
A Navier-Stokes two-dimensional fluid flow simulation object. Most
simulation values are assigned default values upon initialization.
t@@ -25,7 +25,7 @@ class fluid:
reynolds_number()
gravity()
- def init_grid(nx = 10, ny = 10, dx = 0.1, dy = 0.1):
+ def init_grid(self, nx = 10, ny = 10, dx = 0.1, dy = 0.1):
'''
Initializes the numerical grid.
:param nx: Fluid grid width in number of cells
t@@ -45,7 +45,7 @@ class fluid:
self.u = numpy.zeros((nx+2, ny+2))
self.v = numpy.zeros((nx+2, ny+2))
- def current_time(t = 0.0):
+ def current_time(self, t = 0.0):
'''
Set the current simulation time. Default value = 0.0.
:param t: The current time value.
t@@ -53,7 +53,7 @@ class fluid:
'''
self.t_end = numpy.asarray(t)
- def end_time(t_end = 1.0):
+ def end_time(self, t_end = 1.0):
'''
Set the simulation end time.
:param t_end: The time when to stop the simulation.
t@@ -61,7 +61,7 @@ class fluid:
'''
self.t_end = numpy.asarray(t_end)
- def safety_factor(tau = 0.5):
+ def safety_factor(self, tau = 0.5):
'''
Define the safety factor for the time step size control. Default value =
0.5.
t@@ -70,7 +70,7 @@ class fluid:
'''
self.tau = numpy.asarray(tau)
- def max_iterations(itermax = 5000):
+ def max_iterations(self, itermax = 5000):
'''
Set the maximal allowed iterations per time step. Default value = 5000.
:param itermax: Max. solution iterations in [1;inf[
t@@ -78,7 +78,7 @@ class fluid:
'''
self.itermax = numpy.asarray(itermax)
- def tolerance_criteria(epsilon = 1.0e-4):
+ def tolerance_criteria(self, epsilon = 1.0e-4):
'''
Set the tolerance criteria for the fluid solver. Default value = 1.0e-4.
:param epsilon: Criteria value
t@@ -86,7 +86,7 @@ class fluid:
'''
self.epsilon = numpy.asarray(epsilon)
- def relaxation_parameter(omega = 1.7):
+ def relaxation_parameter(self, omega = 1.7):
'''
Set the relaxation parameter for the successive overrelaxation (SOR)
solver. The solver is identical to the Gauss-Seidel method when omega =
t@@ -96,7 +96,7 @@ class fluid:
'''
self.omega = numpy.asarray(omega)
- def upwind_differencing_factor(gamma = 0.9):
+ def upwind_differencing_factor(self, gamma = 0.9):
'''
Set the upwind diffencing factor used in the finite difference
approximations. Default value = 0.9.
t@@ -105,7 +105,7 @@ class fluid:
'''
self.gamma = numpy.asarray(gamma)
- def boundary_conditions(left = 1, right = 1, top = 1, bottom = 1):
+ def boundary_conditions(self, left = 1, right = 1, top = 1, bottom = 1):
'''
Set the wall boundary conditions. The values correspond to the following
conditions: 1) free-slip, 2) no-slip, 3) outflow, 4) periodic
t@@ -117,7 +117,7 @@ class fluid:
self.w_top = numpy.asarray(top)
self.w_bottom = numpy.asarray(bottom)
- def reynolds_number(re = 100):
+ def reynolds_number(self, re = 100):
'''
Define the simulation Reynolds number.
:param re: Reynolds number in ]0;infty[
t@@ -125,7 +125,7 @@ class fluid:
'''
self.re = numpy.asarray(re)
- def gravity(gx = 0.0, gy = 0.0):
+ def gravity(self, gx = 0.0, gy = 0.0):
'''
Set the gravitational acceleration on the fluid.
:param gx: Horizontal gravitational acceleration.
t@@ -137,7 +137,7 @@ class fluid:
self.gx = numpy.asarray(gx)
self.gy = numpy.asarray(gy)
- def read(path, verbose = True):
+ def read(self, path, verbose = True):
'''
Read data file from disk.
:param path: Path to data file
t@@ -193,7 +193,7 @@ class fluid:
if fh is not None:
fh.close()
- def write(verbose = True, folder = './'):
+ def write(self, verbose = True, folder = './'):
'''
Write the simulation parameters to disk so that the fluid flow solver
can read it.
t@@ -243,4 +243,3 @@ class fluid:
finally:
if fh is not None:
fh.close()
-