基于有限体积法 (FVM) 和 SIMPLE 算法求解平行板之间层流的速度、压力和温度附 MATLAB 代码

article/2025/1/12 0:54:29

 ✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法       神经网络预测       雷达通信       无线传感器        电力系统

信号处理              图像处理               路径规划       元胞自动机        无人机 

❤️ 内容介绍

在流体力学领域,层流是指在平行板之间的流动,其中流体沿着平行的路径流动,而不发生明显的横向混合。层流现象在许多工程和科学应用中都非常重要,因此研究和理解层流的速度、压力和温度分布是至关重要的。

为了解决平行板之间层流的速度、压力和温度分布,工程师和科学家使用了一种称为有限体积法 (FVM) 的数值方法。有限体积法是一种将连续介质方程离散化的方法,它将流体域划分为许多小的体积单元,并在每个体积单元中计算流体的平均速度、压力和温度。

在有限体积法中,流体域被划分为一个个小的体积单元,每个体积单元都有一个中心点和相邻的体积单元。通过应用质量守恒、动量守恒和能量守恒等基本方程,可以在每个体积单元中建立离散方程。这些离散方程可以通过迭代求解来获得整个流体域的速度、压力和温度分布。

在层流问题中,SIMPLE (Semi-Implicit Method for Pressure-Linked Equations) 算法是一种常用的求解方法。SIMPLE算法通过耦合速度和压力来解决流体方程,并使用松弛因子来加速求解过程。该算法通过迭代计算速度和压力的修正值,直到满足收敛准则为止。

在使用有限体积法和SIMPLE算法求解平行板之间层流的速度、压力和温度时,需要进行一些前期准备工作。首先,需要定义流体域的几何形状和边界条件。然后,需要选择适当的网格划分方法,并计算每个体积单元的几何参数和初始值。接下来,通过迭代求解离散方程,可以得到流体域的速度、压力和温度分布。

在求解过程中,需要注意选择合适的数值格式和求解器,以确保结果的准确性和稳定性。此外,还需要进行网格收敛性和物理模型验证,以验证数值解的可靠性。

总之,基于有限体积法和SIMPLE算法求解平行板之间层流的速度、压力和温度是一项复杂而重要的工作。通过合理的几何划分、边界条件的定义和数值求解的迭代过程,可以得到准确和可靠的结果。这些结果对于理解和优化层流现象在工程和科学应用中的影响具有重要意义。

🔥核心代码

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Finite Volume Method with SIMPLE algorithm% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear,clc,close allglobal Fw Fe Fs Fn DF aW aE aS aN aP bP dU dV%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CHANNEL FLOW PROBLEM WITH CONSTANT TEMPERATURE OR HEAT FLUX WALLS% GeometryH = 0.01;       % Height of channel in y-direction(m)L = 10*H;       % Length of cavity in x-direction (m)% Grid geometryNx = 200;       % Number of main grid points in x-direction within domaindx = L/Nx;      % Grid spacing in x-directionNy = 40;        % Number of main grid points in y-direction within domaindy = H/Ny;      % Grid spacing in y-directiondz = 0.01;      % Width in z-direction for flux calculations (m)x  = dx/2:dx:L-dx/2;    % x-locations of main grid points (m)xu = 0:dx:L;            % x-locations of u-velocities (m)y  = dy/2:dy:H-dy/2;    % y-locations of main grid points (m)yv = 0:dy:H;            % y-locations of v-velocities (m)iu = 1:Nx+1; Ju = 2:Ny+1;   % Interior node numbers for uIv = 2:Nx+1; jv = 1:Ny+1;   % Interior node numbers for vIp = 2:Nx+1; Jp = 2:Ny+1;   % Interior node numbers for piF = 2:Nx;   jF = 2:Ny;     % Node numbers for face flow (or advection)% Properties (air at STP)rho   = 1.2;            % Density (kg/m^3)mu    = 1.8e-5;         % Absolute viscosity (N-s/m^2)nu    = mu/rho;         % Kinematic viscosity (m^2/s)kt    = 0.025;          % Thermal conductivity (W/m-K)cp    = 1006;           % Specific heat (J/kg-K)alpha = kt/(rho*cp);    % Thermal diffusivity (m^2/s)Pr    = nu/alpha;       % Prandtl number% Boundary conditionsRe = 100;               % Reynolds numberU  = Re*nu/(2*H);       % Average velocity(m/s)Ti = 20;                % Inlet temperature (deg. C)Tw = 100;               % Wall temperature (deg. C)qw = 100;               % Wall heat flux (W/m^2)BC_N = 1;               % BC_N = 0 for Tw, BC_N = 1 for qwBC_S = 1;               % BC_S = 0 for Tw, BC_S = 1 for symmetry% Solution controlsalphaU  = 0.3;  % Velocity relaxation (under)alphaP  = 0.2;  % Pressure relaxation (under)NmaxSIM = 1e+4; % Iteration max for SIMPLE algorithm (-)NmaxGSI = 1e+1; % Iteration max for numerical method (-)err     = 1e-5; % Convergence criteria (-)div     = 1e+1; % Divergence criteria (-)% Initialize u, v, p, T, F, a, and residual matricesu      = zeros(Nx+1,Ny+2); v      = zeros(Nx+2,Ny+1);uStar  = zeros(Nx+1,Ny+2); vStar  = zeros(Nx+2,Ny+1);uPrime = zeros(Nx+1,Ny+2); vPrime = zeros(Nx+2,Ny+1);dU     = zeros(Nx+1,Ny+2); dV     = zeros(Nx+2,Ny+1);T      = zeros(Nx+2,Ny+2);p      = zeros(Nx+2,Ny+2); pPrime = zeros(Nx+2,Ny+2);Fe = zeros(Nx+1,Ny+1); Fw = zeros(Nx+1,Ny+1);   % Flow coefficientsFn = zeros(Nx+1,Ny+1); Fs = zeros(Nx+1,Ny+1);DF = zeros(Nx+1,Ny+1);aE = zeros(Nx+1,Ny+1); aW = zeros(Nx+1,Ny+1);   % Coefficients foraN = zeros(Nx+1,Ny+1); aS = zeros(Nx+1,Ny+1);   % discretized equationsaP = zeros(Nx+1,Ny+1); bP = zeros(Nx+1,Ny+1);ures  = zeros(NmaxSIM,1);   % Residual for uvres  = zeros(NmaxSIM,1);   % Residual for vpres  = zeros(NmaxSIM,1);   % Residual for pPrime% Inlet velocity for uniform flow at inletu(:,Ju) = U;% Initialize to inear pressure drop for fully developed flowp1  = 12*mu*U*L/(2*H)^2;    p(Ip,Jp) = ones(Nx,Ny).*linspace(p1,0,Nx)';% Initialize temperature to inlet and wall temperaturesT(:,Jp) = Ti; T(:,1) = Tw; T(:,Ny+2) = Tw;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SIMPLE algorithm% Constant diffussion coefficientsDx = (mu/dx)*dy*dz;Dy = (mu/dy)*dx*dz;for n = 1:NmaxSIM    % Initial guess    uOld  = u;    vOld  = v;    pStar = p;        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    % STEP 1a: solve x-momentum as uStar    % Setup coefficients    FVM_u(Nx,Ny,dx,dy,dz,rho,Dx,Dy,iF,Ju,alphaU,uOld,vOld,pStar,BC_S);        % Use previous calculation as initial guess in numerical method      [uStar,ures(n)] = FVM_GS_ext_mesh(Nx,Ny+1,alphaU,NmaxGSI,err,uOld);    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    % STEP 1b: solve y-momentum as vStar    % Setup coefficients    FVM_v(Nx,Ny,dx,dy,dz,rho,Dx,Dy,Iv,jF,alphaU,u,v,pStar)        % Use previous calculation as initial guess in numerical method         [vStar,vres(n)] = FVM_GS_ext_mesh(Nx+1,Ny,alphaU,NmaxGSI,err,vOld);        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    % STEP 2: Solve pressure correction equation (PCE)    % Setup coefficients    FVM_pcorr(Nx,Ny,dx,dy,dz,rho,Ip,Jp,uStar,vStar)      % Use numerical method to calculate pressure correction    pPrime(:,:) = 0;    [pPrime,pres(n)] = FVM_GS_ext_mesh(Nx+1,Ny+1,1,NmaxGSI,err,pPrime);      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%     % STEP 3: calculate corrected pressure and velocity    % p corrections with under-relaxation    p(Ip,Jp)      = pStar(Ip,Jp) + pPrime(Ip,Jp)*alphaP;        % u corrections    uPrime(iF,Ju) = dU(iF,Ju).*(pPrime(iF,Ju) - pPrime(iF+1,Ju));                          u(iF,Ju)      = uStar(iF,Ju) + uPrime(iF,Ju);                     % v corrections    vPrime(Iv,jF) = dV(Iv,jF).*(pPrime(Iv,jF) - pPrime(Iv,jF+1));                          v(Iv,jF)      = vStar(Iv,jF) + vPrime(Iv,jF);        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    % STEP 4: Check for convergence or divergence        if n > 10                fprintf('n = %5.0f, u = %6.2e, v = %6.2e, p = %6.2e \n',...                 n,ures(n),vres(n),pres(n))        cTest = max([ures(n),vres(n)]);        if cTest < err            break;         elseif cTest > div || isnan(cTest)            fprintf('Residuals are too high.')            break;        end    end        % Apply right boundary condition (outlet, du/dx = dv/dx = 0)    u(Nx+1,:) = u(Nx,:);          v(Nx+2,:) = v(Nx+1,:);    end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % STEP 5: solve for temperature distribution% Setup coefficientsFVM_phi(Nx,Ny,dx,dy,dz,rho,kt/cp,qw/cp,Ip,Jp,u,v,BC_S,BC_N)% Use numerical method to calculate temperature[T,Tres] = FVM_GS_ext_mesh(Nx+1,Ny+1,1.0,1e4,1e-8,T);                   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % POST PROCESSINGfigure('Name','Convergence Plot for Scaled Residuals',...       'Position',[100 100 500 300])% Convergence plotnlist = 10:n;semilogy(nlist,ures(nlist),'-b',nlist,vres(nlist),'-r',...         nlist,pres(nlist),'-g')legend('u residual','v residual','p residual')xlabel('Iteration')ylabel('Scaled Residual')FVM_Vplot(Nx,Ny,x,xu,y,H,u(iu,Ju),v(Iv,jv),p(Ip,Jp),U)FVM_Tplot(Nx,Ny,x,y,L,H,rho,cp,u(iu,Ju),T(Ip,Jp),U,Ti,Tw,qw,BC_N)​

❤️ 运行结果

⛄ 参考文献

[1]娄淑梅,赵国群,王锐.铝型材非稳态挤压有限体积法模拟关键技术研究与应用[J].中国机械工程, 2006(S1):4.DOI:JournalArticle/5aed8a4bc095d710d40d2617.

⛳️ 代码获取关注我

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料

🍅 仿真咨询

1 各类智能优化算法改进及应用

生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化

2 机器学习和深度学习方面

卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断

2.图像处理方面

图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知

3 路径规划方面

旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化

4 无人机应用方面

无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
、无人机安全通信轨迹在线优化

5 无线传感器定位及布局方面

传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化

6 信号处理方面

信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化

7 电力系统方面

微电网优化、无功优化、配电网重构、储能配置

8 元胞自动机方面

交通流 人群疏散 病毒扩散 晶体生长 火灾扩散

9 雷达方面

卡尔曼滤波跟踪、航迹关联、航迹融合、状态估计


http://chatgpt.dhexx.cn/article/VB3x1wgd.shtml

相关文章

【论文笔记】AP聚类算法解读

文章目录 引子自己体会吸引信息更新公式归属信息更新公式松弛因子引入 缺点评估 论文原文 引子 网络上已经有很多关于AP算法的介绍了&#xff0c;托他们的福&#xff0c;我更快地理解了AP算法。但是感觉他们不说人话&#xff0c;只说了很抽象的概念&#xff0c;公式理解起来还…

r语言 支持向量机实现_支持向量机解密:R中的实现

r语言 支持向量机实现 Support Vector Machine, popularly abbreviated as SVM is a supervised learning algorithm used for both regression and classification but more commonly used for classification. SVMs have been shown to outperform well in a variety of sett…

2017华为软件精英挑战赛小结

// 2017华为软件精英挑战赛小结 // 不说废话&#xff0c;直接上货&#xff01;希望对目前的参赛者&#xff0c;或日后学习的人&#xff0c;提供一些参考和思路。 #include <赛题说明.pdf> // 见附录文件 赛题说明.pdf 或网址传送门&#xff1a;http://codecraft.hua…

19华为软件精英挑战赛止步复赛

2019年华为软件精英挑战赛&#xff0c;京津东北赛区初赛第13&#xff0c;复赛第18&#xff0c;呦车还没我跑的快。 历时一个多月的华为软件精英大赛落下帷幕&#xff0c;很遗憾的止步了三十二强&#xff0c;从初赛到复赛更改了大大小小的版本将近50多个&#xff0c;通过改进调度…

2021CCPC华为云挑战赛热身赛A题(思维)

题目链接 题意&#xff1a;简单来说必须立足于当前值等于A序列中的一个值才能去增加 【0&#xff0c;ki】范围内的值并且k- -。贪心的想法就是尽可能的让最终自己的数大&#xff0c;我们先从A序列中选一个最大的数且处于【0,m】以内&#xff0c;然后每次转移的时候判断a[i]-a[…

2018华为软件精英挑战赛-复赛赛题

以下描述部分主要是相对初赛赛题的变化点&#xff0c;其他描述和条件均一致&#xff1a; 通用性描述变化点&#xff1a; 物理服务器&#xff1a;为了满足不同虚拟机规格的需求&#xff0c;实际物理服务器规格也有多种&#xff0c;假设云平台共有三种类型的物理服务器&#xff0…

2017华为精英挑战赛总结

大赛官网&#xff1a;http://codecraft.huawei.com/ 赛题解读&#xff1a;http://mp.weixin.qq.com/s/on_l5Rc3Be-DjgUOXftaNw 赛题案例以及编译官方软件包&#xff1a;HUAWEI_Code_Craft_2017_初赛软件包(readme.txt中有详细介绍) 从2017.3.15到2017.4.6&#xff0c;花费三个…

2017华为精英挑战赛64强总结

比赛最后一周的时候每天到凌晨2-3点&#xff0c;最后通宵了一两次&#xff0c;提交大概100多版的版本&#xff0c;使用KWM网络流遗传算法&#xff0c;最终获得了西北赛区49名的成绩。 虽说不是很好&#xff0c;但对我来说是一份难得的经历&#xff0c;这里把比赛心得和体会总结…

华为2019挑战赛

华为软件精英挑战赛总结&#xff08;初赛&#xff09; 赛题&#xff1a; 评分标准&#xff1a; 思路&#xff1a;这是一个典型的动态负载均衡算法的设计&#xff0c;对于每一辆车来说&#xff0c;时间最短意味着路程最优&#xff0c;首先想到迪杰斯特拉来求出每一辆车的最优路径…

2017华为软件精英挑战赛总结

1.题目 本次赛题是一个视频服务器的CDN规划问题 赛题包_百度网盘 2.解题思 2.1 思路一 整数规划 主要是要把模型建出来 包含了 0-1变量->是否布置服务器 边变量-> 表示该边所跑的流量 用glpk试过,变量个数太庞大,内存都开不下,解的效果也不好,只能解很小…

2017华为软件精英挑战赛解分析

后经在复赛赛题上测试&#xff0c;效果并不好&#xff0c;只适合部分数据集&#xff0c;并且没有理论支持&#xff0c;放出来只为启发—— 以下方法初中级样例1s以内&#xff0c;高级样例10s内出最优解—— 不随机&#xff0c;无启发式&#xff0c;走优化的方法。采用反馈-迭代…

2021华为软件精英挑战赛(粤港澳赛区复赛第八)

一、序言 总结一下四月份参加的华为软挑赛&#xff0c;距离现在已经结束了四个多月&#xff0c;终于有时间抽空写写总结了&#xff08;小作文&#xff09;&#xff0c;我们是粤港澳赛区的620&619-F3队&#xff0c;第一次参加这次比赛&#xff0c;本想尝试一下&#xff0c;但…

css 给文字加下划线

css给文字加下划线 直接贴代码 span {cursor: pointer;&:hover {color: #40A9FF;text-decoration: underline;}}

Excel批量设置下划线

Excel批量设置下划线 目录 Excel批量设置下划线 1、框选需要设置的单元格内容&#xff0c;鼠标右键选择“设置单元格格式” 2、点击“自定义”在类型框中输入“ *_ ” 点击“确定”自动生成&#xff08;注意这个 *_符号需要将输入法切换为英文输入法&#xff09; 3、完成…

h5下划线怎么设置_怎么给文加下划线?

怎么给文本加下划线&#xff1f;下面本篇文章就给大家介绍一下HTML页面和word文档中给文本加下划线的方法。有一定的参考价值&#xff0c;有需要的朋友可以参考一下&#xff0c;希望对大家有所帮助。 HTML页面中给文本添加下划线 在HTML页面中怎么给文本添加下划线&#xff1f;…

latex输出下划线

第一种&#xff1a; 如果只是在作者的邮箱...输出下划线的话直接使用 \_ 就可以了 ma\_pengsen 输出结果&#xff1a; 第二种&#xff1a; 如果要在下划线上输出东西&#xff0c;那需要 \underline{XXXXXXX} ma\underline{ABCDEFG} 结果&#xff1a;

speedoffice(Word)文字怎么添加下划线

Word里面编辑文字&#xff0c;有时需要添加下划线&#xff0c;那么怎么添加下划线了&#xff1f;以最常用的speedoffice为列。 1、首先&#xff0c;我们用speedoffice打开Word文件&#xff0c;选中需要添加下划线的文字内容&#xff1b; 2、然后&#xff0c;鼠标点击选择“主页…

css里给文字加下划线代码,css给文字加下划线

语法&#xff1a;linear-gradient(direction, color-stop 1, color-stop 2,……) 简单用法&#xff1a;background-image: linear-gradient(red, transparent); 增加角度&#xff0c;linear-gradient(45deg, red, transparent) 加个position&#xff1a;linear-gradient(45deg,…

Word调整文字和下划线的间隔

工作环境(蓝色粗体字为特别注意内容) 1&#xff0c;开发环境&#xff1a;Microsoft word 2007 2&#xff0c;参考文献&#xff1a;https://blog.csdn.net/yiluyangguang1234/article/details/50158381 我们在使用Word编辑文档的时候&#xff0c;遇到有的标题带下划线的&#…

CSS设置下划线与文字间距距离

css的写下划线 text-decoration: underline; 但是这样的样式下划线太靠近文字了 如图 修改方式 border-bottom: 1px solid red;padding-bottom: 8px; 如图