Question: I am trying to write a MATLAB code that will apply an expansion factor ( R ) to the nodes in the given parameters. Right
I am trying to write a MATLAB code that will apply an expansion factor R to the nodes in the given parameters. Right now, I have the code in terms of a constant expansion dx I would like each iteration to be expanding by a Ratio R
Current code:
clear all; close all; clc;
pmfilename;
D steady state convection diffusion hybrid method
finite volume
uniform mesh
Pe central difference
Pe upwind
L;
N;
dxLN;
gamma;
rho;
u;
PerhouLgamma;
phi;
phiL;
Frhou;
Dgammadx;
PexFD;
Graduates
coefficients
if Pex
sprintfPex gs Pex 'upwind'
Aw onesNF;
Ae zerosN;
elseif Pex
sprintfPex gs Pex 'upwind'
Aw zerosN;
Ae onesNF;
else
sprintfPex gs Pex 'central'
Aw onesNDF;
Ae onesNDF;
end
qp zerosN;
qu zerosN;
Undergrad
west
if Pex
Ae;
Aw;
qpDF;
quDFphi;
elseif Pex
AeF;
Aw;
qpD;
quDphi;
else
AeDF;
Aw;
qpDF;
quDFphi;
end
east
if Pex
AeN;
AwNF;
qpND;
quNDphiL;
elseif Pex
AeN;
AwN;
qpNFD;
quNFDphiL;
else
AeN;
AwND F;
qpND F;
quND FphiL;
end
assembly
Ap Aw Ae qp;
TDMA
phitdmaAwApAequ;
COORDINATES OF CELL CENTERS
xlinspaceLN;
for i:N
xcixixi;
end
CALCULATE EXACT SOLUTION AND ERROR NORM
ERROR;
for i:N
phiexiphiexpxciPeLexpPephiLphi;
ERRORERRORabsphiexiphii;
end
ERRORERRORN
Xxxcxend;
PHIphiphi',phiL;
PHIEXphiphiexphiL;
plotXPHI,bsXPHIEXr'linewidth',
legendFV'exact'
TDMA Code:
function X tdmaABCD
Cp C;
Dp D;
n lengthA;
X zerosn;
Cp CB;
Dp DB;
for i :n
Cpi CiBiCpiAi;
DpiDiDpiAiBiCpiAi;
end
Xn Dpn;
for i n::
Xi DpiCpiXi;
end:
Graph: See attached image
The graph shows evenly distributed iterations along Xaxis. I need one that expands by a factor of some ratio R
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
