FVM Method For 1D Convection Diffusion Problem Using 5 Control volumes with spacing of 0.2

7 次查看(过去 30 天)

Hello sir, I solved FVM method for 1D convection Diffusion problem with 5 Control Volumes and with a spacing of 0.2,and velocity of 0.1 but the results i am getting is not up to the mark please guide me. I am attaching problem with my code clc; clear all;

phia=1; %Boundary Conditions phib=0; %Boundary Conditions gamma=0.1 L=1; %Length of a bar nx=5; %No. of subdomains dx=L/nx; %finite volume length phi=zeros(nx+2,1); u=0.1; rho=1; D=gamma/dx; F=rho*u; tolearnce=1e-4; error=1; phi(1,1)=phia; phi(7,1)=phib; iter=0; x=0:dx:nx; p= rho*u*nx/gamma phi_exact = phia + (phib-phia).*(exp(p.*x/nx) - 1)./(exp(p) - 1); while error>tolearnce phi_old=phi; iter=iter+1; for i=2 a_E=F/2+D; a_W=0; Spa=-(2*D+F); Sua=(2*D+F)*phia; a_P=a_E+a_W-Spa; phi(i,1)=(a_E*phi(i+1) + a_W*phi(i-1)+ Sua)/a_P; end

    for i=3:nx
        a_W=D+F/2;
        a_E=D-F/2;
        a_P=2*D;
        phi(i,1)=(a_E*phi(i+1) + a_W*phi(i-1))/a_P;
    end
    for i=6
        a_W=D+F/2;
        a_E=0;
        Spb=-(2*D-F);
        Sub=(2*D-F)*phib;
        a_P=a_E+a_W-Spb;
        phi(i,1)=(a_E*phi(i+1) + a_W*phi(i-1)+ Sub)/a_P;
    end
    error=max(abs(phi_old-phi));
    phi_new=phi;
end
figure();
x=[0,0.05,0.15,0.25,0.35,0.45,0.5];
plot(x,phi)                                    I am attaching original problem statements with its results Pleaee Guide me

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Computational Fluid Dynamics (CFD) 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by