# Simpliest way to simulate an IC engine

1. May 1, 2010

### Jonne

Hi Guys,

I would like to write some software to teach people to tune internal combustion engines. More specifically, as some of you may know, an engine is controlled by two 2D grids or 'maps' which have engine load on one axis and engine RMP on the other. One map tells the engine how early to fire the spark plug, the other tells it how much fuel to inject.

I am just wondering what the simplest physics model I can use that will simulate this and give me realistic results?

I am not looking to allow people to test different engine designs, just see the results of changing values in the maps. For example, adding more fuel may lose torque but would allow for more ignition timing (due to mixture being less prone to http://en.wikipedia.org/wiki/Engine_knocking" [Broken]) which would then increase torque.

So, is this possible without having to learn computational fluid dynamics?

Sorry if this is a silly question, I have don't any physics past GCSE level but I'm always willing to learn.

Last edited by a moderator: May 4, 2017
2. May 1, 2010

### Jonne

In fact, I can make my question a lot more specific..

Given these variables :-

1. Number of gasoline molecules
2. Number of oxygen molecules
3. Cylinder volume
4. Compression ratio

Is it possible to estimate the following outputs :-
1. Pressure on the crank shaft for each increment of rotation
2. Number of left over fuel and air molecules

If so, how?

Thanks

3. May 2, 2010

### Jonne

Doesn't anyone have any idea? Even if someone could just tell me which division of Physics I should study, I'd be grateful.

4. May 2, 2010

### jack action

No.

Even knowing that wouldn't be enough. There's heat transfer, you also need a combustion model and all the electrical notions for the spark plug to work under different fuel distributions, high pressure and high temperature.

5. May 3, 2010

### xxChrisxx

You don't need CFD to do this. Combustion models are far too hard to make yourself and you dont need to know the flow in the cylinder. Maps are generally made by practical testing on a dyno.

Wiebe combustion model is used in lotus engine simulation, Ricardo WAVE etc etc.

Get an engine book.
Heywood - Internal combustion engine fundamentals is a good technical book. (very very technical)
Richard Stone - intro to internal combustion eniges is a better book for starting out.

either will set you back about 30-50 quid on amazon.
Also what do you acutally want to achieve from this 'simulation'?

Last edited: May 3, 2010
6. May 3, 2010

### jack action

Practical testing kind of make useless the purpose of simulation.

The simplest combustion model I've seen for simulating (realistically) the outputs (power, exhaust gas characteristics, etc) of an engine assumes that combustion happens at the right time. Meaning that timing advance is appropriate, no matter what it is. The reason is that once the spark plug ignites, there is a delay before the combustion actually starts. Even assuming the same AFR, CR, RPM, etc. that delay still vary a bunch from engine to engine.

As for AFR variations, it was assumed that the combustion efficiency (amount of mixture actually burnt) varies with AFR. There was still another efficiency that varied (if my memory don't fail me) from 85% to 90% to take into account the particular design of each engine (ex.: "quenched spot" where the fuel could not burn due to too much cooling or spots where too much exhaust gas was present, etc.). That last one had to be purely a guess from the part of the programmer.

And just to know how much exhaust gas will stay in the combustion chamber (not even talking about how well it will mix with the fresh mixture), you need at least some CFD of the entire valvetrain, intake and exhaust systems design.

That is with a simple combustion model where all the mixture burns at the same time. To do what you want to do, and I'm no expert on this, you would at least need a model with multiple stage combustion chamber (i.e. the combustion chamber is divided into smaller ones such that you can follow the flames propagation from the spark plug).

7. May 3, 2010

### xxChrisxx

If he's looking to acutally use this to remap something, then everything you said is totally insufficient for purpose. You can't just 'assume' things if a map is going to be implemented. That's how engines grenade themselves.

Also none of what you said above is in any way simple to model correctly.

However if this is just a mental type excercise, or to get a power/torque output figure, then you can obviously have some leeway on how stringent the model is.

YOU DONT NEED CFD TO DO THIS. It's is in no way necessary, both Ricardo WAVE and LES requires geometry but does not do a full CFD model. I can gaurantee you that, as even with pressure wave exhaust tuning, you don't need a CFD model. The model doesn't require knowing what the fluid is acutally doing, only when pressure waves will arrive at the valves. I remember that WAVE does have an option for combustion chamber and valve design that uses CFD/

Fact is, if he's trying to do what I think he's doing then a simulation will be very little help even if he does do one.

Also note that he only had GCSE physics, telling him to model the full intake and exhaust for CFD isn't helpful as he will have niether the knowledge or the necessary software. Not if what he wants to achieve can be done more easily.

Last edited: May 3, 2010
8. May 3, 2010

### jack action

That's the point of my last post: The simplest methods i know to find

1. Pressure on the crank shaft for each increment of rotation
2. Number of left over fuel and air molecules

assumes an already appropriate timing and AFR. Hence, they won't work for his purpose.

Again, my point exactly. I recall the initial question: I am just wondering what the simplest physics model I can use that will simulate this and give me realistic results?

It is not. He wants to know how to estimate mathematically the effects of changing timing and AFR on power, pre-ignition or others.

I don't know what you think he's trying to do, but for WHAT HE'S REALLY TRYING TO DO, a SIMPLIFIED simulation will be very little help even if he does do one.

... One map tells the engine how early to fire the spark plug, the other tells it how much fuel to inject. I am just wondering what the simplest physics model I can use that will simulate this ... just see the results of changing values in the maps.

So, is this possible without having to learn computational fluid dynamics?

Even if someone could just tell me which division of Physics I should study

For these questions, my answer is that the simplest computational model would be a very complicated one. Unless somebody has another answer, then I would learn something new today.

Given these variables :-
Number of gasoline molecules
Number of oxygen molecules
Cylinder volume
Compression ratio

Is it possible to estimate the following outputs :-
Pressure on the crank shaft for each increment of rotation
Number of left over fuel and air molecules

If so, how?

For this question, although the simplest model will give you some info based on AFR variations, the timing can only be based on assumptions, which defy the purpose of his program since this means that he already knows what the effects of timing are. And, again, if you want to incorporate the effects of timing, it would have to be a very complicated model.

9. May 3, 2010

### Jonne

Many thanks for all the comments, they are greatly appreciated.

Just to clarify, I am not looking to write software to substitute any kind of physical testing. As I'm sure you know, after market engine tuning can be a tricky and potentially dangerous task. I am just looking to provide a sandbox to allow people to change parameters in the ECU and see the results and become au fait with the tuning process before trying anything on their own car. My aim is purely to write something that can help people learn in a safe environment. I'm quite happy make use of pre-calculated lookup tables to simplify the model if required.

There has been a few models mentioned above which I will investigate fully. I will also check out the recommended books although I do feel its my knowledge of physics that is letting me down at this time rather than of the IC engine.

Just thinking again about my comment above about calculating torque at a given increment of the crank shaft, I don't believe this is necessary but I would need calculate/estimate overall torque and detect a condition where pre-ignition and/or denomination may occur.

I would be grateful of any further thoughts.

Jon

10. May 3, 2010

### xxChrisxx

To be honest, writing your own is a massive undertaking (given that you have limited knowledge of the physics and model writing experience). I have spent quite a bit of time writing engine simulation (and other) models, and I don't really know where to start with all the variables.

I have a friend that does maps (he builds megasquirt ecu's), and used LES to do design a custom exhaust system and cam timing, I'll have a chat with him and see what he says. I'll also have a look around the web and read up on the papers done with the model you want.

I do have an idea as to what you could do, as we can use a simulation similar to this
http://www.engr.colostate.edu/~allan/thermo/page6/page6.html

The problem is incorporating all the other map variables into something similar to make a single 'combustion input'. You can also use the pressure and work graphs as an input to get a torque output. I have a numerical model that will do this (providing you know the reciprocating masses).

EDIT: Infact that model and applet incorporates quite a few of the variables you describe. The only problem is that it doesn't really accurately describe what happens if you bugger up the map. eg, over lean the mixture

Last edited: May 3, 2010
11. May 3, 2010

### Jonne

Thanks Chris, very useful indeed. As you say, the model you posted seems fulfil most of the requirements. The only thing missing would be the effect of the AFR, knock detection and the composition of the exhaust gas.

I guess you could fill in these gaps with a pre-calculated table of AFR vs Ignition timing which would give you a set of number which represent: the likely hood of knock (although RMP would also have to be taken into account), the effect on torque and the contents of the exhaust gas; Not very scientific but I can't see why I wouldn't give the desired results.

I have to be honest and say that, although the text makes sense, the formulas are way over my head at the moment. I know I need to brush up on maths and this would be a good time to do it. Do you happen to know of any web sites that can help me understand the equations?

Thanks again