CFD Online Discussion Forums

CFD Online Discussion Forums (
-   CFX (
-   -   Modeling the air flow of an Internal Combustion Engine (

mateusdias89 September 17, 2013 15:24

Modeling the air flow of an Internal Combustion Engine

I am starting to model the air flow in an internal combustion engine and started now to work on the moving parts. I divided this task in two parts: In the first, I want to learn how to simulate the movement of the valves, but with no movement of the piston. In the second, I will learn how to move the piston, putting a moving condition to the bottom wall of the geometry.
I always like to start with simplified examples, full of assumptions, and then refine all of them until I get the knowledge to solve the desired problem.
Hence to simulate the movement of the valves, I thought that would be a good start, to divide the problem in 3 instants and to make a mesh for each one. The first mesh will represent the intake of the air, with the intake valve fully opened and the exhaust valve fully closed with a total simulation time of a quarter of time of one engine rotation. The second mesh will represent the state when the cylinder is fully closed (the domain will turn to only a cylinder), with a simulation time of one half of rotation. And the third will represent the exhaust of the air, with the intake fully closed and the exhaust fully opened.
So I thought to solve this problem in CFX by creating configurations to allow a complete remesh from one instant to another. So the problem would start with the first mesh (intake) with a constant mass flow at the inlet until 1/4 of time, then change to second mesh (fully closed) for more 1/2 of time and, finally, change to the third mesh (exhaust) until the end of the simulation.
The question that came to my mind is: is that possible since at the beginning I don't have the exhaust mesh to create an outlet boundary condition for the exhaust of the air?
I don't know if I explained my point clear enough, so if not, please just tell me.

Mateus Dias Ribeiro

ghorrocks September 17, 2013 19:07

There are a number of ways to model poppet valves. Some ideas:

* Model the valve motion and use remeshing. You also then fully close the valve as one of your remeshing steps involves removing the mesh in the valve curtain which disconnects the manifold to the cylinder. Usually this approach models the valve motion until the valve is almost shut, then you jump to fully shut. There is no point in modelling very fine valve openings when there is no flow anyway.
* Stop the valve motion just before it shuts and then use a source term to stop flow in the valve curtain area. This has the advantage that you do not have to do the jump to a fully closed valve, but the disadvantage that your valves never fully shut.

You comment seems to suggest you are not modelling the manifolds - most IC engine models will require the manifolds to get the pressures right. If you have some strange sort of IC engine with no manifold pressure variation you can model the valves as inlets and outlets and that will be mush easier than what I described above - but very inaccurate for most applications.

And my PhD thesis was using CFX (the old version, CFX4) to model an IC engine. You may find it useful -

mateusdias89 September 18, 2013 08:20


thank you very much for the answer and for your thesis. I will read it carefully.
And yes, I am not modelling the entire manifold, but only parts of the inlet and outlet pipes. I know it would be necessary to model the entire manifold, so it is more reliable and accurate but I am still learning how to use CFX and ICEM to this kind of application and just started to learn about moving mesh. I hope that giving small steps I will be able to finish this master thesis until the end of next year, as suposed... :)
I will try the first idea you gave and come back to tell what happened.

Best Regards,

mateusdias89 September 23, 2013 15:33

Hi again,

I tried to do some simulations of the intake (domain with only the intake pipe and valve) and model the valve motion tracking the valve position and using remesh. After the second displacement of the valve in the upward direction and remesh, I got the error: "Error interpolating results onto new mesh". After a quick search on the forum and on internet, I thought that I have run out of memory. However, after allocating more memory for the interpolator and even coarsening the mesh and still getting the same error, I realized that it may no be the reason. Here is the error message:

+================================================= ===================+
| ****** PROBLEM REPORT ****** |
| Subsystem: Input and Output |
| Subroutine name: ErrAction |
| Severity level: Fatal Error |
| Error message number: 001100279 |
| Message: |
| |
| REDHDR: locating dataset failed: what=G/NAMEMAP where=EVERY |
| |
| |
| |
| |
| |
+================================================= ===================+
WARNING: CFXSTP, Regression check error.

| An error has occurred in cfx5solve: |
| |
| Error interpolating results onto the new mesh: C:\Program |
| Files\ANSYS Inc\v145\CFX\bin\winnt-amd64\solver-pcmpi.exe exited |
| with return code 1. |

Is it really because I have run out of memory or someone has another guess?


ghorrocks September 23, 2013 18:45

I would develop the mesh motion+remeshing algorithm on a simple model which you can run in a few minutes and debug quickly, not an engine model. So get this working on a simple version first before using it on a complex engine model.

mateusdias89 September 24, 2013 16:28

2 Attachment(s)
Hi, thank you again.

I followed your advice and tried now to model only the valve motion, as seen in the picture. I set two opening boundary conditions, so air can enter or leave the domain as needed. At the beginning, the clearance distance from the bottom surface of the valve to the top surface is 5 mm and then it starts closing as stated by the motion expression. I attached also the ccl of the run, where I defined two cel expressions (One for the motion and the other for the remesh condition). After creating the configuration and setting the remesh using the option "ICEM Remesh Replay" I still get the same error after two moves of the valve upward (or a displacement of 2mm) when the first remesh takes place. So I opened the results directory and looked at the file "2_remesh" and found this in the end of the text, after the remesh script:
Batch run of "C:\Users\MAURICIO\Mateus Dias\Valvemotion\Valve7_004.dir\meshUpdate.pre" failed due to the following errors:

-- ERROR --
The location of boundary "BOTTOM" is invalid:
Region "BOTTOM" is not recognised.

The location of boundary "INLET" is invalid:
Region "INLET" is not recognised.

The location of boundary "INLET WALL" is invalid:
Region "INLET_WALL" is not recognised.

The location of boundary "INTAKE" is invalid:
Region "INTAKE" is not recognised.

The location of boundary "SYMMETRY" is invalid:
Region "SYMMETRY" is not recognised.

The location of boundary "TOP" is invalid:
Region "TOP" is not recognised.

The location of boundary "WALL" is invalid:
Region "WALL" is not recognised.

Since this message appeared after the script of the ICEM replay file, it seems that after doing the remesh, the solver was not able to find the named boundaries and hence the interpolation failed. But this is strange because I followed exactly the same steps to create the replay file as for this tutorial, but however the latter worked fine. Has someone any idea of what is going on or had similar issue?


ghorrocks September 24, 2013 18:24

I am not familiar with ICE remeshing so cannot help you - but obviously I would check the naming of boundary objects from ICEM, pre and boundary conditions to check the names are correct.

mateusdias89 September 25, 2013 15:12

Hi Ghorrocks,
thank you for the clever tips.

I checked the named boundaries again but it was ok, so I changed my strategy. Instead of tracking the position of the valve and remeshing while running the solution, I made many different meshes at different positions and called everyone of them at the respective time step. This is not clever at all, actually, and it is of course more painful but it worked. Besides I can see how the mesh looks like at every time step, since that I must make all the mesh procediments.
I will work now on the improvement of this algorithm and then try an engine model.


ghorrocks September 25, 2013 18:33

This approach is quite workable. It means you get a chance to custom make each mesh to each valve lift. This means you are likely to get better mesh quality than when you script it as the script is unlikely to be optimal for all lifts.

So if this approach works and is practical then it is perfectly acceptable and I would stick with it.

mateusdias89 October 2, 2013 10:37


I tried to implement my moving mesh algorithm to the valves in an engine model where only the valves move and the piston is at BDC. So I forced a mass flow at the inlet, with the intake valve fully opened and the exhaust valve fully shut at the beginning. The total time of simulation was defined as 0.02s and the time-step as 10^-4s. After 1/4 of time the intake valve starts to close, the mass flow at the inlet is interrupted and the cylinder remains fully closed for 1/2 of time and then the exhaust valve starts to open and remains open until the end. I am facing problems when some of the valves fully shuts, because I get two regions of fluid separated. If I create only one domain for the initial configuration (intake valve opened and exhaust valve shut) in CFX-Pre, I can change an expert parameter, so that the solver allows two disconnected regions in the same domain and the solution runs. However, the instability of the solution is very high and I get overflow error after a few time-steps. If I create two domains for the initial configuration, I get good stability for the solution but I get an interpolation error when the intake valve fully shuts, because the disconnection of the geometry creates 2D regions that may be created automatically as boundary condition in two different domains at the remesh instant (that would not happen using only one domain). So, as you can see, I have only one alternative left, that is not to close the valves completely and create a source term to stop the flow in the valve curtain area. I took a look on the cfx-modelling guide to learn how to do it and the problem now is that I have to create a subdomain to define a source term. However, I can't create these subdomain because in CFX-Pre I have only the mesh of the initial instant but I need to use the source term over the curtain area of the valve in a future instant, when the intake and/or exhaust valve is almost shut. Was I clear enough?
So I would like to know if there is any other way to create this source term, by using cel or fortran routines. So that the term is used only at defined instants. Is that possible?
My question is basically this: Can I create an expression of the kind: if(Time>t0 && Time<t1, massflow@curtain area = 0 [g/s], normal flow)


ghorrocks October 2, 2013 17:59

You have two options:
1) Generate a new mesh with a mesh volume defined in the valve curtain. Then you apply the source subdomain to this curtain volume.
2) Have a interface in the valve curtain. Interfaces allow you to conditionally switch them on and off. But you will probably have to generate a new mesh for this approach as well as you need the interface surface.

I think you are asking the wrong question in your final sentence. The normal source term can easily handle being turned on and off versus time with simple CEL functions so there is no need for fortran. I think your problem is that you need a mesh object in the valve curtain so the solver knows what region to apply the source term to - that will require a new mesh with this region defined.

mateusdias89 October 8, 2013 13:26

1 Attachment(s)
Hi, thank you again!
I am trying the second option and I'm in doubt in how to switch the interface on and off. I created a simple example of a small cylinder in one domain connected to another in other domain, in which both are separated by a valve. The two domains are separated by a region called INTER, which represents the valve curtain area. Then I created a Fluid-Fluid Interface on this region and double clicked on the Interface Icon, that appeared in the Outline-Tree. Clicking on the Additional Interface Models Tab, I can change the Mass and Momentum Option from "Conservative Interface Flux", which connects the two domains and allows fluid to pass to "No Slip Wall" and "Free Slip Wall" condition, which makes the interface to behave as a wall and hence allows no flow across the interface. There is also the option "Side Dependent". It seems to me that to switch the interface from on to off, I would have to switch this option from "Conservative Interface Flux" to a "Wall" condition. However, this can't unfortunately be made by a transient CEL expression, since I choose this options from a drop-down menu. Is there any other way of doing this?

Besides, if I try to apply a boundary source to the valve curtain, I can define a mass flow by CEL expression but I have no idea of what values or expressions should I use as input in the Turbulence Eddy Dissipation and Turbulence Kinetic Energy fields.

I attached an image for better understanding.


Ps.: And just to be sure if I got your last answer right. When you say to create a source term, do you mean to create a Boundary Source in the Continuity Equation of the Interface boundary and impose the mass flow across it?

ghorrocks October 8, 2013 17:57

I am talking about the conditional connection control option on the interface. This is a new option in CFX. What version of CFX are you using?

You can either apply the source term as a boundary source on the interface (but if you have an interface I would not bother as it is easier to just use the conditional connection control) or on a mesh volume define as the valve curtain.

mateusdias89 October 9, 2013 10:43

As Murphy says: if something can go wrong it will...
I normally use a computer with Ansys 14.5 Academic, which has this option. Yesterday I spent the whole day searching for this option in a computer with Ansys 13, which does not have this option. :)
Thank you again.

alinik April 10, 2014 19:25


I have the same issue with CFX not being able to find the corresponding boundaries of ICEM remeshed model in CFX. In error log it says some boudaries(the moving ones) are invalid.
Were you able to solve that? or you just chose the hard way to do the simulation?


mateusdias89 April 11, 2014 03:26

Hi alinik,

the main problem is that when the valves fully shut some parts of the geometry change and are automatically renamed. So CFX can not address the boundary conditions defined at CFX-Pre to these new renamed geometries since you can't change the boundary conditions during the solution or if it is possible I don't know how.

So yes, I just chose the hard way to do the simulation. Which is doing a mesh for different instants of opening/close of the valves. I created only one fluid domain so I don't need to switch an interface off and the valves can be fully closed. But you can not change names of regions attached to boundary conditions before or after geometry changes (like fully closing of valves), otherwise CFX will create an error telling that the boundary is invalid. So be careful at naming your moving/changeable boundary regions, it is some times not a problem to change it's form since the names remain the same and the physics at these boundary don't change too much.


visitor May 19, 2014 00:01

Co-authoring a paper.
Dear Ghorock

Your message dated September 17, 2013 .

I am in the process of writing a technical paper for publishing.

Would you be interested in a joint paper, using your numerical model? Please let me know if this is acceptable.


ghorrocks May 19, 2014 00:07

I do not have much time available for preparing papers so I will have to decline. My PhD thesis is available at if that is of any interest. And feel free to post questions on the forum if you want help.

visitor May 19, 2014 02:59

Co-authorship paper peparation
Dear Ghorock

What I actually meant is that I will do the write-up, and the simulation.

Just thought if I can use an existing model, I can save time and focus on analysis. With the usual thanking in the acknowledgement section of paper.

But thanks anyway, will start from scratch, with the help of manuals/tutorials.


MaBe August 26, 2015 05:50

I'm having the same issue (also with ICE-Remeshing).
Did anybody solve this problem? This would save me a plenty of time.

Otherwise I'll try different things on my own. For me it looks like the new mesh is not getting back to CFX. What do you think?

All times are GMT -4. The time now is 17:51.