Processing math: 100%

Saturday, October 13, 2012

COBY: Standard 1-D Chebyshev collocation method


Purpose
  • The package "Coby" provides the common Chebyshe collocation method for solving the 1-D elliptic equation with the general boundary condition.

Specifications
  • Name: Coby.
  • Author: Feng Chen.
  • Finishing date: 10/13/2012.
  • Languages: MATLAB.

Simple Example
  • Equation: αuu=f,x(1,1),a±u(±1)+b±u(±1)=c±.
  • Parameters: α=3,a±=1,b±=0.
  • Exact solution and input functions: u(x)=sin(πx),
    then f(x) and c± are calculated accordingly.

Quick Start
  • Compiling and running:
    matlab Coby_Driver_Dirichlet
    
  • Output:
    
    
  • CPU: Intel(R) Xeon(R) CPU X5550 @2.67GHz.
  • OS: CentOS release 6.4 (Final).
  • Release: MATLAB R2012a.

References

Code Highlights
    
    % initialize the first-order collocation matrix
    D = cheb(N); 
    
    % second-order collocation matrix
    D2 = D*D;
    
    % construct the linear system
    A = alp*diag(ones(N+1,1))-D2;
    
    % modify the first and last row for boundary conditions
    A(1,:) = bp*D(1,:)+ap*[1,zeros(1,N)];
    A(N+1,:) = bm*D(N+1,:)+am*[zeros(1,N), 1];
    
    % modify right hand side for boundary conditions
    b = [cp;f(2:N);cm];
    
    % solve for the solution
    u = A\b;
    
    

No comments:

Post a Comment