CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   Boundary condition in Spectral method (

jollage April 5, 2013 15:18

Boundary condition in Spectral method
3 Attachment(s)
Hi All

I am playing with the boundary conditions in spectral method using Chebyshev grids.

Say, I want to solve the eigenfunction of \frac{\partial^2}{\partial x^2}. Analytically, the eigenfunction will be sin or cosine.

Indeed, in Matlab, the following small code will generate the eigenfunction with three different boundary conditions. I choose to plot from each boundary condition case an eigenfunction and attach here.




% q is the eigenfunction.

% bc: q(-1)=0,q(1)=0
% [ef,ev]=eig(D2(2:end-1,2:end-1));

% bc: q(-1)=0,q(1)=1. Just change the last 1 to 2 for q(-1)=0,q(1)=2
% [ef,ev]=eig(D2(2:end-1,2:end-1)+diag(D2(2:end-1,1))*1);

% bc: q(-1)=1,q(1)=1

for i=nrmod-2:-1:1
title([num2str(i) ' eigenvalue is ' num2str(ev(i,i))])

My question is:

Does it make sense to require the eigenfunction to have boundary condition q(-1)=0,q(1)=2? I tried in Matlab, but strange things happens, it returns the results of q(-1)=0,q(1)=0. Why is this?

Thanks a lot in advance!


jollage April 5, 2013 16:58

I am sorry.

I just realized that the way imposing the boundary condition as implemented here is not right. Could anyone tell me the right way?......Thanks.


All times are GMT -4. The time now is 19:17.