# CFD Basics
Coding practice of Anderson's CFD book: __Computational Fluid Dynamics: The basics with applications__
## Laval (Chapter7)
The Laval pipe, a classical 1D problem, based on Euler equation.
### (0) Subsonic-Supersonic Isentropic Flow
MacCormack Scheme.
Usage:
> * Compile: `g++ main.cc -o Laval`
> * Execute: `./Laval`
> * Animate: `python3 animate.py`
The program will produce a flowfield history file named `flow.txt`, and the steady-state flowfield looks like:
![steady-laval](Laval/0/steady.png)
Pay attention to B.C. at both inlet and outlet!
### (1) Subsonic Isentropic Flow
MacCormack Scheme.
Clearly, velocity peaks at central.
Usage:
> * Compile: `g++ main.cc -o Laval`
> * Execute: `./Laval`
> * Animate: `python3 animate.py`
### (2) Conservative form for Subsonic-Supersonic Isentropic Flow
MacCormack Scheme.
Usage:
> * Compile: `g++ main.cc -o Laval`
> * Execute: `./Laval`
> * Animate: `python3 animate.py`
### (3) Shockwave Capture
MacCormack Scheme.
Add artificial viscosity at both prediction and correction steps.
Usage:
> * Compile: `g++ main.cc -o Laval`
> * Execute: `./Laval`
> * Animate: `python3 animate.py`
The program will produce a flowfield history file named `flow.txt`, and the steady-state flowfield looks like:
![steady-shock](Laval/3/steady.png)
## Couette (Chapter8)
Viscous flow between 2 parallel plate.
### (0) 1D simulation
The simplified G.E. is given as:
<div align=center><img src="Couette/1D/eqn.png"/></div>
it is similiar with unsteady heat transfer equation, which is __parabolic__.
Crank-Nicolson method is used, which is __unconditionally__ stable due to its implicitness. Hence, larger time-step can be taken via tuning the parameter `E`.
However, errors during iteration will get larger when `E` is increasing due to larger truncation error.
This well illustrates that, even with implict scheme, timestep can not go to infinity!(an optimal timestep in between)
Usage:
> * Compile: `g++ main.cc -o Couette`
> * Execute: `./Couette`
> * Animate: `python3 animate.py`
The program will produce a flowfield history file named `flow.txt`, and the steady-state flowfield(with `E=1.0`) looks like:
<div align=center><img src="Couette/1D/steady.png"/></div>
Be careful with the index inside the Thomas algorithm!
### (1) 2D simulation
Pressure-Correction method in general.
Classical schemes like __SIMPLE__, __SIMPLER__ and __PISO__ are used on __staggered__ grids.
Grid with virtual nodes is adopted as illustrated in `Chapter 8.4.1`.
Variable placement follows the convention introduced in `Chapter 6.8.4`.
<div align=center><img src="Couette/2D/grid.png"/></div>
Standard TECPLOT ASCII data files will be produced every time-step.
#### (1.1) SIMPLE
Standard SIMPLE method is used to achieve final steady-state result.
The poisson equation is solved implicitly by solving a linear system.
Convergency history:
|<div align=center><img src="Couette/2D/SIMPLE/mass_flux.png"/></div>|<div align=center><img src="Couette/2D/SIMPLE/u.png"/></div>|
|:-:|:-:|
|mass flux at (15, 5)|__u__ at i=15|
Values on __Boundary__:
-|Left Inlet|Right Outlet|Top Lid|Bottom Wall
:-:|:-:|:-:|:-:|:-:
p'|zero|zero|zero-gradient|zero-gradient
u|linear extrapolation|linear extrapolation|Ue|0
v|0|by computation|0|0
Values on __virtual__ nodes are mostly calculated by __linear extrapolation__ from neighbouring nodes.
Usage:
> * Compile: `g++ main.cc -std=c++14 -I /usr/include/eigen3 -o Couette`
> * Execute: `./Couette`
> * View full flowfield: `Tecplot` or `ParaView` or `EnSight`
> * Animate convergency history at (15, 5): `python3 animate.py`
> * Path of `Eigen3` may vary in different systems or platforms, adjust it accordingly.
#### (1.2) SIMPLER
It is similiar with __SIMPLE__ in general, but a better __p*__ is provided by calculating the pressure equation in advance within each iteration loop.
Convergency history:
|<div align=center><img src="Couette/2D/SIMPLER/u.png"/></div>|<div align=center><img src="Couette/2D/SIMPLER/v.png"/></div>|
|:-:|:-:|
|__u__ at i=15 | __v__ at i=15|
Usage:
> * Compile: `g++ main.cc -std=c++14 -I /usr/include/eigen3 -o Couette`
> * Execute: `./Couette`
> * View full flowfield: `Tecplot` or `ParaView` or `EnSight`
> * Animate convergency history at (15, 5): `python3 animate.py`
> * Path of `Eigen3` may vary in different systems or platforms, adjust it accordingly.
__SIMPLER__ is much more stable than __SIMPLE__ in terms of the divergence term.
#### (1.3) PISO
In my opinion, __PISO__ corrects pressure twice, while __SIMPLER__ predicts once and corrects once.
Convergency history:
|<div align=center><img src="Couette/2D/PISO/u.png"/></div>|<div align=center><img src="Couette/2D/PISO/v.png"/></div>|
|:-:|:-:|
|__u__ at i=15 | __v__ at i=15|
Usage:
> * Compile: `g++ main.cc -std=c++14 -I /usr/include/eigen3 -o Couette`
> * Execute: `./Couette`
> * View full flowfield: `Tecplot` or `ParaView` or `EnSight`
> * Animate convergency history at (15, 5): `python3 animate.py`
> * Path of `Eigen3` may vary in different systems or platforms, adjust it accordingly.
Pay attention to the B.C. of the pressure correction equation!
It seems unstable in the begining, may be improved if under-relaxation is used when updating pressure.
## Plate (Chapter9)
Supersonic flow over a plate.
2 different thermal B.C. are examined.
### (0) Isothermal B.C.
Wall temperature is fixed.
MacCormack scheme is adopted.
The back-and-forth alternation on derivatives aims at obtaining 2nd-order accuracy.
Flowfiled at Steady-State:
|<div align=center><img src="Plate/0-Isothermal/fig/U.png"/></div>|<div align=center><img src="Plate/0-Isothermal/fig/V.png"/></div>|
|:-:|:-:|
|<div align=center><img src="Plate/0-Isothermal/fig/p.png"/></div>|<div align=center><img src="Plate/0-Isothermal/fig/T.png"/></div>|
Pressure at bottom:
<div align=center><img src="Plate/0-Isothermal/fig/p_bottom.png"/></div>
Values at outlet:
<div align=center><img src="Plate/0-Isothermal/fig/outlet.png"/></div>
Standard TECPLOT data file in ASCII format will be produced every 100 steps.
An aditional file `history.txt` will be written for animation.
Usage:
> * Compile: `g++ main.cc -std=c++14 -o Plate -O3`
> * Execute: `./Plate`
> * View: `Tecplot` or `ParaView` or `EnSight`
> * Animate: `python3 animate.py`
Pay attention to values at ___boundary___, remember to update them!
### (1) Adiabatic B.C.
Similar to previous, only wall temperature gradient is set to 0.
This is achieved by simply setting `T(i, JMIN) = T(i, JMIN+1)` inside program.
Flowfiled at Steady-State:
|<div align=center><img src="Plate/1-Adiabatic/fig/U.png"/></div>|<div align=center><img src="Plate/1-Adiabatic/fig/V.png"/></div>|
|:-:|:-:|
|<div align=center><img src="Plate/1-Adiabatic/fig/p.png"/></div>|<div align=center><img src="Plate/1-Adiabatic/fig/T.png"/></div>|
Pressure at bottom:
<div align=center><img src="Plate/1-Adiabatic/fig/p_bottom.png"/></div>
Values at outlet:
<div align=center><img src="Plate/1-Adiabatic/fig/outlet.png"/></div>
Standard TECPLOT data file in ASCII format will be produced every 100 steps.
An aditional file `history.txt` will be written for animation.
Usage:
> * Compile: `g++ main.cc -std=c++14 -o Plate -O3`
> * Execute: `./Plate`
> * View: `Tecplot` or `ParaView` or `EnSight`
> * Animate: `python3 animate.py`
没有合适的资源?快使用搜索试试~ 我知道了~
计算流体力学入门Aderson代码
共53个文件
png:25个
py:10个
cc:10个
需积分: 5 2 下载量 118 浏览量
2022-12-26
15:06:26
上传
评论
收藏 1.15MB ZIP 举报
温馨提示
计算流体力学入门Aderson代码
资源推荐
资源详情
资源评论
收起资源包目录
CFD-Basics-master.zip (53个子文件)
CFD-Basics-master
LICENSE 1KB
Couette
2D
SIMPLER
CMakeLists.txt 193B
v.png 20KB
animate.py 2KB
u.png 33KB
main.cc 13KB
SIMPLE
CMakeLists.txt 192B
animate.py 2KB
u.png 33KB
mass_flux.png 36KB
main.cc 12KB
PISO
CMakeLists.txt 190B
v.png 20KB
animate.py 2KB
u.png 30KB
main.cc 15KB
grid.png 170KB
1D
animate.py 1KB
eqn.png 776B
steady.png 22KB
main.cc 4KB
Plate
1-Adiabatic
CMakeLists.txt 119B
animate.py 4KB
main.cc 23KB
fig
rho.png 49KB
T.png 37KB
outlet.png 95KB
p_bottom.png 24KB
U.png 33KB
V.png 51KB
p.png 42KB
0-Isothermal
CMakeLists.txt 119B
animate.py 4KB
main.cc 23KB
fig
rho.png 33KB
T.png 39KB
outlet.png 101KB
p_bottom.png 29KB
U.png 24KB
V.png 47KB
p.png 39KB
.gitignore 286B
Laval
0
animate.py 2KB
steady.png 168KB
main.cc 7KB
1
animate.py 2KB
main.cc 7KB
2
animate.py 2KB
main.cc 8KB
3
animate.py 2KB
steady.png 78KB
main.cc 9KB
README.md 7KB
共 53 条
- 1
资源评论
ambu1230
- 粉丝: 84
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功