#! /usr/bin/env python # def resid_poiseuille ( nu, rho, n, x, y, t ): #*****************************************************************************80 # ## RESID_POISEUILLE returns Poiseuille residualss. # # Location: # # http://people.sc.fsu.edu/~jburkardt/py_src/navier_stokes_2d_exact/resid_poiseuille.py # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 22 July 2015 # # Author: # # John Burkardt # # Parameters: # # Input, real NU, the kinematic viscosity. # # Input, real RHO, the density. # # Input, integer N, the number of points at which the solution is to # be evaluated. # # Input, real X(N), Y(N), the coordinates of the points. # # Input, real T(N), the time coordinate or coordinates. # # Output, real UR(N), VR(N), PR(N), the residuals in the U, V and P equations. # import numpy as np from rhs_poiseuille import rhs_poiseuille ur = np.zeros ( n ) vr = np.zeros ( n ) pr = np.zeros ( n ) # # Get the right hand side functions. # f, g, h = rhs_poiseuille ( nu, rho, n, x, y, t ); # # Form the functions and derivatives for the left hand side. # u = 1.0 - y ** 2 dudt = 0.0 dudx = 0.0 dudxx = 0.0 dudy = - 2.0 * y dudyy = - 2.0 v = 0.0 dvdt = 0.0 dvdx = 0.0 dvdxx = 0.0 dvdy = 0.0 dvdyy = 0.0 p = - 2.0 * nu * rho * x dpdx = - 2.0 * nu * rho dpdy = 0.0 # # Evaluate the residuals. # ur = dudt - nu * ( dudxx + dudyy ) \ + u * dudx + v * dudy + dpdx / rho - f vr = dvdt - nu * ( dvdxx + dvdyy ) \ + u * dvdx + v * dvdy + dpdy / rho - g pr = dudx + dvdy - h return ur, vr, pr def resid_poiseuille_test ( ): #*****************************************************************************80 # ## RESID_POISEUILLE_TEST samples the Poiseuille residual. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 30 January 2015 # # Author: # # John Burkardt # import numpy as np import platform from r8vec_uniform_ab import r8vec_uniform_ab nu = 1.0 rho = 1.0 print ( '' ) print ( 'RESID_POISEUILLE_TEST' ) print ( ' Python version: %s' % ( platform.python_version ( ) ) ) print ( ' Poiseuille Flow:' ) print ( ' Sample the Navier-Stokes residuals' ) print ( ' at the initial time T = 0, over a channel region.' ) print ( ' Kinematic viscosity NU = %g' % ( nu ) ) print ( ' Fluid density RHO = %g' % ( rho ) ) n = 1000 x_lo = 0.0 x_hi = 6.0 y_lo = -1.0 y_hi = +1.0 seed = 123456789 x, seed = r8vec_uniform_ab ( n, x_lo, x_hi, seed ) y, seed = r8vec_uniform_ab ( n, y_lo, y_hi, seed ) t = 0.0 ur, vr, pr = resid_poiseuille ( nu, rho, n, x, y, t ) print ( '' ) print ( ' Minimum Maximum' ) print ( '' ) print ( ' Ur: %14.6g %14.6g' % ( np.min ( np.abs ( ur ) ), np.max ( np.abs ( ur ) ) ) ) print ( ' Vr: %14.6g %14.6g' % ( np.min ( np.abs ( vr ) ), np.max ( np.abs ( vr ) ) ) ) print ( ' Pr: %14.6g %14.6g' % ( np.min ( np.abs ( pr ) ), np.max ( np.abs ( pr ) ) ) ) # # Terminate. # print ( '' ) print ( 'RESID_POISEUILLE_TEST:' ) print ( ' Normal end of execution.' ) return if ( __name__ == '__main__' ): from timestamp import timestamp timestamp ( ) resid_poiseuille_test ( ) timestamp ( )