⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 three_point_upwind_uni_d1.m

📁 有关the method of line即MOL算法的matlab代码
💻 M
字号:
      function [D]=three_point_upwind_uni_D1(z0,zL,n,v)
%...
%...  A. Vande Wouwer, P. Saucez and W.E. Schiesser (2002)
%...
%...  function three_point_upwind_uni_D1 returns the differentiation matrix 
%...  for computing the first derivative, xz, of a variable x over the spatial 
%...  domain z0 < z < zL from upwind three-point, first-order finite difference 
%...  approximations (this function replaces dss014)
%...
%...  argument list
%...
%...     z0      lower boundary value of z (input)
%...
%...     zL      upper boundary value of z (input)
%...
%...     n       number of grid points in the z domain including the
%...             boundary points (input)
%...
%...     v       fluid velocity (positive from left to right - only the sign is used) (input)
%...
%...  origin of the approximation
%...
%...  this function is an application of second-order directional
%...  differencing in the numerical method of lines. It is intended
%...  specifically for the analysis of convective systems modelled by
%...  first-order hyperbolic partial differential equations as dis-
%...  cussed in the two_point function. The coefficients of the finite
%...  difference approximations used herein are taken from Bickley, W.
%...  G., Formulae for numerical differentiation, The Mathematical
%...  Gazette, pp. 19-27, 1941, n = 2, m = 1, p = 0, 1, 2.
%...
%...  compute the spatial increment
      dz=(zL-z0)/(n-1);
      r2fdz=1/(2*dz);
%...
%...     (1)  finite difference approximation for positive v     
              if v > 0
%...
%...             sparse discretization matrix      
%...
%...             interior points      
                 D=diag(+1*ones(n-2,1),-2)+diag(-4*ones(n-1,1),-1)+diag(+3*ones(n,1),0);      
%...
%...             boundary points      
                 D(1,1:3) = [-3 +4 -1];
                 D(2,1:3) = [-1  0 +1];
              end;
%...
%...     (2)  finite difference approximation for negative v
              if v < 0
%...
%...             sparse discretization matrix      
%...
%...             interior points      
                 D=diag(-3*ones(n,1),0)+diag(+4*ones(n-1,1),+1)+diag(-1*ones(n-2,1),+2);      
%...
%...             boundary points      
                 D(n-1,(n-2):n) = [-1 0 +1];
                 D(n,(n-2):n) = [+1 -4 +3];
              end;                
%...      
      D=r2fdz*D;
      D=sparse(D);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -