⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cfd3.m

📁 Computtional Fluid Dynamics (CFD) steady 1-Dimensional convection and diffusion using central diff
💻 M
字号:
clear all
L=1;
rho=1;
r=0.1;
N=50;
dx=L/N;
phia=4;
phib=1;

x=0:dx:L;
u=0.2;
phin1=(exp(rho*u*x/r)-1)*(phib-phia)/(exp(rho*u*L/r)-1)+phia;
u=3;
phin2=(exp(rho*u*x/r)-1)*(phib-phia)/(exp(rho*u*L/r)-1)+phia;


xc=1;
while xc==1
    clc
    fprintf('Menu\n1)Central  Differencing\n2)Upwind Differencing\n3)Hybrid Differencing\n4)Power Law\n5)Exit\n\n');
    dice=input('Choice : ','s');

switch dice
    case '1'
        S='central'; %tag recognition of method for tdma function.
        [x1,phi1]=tdma(0.2,10,S);
        [x2,phi2]=tdma(3,10,S);
        plot(x,phin1,x,phin2,x1,phi1,'-.d',x2,phi2,'-or')
        legend('actual 0.2 m/s','actual 3.0 m/s','u = 0.2 m/s','u = 3.0 m/s',0)
        title('Central Differencing')
        grid
        pause
        close
        
    case '2'
        S='upwind'; 
        [x1,phi1]=tdma(0.2,10,S);
        [x2,phi2]=tdma(3,10,S);
        plot(x,phin1,x,phin2,x1,phi1,'-.d',x2,phi2,'-or')
        legend('actual 0.2 m/s','actual 3.0 m/s','u = 0.2 m/s','u = 3.0 m/s',0)
        title('Upwind Differencing')
        grid
        pause
        close
        
    case '3'
        S='hybrid'; 
        [x1,phi1]=tdma(0.2,10,S);
        [x2,phi2]=tdma(3,10,S);
        plot(x,phin1,x,phin2,x1,phi1,'-.d',x2,phi2,'-or')
        legend('actual 0.2 m/s','actual 3.0 m/s','u = 0.2 m/s','u = 3.0 m/s',0)
        title('Hybrid Differencing')
        grid
        pause 
        close
       
        
        
    case '4'
        S='powlaw'; 
        [x1,phi1]=tdma(0.2,10,S);
        [x2,phi2]=tdma(3,10,S);
       plot(x,phin1,x,phin2,x1,phi1,'-.d',x2,phi2,'-o')
        legend('actual 0.2 m/s','actual 3.0 m/s','u = 0.2 m/s','u = 3.0 m/s',0)
        title('Power Law')
        grid
        pause
        close
        
       
        
    case '5'
        break
end
end
clc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -