CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Convergence study_Computational fluid dynamics (https://www.cfd-online.com/Forums/main/123458-convergence-study_computational-fluid-dynamics.html)

miel_35 September 13, 2013 05:18

Convergence study_Computational fluid dynamics
 
Hello guys!
I am a beginner in Matlab, I am currently a student in Computational fluid dynamics and i am struggling badly with the codes.

We started with a script that uses Taylor's series expansion to compute coefficients of one-dimensional Finite Difference schemes on an even stencil using 'a' points to the left and 'b' points to the right for a total of 'r = a + b + 1' points in the stencil. I was able to develop this script and afterwards, i made it a function as i should use it for another exercise. That's where i am stuck. I have to use a double 'for'-loop to run over all combinations of grid points in N and stencils in STENCIL to compute the max. trunc. errors in ERROR.
%% Input
L = 1; % length of domain
N = [5 10 20 40 80 160 320]; % vector with num. of grid points
STENCIL = [ 0 1 ; 1 1 ; 2 2 ]; % stencil size array
%% Initialize
k = 2*pi/L; % wave number
Dx = L./(N-1); % vector with grid spacings
ERROR = zeros(size(STENCIL,1),length(N)); % array to hold maximum errors
ROC = zeros(size(STENCIL,1),1); % vector to hold rates of conv.
TL = zeros(size(STENCIL,1),length(N)); % array to hold tendency line val.

Can anyone help? I would appreciate.


All times are GMT -4. The time now is 10:53.