tClass with all relevant parameters. Needs IO - 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 02907fc07a66c16364379dbf5d92550083ce0730
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Sat,  1 Mar 2014 17:25:56 +0100
       
       Class with all relevant parameters. Needs IO
       
       Diffstat:
         A ns2dfd.py                           |     137 +++++++++++++++++++++++++++++++
       
       1 file changed, 137 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/ns2dfd.py b/ns2dfd.py
       t@@ -0,0 +1,137 @@
       +#!/usr/bin/env python
       +
       +import numpy
       +
       +class fluid:
       +
       +    def __init__(sim = 'unnamed'):
       +        '''
       +        A Navier-Stokes two-dimensional fluid flow simulation object. Most
       +        simulation values are assigned default values upon initialization.
       +        :param sim: Simulation identifier
       +        :type sim: str
       +        '''
       +        self.sim = sim
       +
       +        init_grid()
       +        current_time()
       +        safety_factor()
       +        max_iterations()
       +        tolerance_criteria()
       +        relaxation_parameter()
       +        upwind_differencing_factor()
       +        boundary_conditions()
       +        reynolds_number()
       +        gravity()
       +
       +    def init_grid(nx = 10, ny = 10, dx = 0.1, dy = 0.1):
       +        '''
       +        Initializes the numerical grid.
       +        :param nx: Fluid grid width in number of cells
       +        :type nx: int
       +        :param ny: Fluid grid height in number of cells
       +        :type ny: int
       +        :param dx: Grid cell width (meters)
       +        :type dx: float
       +        :param dy: Grid cell height (meters)
       +        :type dy: float
       +        '''
       +        self.nx, self.ny = nx, ny
       +        self.dx, self.dy = dx, dy
       +        self.u = numpy.zeros((nx+2, ny+2))
       +        self.v = numpy.zeros((nx+2, ny+2))
       +        self.p = numpy.zeros((nx+1, ny+1))
       +
       +    def current_time(t = 0.0):
       +        '''
       +        Set the current simulation time. Default value = 0.0.
       +        :param t: The current time value.
       +        :type t: float
       +        '''
       +        self.t_end = t_end
       +
       +
       +    def end_time(t_end):
       +        '''
       +        Set the simulation end time.
       +        :param t_end: The time when to stop the simulation.
       +        :type t_end: float
       +        '''
       +        self.t_end = t_end
       +
       +    def safety_factor(tau = 0.5):
       +        '''
       +        Define the safety factor for the time step size control. Default value =
       +        0.5.
       +        :param tau: Safety factor in ]0;1]
       +        :type tau: float
       +        '''
       +        self.tau = tau
       +        
       +    def max_iterations(itermax = 5000):
       +        '''
       +        Set the maximal allowed iterations per time step. Default value = 5000.
       +        :param itermax: Max. solution iterations in [1;inf[
       +        :type itermax: int
       +        '''
       +        self.itermax = itermax
       +
       +    def tolerance_criteria(epsilon = 1.0e-4):
       +        '''
       +        Set the tolerance criteria for the fluid solver. Default value = 1.0e-4.
       +        :param epsilon: Criteria value
       +        :type epsilon: float
       +        '''
       +        self.epsilon = epsilon
       +
       +    def relaxation_parameter(omega = 1.7):
       +        '''
       +        Set the relaxation parameter for the successive overrelaxation (SOR)
       +        solver. The solver is identical to the Gauss-Seidel method when omega =
       +        1. Default value = 1.7.
       +        :param omega: Relaxation parameter value, in ]0;2[
       +        :type omega: float
       +        '''
       +        self.omega = omega
       +
       +    def upwind_differencing_factor(gamma = 0.9):
       +        '''
       +        Set the upwind diffencing factor used in the finite difference
       +        approximations. Default value = 0.9.
       +        :param gamma: Upward differencing factor value, in ]0;1[
       +        :type gamma: float
       +        '''
       +        self.gamma = gamma
       +
       +    def boundary_conditions(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
       +        :param left, right, top, bottom: The wall to specify the BC for
       +        :type left, right, top, bottom: int
       +        '''
       +        self.w_left = left
       +        self.w_right = right
       +        self.w_top = top
       +        self.w_bottom = bottom
       +
       +    def reynolds_number(re = 100):
       +        '''
       +        Define the simulation Reynolds number.
       +        :param re: Reynolds number in ]0;infty[
       +        :type re: float
       +        '''
       +        self.re = re
       +
       +    def gravity(gx = 0.0, gy = 0.0):
       +        '''
       +        Set the gravitational acceleration on the fluid.
       +        :param gx: Horizontal gravitational acceleration.
       +        :type gx: float
       +        :param gy: Vertical gravitational acceleration. Negative values are
       +            downward.
       +        :type gy: float
       +        '''
       +        self.gx, self.gy = gx, gy
       +
       +