# 2D SIMPLE Compressible flow Matlab

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 11, 2021, 03:55 2D SIMPLE Compressible flow Matlab #1 New Member   Gao Shangya Join Date: Oct 2021 Posts: 18 Rep Power: 4 Hello everyone, I'm Gao. I'm a master student in automotive systems. I am currently working on my thesis. The content of my thesis is to write a CFD code in matlab (it's 2D), this code is used to simulate the gas exchange in the cylinder of a hydrogen internal combustion engine. There is no need to consider the combustion as well as the exhaust. The intake and compression need to be considered. I have started my first step: assume that the piston is at the BDC and that air flows the cylinder at a certain speed. I have used a staggered grid and discretized the governing equations using the finite volume method, while I have coupled the pressure-velocity-density using the SIMPLE algorithm. I have successfully simulated the air flowing into the cylinder at a speed of 1m/s. However, when I modified the velocity just to 2m/s, my code went into chaos and I spent a lot of time trying to improve it, but it didn't seem to work. I would like people to take a look at my code and give me some advice. I'm not a very good programmer. Also, I am a newbie to CFD. I have commented my code very well and it is very easy to understand. If you could point out my mistakes and give me some corrections, I'd really appreciate your help!!! KR Gao

 December 22, 2021, 16:50 #2 New Member   Alan Join Date: Dec 2021 Posts: 7 Rep Power: 4 Hi, I used a similar approach to wrote a 2D FVM code using SIMPLE for the cavity lid problem. I think your problem resides in turbulence. If you discretize the NS equations directly, you have to bound your problem to laminar flow conditions. If some part of the flow start to behave like turbulent, then an exponentially growing numerical error would likely to occur, and the simulation would diverge. Try to set viscosity to zero. AMK

December 23, 2021, 07:02
#3
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 4
Quote:
 Originally Posted by PacMan Hi, I used a similar approach to wrote a 2D FVM code using SIMPLE for the cavity lid problem. I think your problem resides in turbulence. If you discretize the NS equations directly, you have to bound your problem to laminar flow conditions. If some part of the flow start to behave like turbulent, then an exponentially growing numerical error would likely to occur, and the simulation would diverge. Try to set viscosity to zero. AMK
Hello,
thank you for your advice.Do you know how to discretize the NS turbulence equations? I have searched for some literature,but there are no details...

 December 23, 2021, 08:42 #4 New Member   Alan Join Date: Dec 2021 Posts: 7 Rep Power: 4 I'm no specialist of this, but there are my advices: Look into Fluent Manual -> theory guide -> turbulence modeling or something like this... To model turbulence, you have to add (subtract the Reynold stress term in your velocity equations (Look the Raynolds Average NS - RANS). The RS term is then modelled in the scalar or vectorial equations of the turbulence model of your choice. The simplest is Spalart-Allmaras, but is not suited for your case. Try the k-epsilon, that is stable. Then you have to write the transport equations for k and epsilon. It has a lot of constants, take the default ones. Choose a strategy to determine k and epsilon values on the boundaries. Think of them as scalars, like something that is convected with the flow. Use first order upwind scheme (look into Patankar). Maybe in Versteeg and Malalasekera you can find some better explanation, but the solver manuals are written by people that use to code those things and are written in their language (very narrow). Good luck Harlotte likes this.

 Tags cfd, compressible flow problem, matlab