# How to describe the movement of a piston?

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

 October 20, 2021, 09:25 How to describe the movement of a piston? #1 New Member   Gao Shangya Join Date: Oct 2021 Posts: 18 Rep Power: 2 Hello everyone, I am currently working on my masters thesis which is about writing a code in Matlab to describe the simulation of a gas exchange in an hydrogen combustion engine. I am at the beginning of my studies and I am using lid driven cavity as an example to write the code. But I found some questions:How do I describe the movement of the piston in the code written in matlab? And what are the main equations I have to use to describe the gas (NS equation, convection-diffusion equation)? When I use the NS equation to describe the flow of the gas, I find it difficult to describe the convective diffusion equation at the same time? I would be very grateful if you could give me some advice

 October 20, 2021, 10:31 #3 Senior Member   Sayan Bhattacharjee Join Date: Mar 2020 Posts: 395 Rep Power: 5 Since I don't do research in IC engine, so my answers were somewhat speculative. If you truly need the best answer, I would highly recommend you to search for CFD papers for modelling IC engines and papers on writing CFD codes for modelling IC engines. Find a good paper, study how they do it, then based on that, you can implement your code. All of your research problems have already been solved by someone else. Just follow their work as inspiration Harlotte likes this.

October 20, 2021, 12:31
#4
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,103
Rep Power: 66
Quote:
 Originally Posted by Harlotte Hello everyone, I am currently working on my masters thesis which is about writing a code in Matlab to describe the simulation of a gas exchange in an hydrogen combustion engine. I am at the beginning of my studies and I am using lid driven cavity as an example to write the code. But I found some questions:How do I describe the movement of the piston in the code written in matlab? And what are the main equations I have to use to describe the gas (NS equation, convection-diffusion equation)? When I use the NS equation to describe the flow of the gas, I find it difficult to describe the convective diffusion equation at the same time? I would be very grateful if you could give me some advice

1) the lid driven cavity is a good test-case to develop and testing a simple CFD code but it is for incompressible flows. In your case you have compression and expansion, therefore you need to solve the compressible form of the equations.
2) The movement of a piston can be either prescribed or consequent to the flow dynamics, what is your case?
3) The modern trend of the CFD code is to use the immersed boundary method. Thins, You have the moving boundary on a fixed background grid. Several approaches can be adopted and you will find a lot of literature.

4) Whan do you mean for "I find it difficult to describe the convective diffusion equation at the same time"

October 25, 2021, 03:02
#5
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by aerosayan Since I don't do research in IC engine, so my answers were somewhat speculative. If you truly need the best answer, I would highly recommend you to search for CFD papers for modelling IC engines and papers on writing CFD codes for modelling IC engines. Find a good paper, study how they do it, then based on that, you can implement your code. All of your research problems have already been solved by someone else. Just follow their work as inspiration
Thank you very much for your advice, it has been very inspiring for me. I will read more CFD papers for modelling IC engines and papers on writing CFD codes for modelling IC engines. I hope this will be useful for me.

October 25, 2021, 03:11
#6
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by FMDenaro 1) the lid driven cavity is a good test-case to develop and testing a simple CFD code but it is for incompressible flows. In your case you have compression and expansion, therefore you need to solve the compressible form of the equations. 2) The movement of a piston can be either prescribed or consequent to the flow dynamics, what is your case? 3) The modern trend of the CFD code is to use the immersed boundary method. Thins, You have the moving boundary on a fixed background grid. Several approaches can be adopted and you will find a lot of literature. 4) Whan do you mean for "I find it difficult to describe the convective diffusion equation at the same time"
First of all thank you very much for the advice! Regarding the motion of the piston, my idea is to specify a fixed velocity that moves with time. When I was looking at the lid driven cavity example it used the NS equation but did not discretize the convective diffusion equation. I am still learning CFD, is the convective diffusion equation already included in the NS equation? So no discretization is needed?

October 25, 2021, 22:41
#7
Senior Member

Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 395
Rep Power: 5
Quote:
 Originally Posted by Harlotte First of all thank you very much for the advice! Regarding the motion of the piston, my idea is to specify a fixed velocity that moves with time. When I was looking at the lid driven cavity example it used the NS equation but did not discretize the convective diffusion equation. I am still learning CFD, is the convective diffusion equation already included in the NS equation? So no discretization is needed?
The convection and diffusion, are physical transport phenomenons that happen. Fluid flow happens to be due to the combination of both. So, automatically NS equations contain the convection and diffusion terms. So, to solve the NS equations, you need to discretize them.

Did you write simple 1D, 2D solvers for convection and diffusion before?

I just had a recent discussion here on how much majority of the students have difficulty understanding CFD because they have never been taught to develop the simpler solvers.

October 26, 2021, 01:15
#8
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by aerosayan The convection and diffusion, are physical transport phenomenons that happen. Fluid flow happens to be due to the combination of both. So, automatically NS equations contain the convection and diffusion terms. So, to solve the NS equations, you need to discretize them. Did you write simple 1D, 2D solvers for convection and diffusion before? I just had a recent discussion here on how much majority of the students have difficulty understanding CFD because they have never been taught to develop the simpler solvers.
I have not written solvers for convective diffusion equations before.
Yes, understanding CFD is also difficult for me, I had not studied it before, but I need to complete the Master's thesis. Can you give me some advice for my situation?

October 26, 2021, 08:07
#9
Senior Member

Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 395
Rep Power: 5
Quote:
 Originally Posted by Harlotte I have not written solvers for convective diffusion equations before. Yes, understanding CFD is also difficult for me, I had not studied it before, but I need to complete the Master's thesis. Can you give me some advice for my situation? I appreciate your help.
How much time do you have left? Master's thesis generally take 2 years in India. I'm not sure how long it takes in other countries.

Honestly, if you have less than 1.5 years of time left, it might be better to use commerical codes like ANSYS or OpenFOAM or SU2 to do your research instead of developing a solver yourself.

I don't mean to be discouraging, and CFD is easy to learn once we know the basics, but learning the basics take some time. That can be done easily in 2 month, if you have a guided learning path.

But since your research topic is in combustion CFD, and you mean to write your own solver, it becomes much more challenging. Combustion CFD requires you to know the basics of CFD + advanced combustion models.

Learning advanced combustion models might take 7 or more months if your guiding professor is an expert in combustion CFD. If you plant to learn on your own, it would take a few years.

Only take this opportunity if your professor is also an expert in combustion CFD. Otherwise he/she won't be able to guide you or correct your mistakes.

however I don't mean to be discouraging. You could do your research that you want. However anyone would highly recommend you to use commerical CFD solvers like ANSYS/COMSOL etc. instead of writing your own code.

October 26, 2021, 08:22
#10
Senior Member

Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,103
Rep Power: 66
Quote:
 Originally Posted by Harlotte I have not written solvers for convective diffusion equations before. Yes, understanding CFD is also difficult for me, I had not studied it before, but I need to complete the Master's thesis. Can you give me some advice for my situation? I appreciate your help.

Generally, a CFD student does practice first with simple exercises like those in the book of Ferziger, Peric and Street. Only after some months he can approach the methods for solving NSE.

That while assuming he has already a good background in fluid mechanics.

What is your present educational background?

October 26, 2021, 08:34
#11
Senior Member

Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 395
Rep Power: 5
Quote:
 Originally Posted by FMDenaro Generally, a CFD student does practice first with simple exercises like those in the book of Ferziger, Peric and Street. Only after some months he can approach the methods for solving NSE. That while assuming he has already a good background in fluid mechanics. What is your present educational background?
In my opinion, Professor Lorena Barba's course 12 steps to NS equations is more approachable by students : https://lorenabarba.com/blog/cfd-pyt...navier-stokes/

However, @Harlotte would be best prepared to complete their combustion CFD solver in 2 years *only and only if* their guiding professor has also written combustion CFD solvers before.

I could be wrong, but that's the most probable outcome.

October 26, 2021, 08:46
#12
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
Thank you very much for the advice you have given me.
I am a current master in Germany and the Master's theses take 8 months in Germany. My supervisor asked me to write a simple solver in Matlab. This solver should at least include the intake and exhaust ports, but the Ignition can be ignored in this model(I think that the combustion can be ignored). In this way, is it possible to simplify this solver?

October 26, 2021, 09:00
#13
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by aerosayan In my opinion, Professor Lorena Barba's course 12 steps to NS equations is more approachable by students : https://lorenabarba.com/blog/cfd-pyt...navier-stokes/ However, @Harlotte would be best prepared to complete their combustion CFD solver in 2 years *only and only if* their guiding professor has also written combustion CFD solvers before. I could be wrong, but that's the most probable outcome.
I've been watching Tanmay's videos to learn recently:https://www.youtube.com/watch?v=VwGF...7xbmJISRWA0xYS. Even though he talks about incompressible fluids, it's still inspiring to me. But if I want to complete my solver, I find it's not enough...

October 26, 2021, 09:06
#14
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by FMDenaro Generally, a CFD student does practice first with simple exercises like those in the book of Ferziger, Peric and Street. Only after some months he can approach the methods for solving NSE. That while assuming he has already a good background in fluid mechanics. What is your present educational background?

I had no basic knowledge of CFD before that and I had also not tried to write some CFD code before. I just learn CFD by myself t in the last two months.

October 26, 2021, 12:50
#15
Senior Member

Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 395
Rep Power: 5
Quote:
 Originally Posted by Harlotte Thank you very much for the advice you have given me. I am a current master in Germany and the Master's theses take 8 months in Germany. My supervisor asked me to write a simple solver in Matlab. This solver should at least include the intake and exhaust ports, but the Ignition can be ignored in this model(I think that the combustion can be ignored). In this way, is it possible to simplify this solver?
If intake and exhaust is only to be modelled and the combustion isn't required, then it can be done.

Although you need more restrictions. Is it 2D or 3D? What is the geometry of the combustion chamber? Will this geometry changed and will you need to use your code for analysing multiple different geometries? Will the Piston move? How much accuracy in results do you require? Do you need to simulate the full cycle, or can you just simulate parts of the cycle, like gas expansion or compression? What's going to be entering into the camber? Is it only air, or air+fuel mixture?

Try to come up with the more restrictions, so the solver is simple. Clarify it with your professor, and ensure that's enough for the project.

Never complicate things.

October 26, 2021, 22:44
#16
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by aerosayan If intake and exhaust is only to be modelled and the combustion isn't required, then it can be done. Although you need more restrictions. Is it 2D or 3D? What is the geometry of the combustion chamber? Will this geometry changed and will you need to use your code for analysing multiple different geometries? Will the Piston move? How much accuracy in results do you require? Do you need to simulate the full cycle, or can you just simulate parts of the cycle, like gas expansion or compression? What's going to be entering into the camber? Is it only air, or air+fuel mixture? Try to come up with the more restrictions, so the solver is simple. Clarify it with your professor, and ensure that's enough for the project. Never complicate things.
Thank you very much for your help! At the moment it is a 2D model that is needed. Cylindrical geometry is enough. I don't need to analyse multiple geometries. The piston will move, the piston will move down when the air enters and afterwards the compression of the gas will take place. I am simulating a mixture of air and hydrogen. I still need to check with my supervisor for accuracy and for the part of the simulation cycle.

Thanks again for the advice you gave me, it helps me a lot!

October 27, 2021, 13:46
#17
Senior Member

Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 395
Rep Power: 5
Quote:
 Originally Posted by Harlotte Thank you very much for your help! At the moment it is a 2D model that is needed. Cylindrical geometry is enough. I don't need to analyse multiple geometries. The piston will move, the piston will move down when the air enters and afterwards the compression of the gas will take place. I am simulating a mixture of air and hydrogen. I still need to check with my supervisor for accuracy and for the part of the simulation cycle. Thanks again for the advice you gave me, it helps me a lot!
All right, based on the restrictions and requirements, this is possible. It's basically a NS solver without any extra fancy things. You can probably get away with using a structured grid, and if the piston is moving, set how much it will move at every timestep. If it moves 1 mm every timestep, then you can just make a structured grid with 0.5 mm (or less) cell width and height.

Look up old CFD papers on simulating piston engines. They are simpler to understand and replicate.

October 27, 2021, 21:38
#18
New Member

Gao Shangya
Join Date: Oct 2021
Posts: 18
Rep Power: 2
Quote:
 Originally Posted by aerosayan All right, based on the restrictions and requirements, this is possible. It's basically a NS solver without any extra fancy things. You can probably get away with using a structured grid, and if the piston is moving, set how much it will move at every timestep. If it moves 1 mm every timestep, then you can just make a structured grid with 0.5 mm (or less) cell width and height. Look up old CFD papers on simulating piston engines. They are simpler to understand and replicate.
Ok, thank you very much for the suggestion! It inspires me a lot.

 Tags engine cylinder head, matlab codes for cfd