Buckaroo's Flightgear Projects

Simulation of Piston Engine Fuel Consumption and Engine Temperature using YASim

By Gary "Buckaroo" Neely


Flighgear's YASim piston engine simulation does a good job of addressing power, but it gives mediocre results for fuel consumption and no usable results for EGT and CHT. YASim's fuel consumption is typically higher than expected. Scaling fuel results can give passable low-fidelity values for some aircraft, but the engine temperature values are not usable. YASim also gives idle manifold pressures that are much too low, yielding mixtures way too rich to burn. These problems make it difficult to simulate many practical piloting procedures.

To be fair, it may be unreasonable to expect YASim to give good results for these numbers. Many factors contribute to engine performance and YASim can't provide a good simulation given the few parameters currently allowed. That still leaves a flight simulation problem, because pilot decisions rely on having an idea of engine condition. For most general aviation aircraft it's reasonable to expect good fuel flow and engine temperature values so the pilot can practise fundamental flight procedures.


The Goal: Reasonable Fuel Consumption and Engine Temperature Values

I had to find a solution for these problems. I decided to develop some data structures and scripting that would supplement or replace the YASim values. In developing this system, these were my goals:

While investigating these objectives, I quickly learned that I didn't know much about engines. I knew the basics: air and fuel go in, get mixed together, are burned to push pistons around, and then get flushed out to make room for the next cycle, with the whole process producing power and lots of heat that must be removed somehow. I also knew that as altitude increases you have less air to play with. These basics didn't get me very far. I spent a lot of time reading about how aircraft pistion engines work, especially the normally-aspirated kind (no turbos or superchargers). Most sources gloss-over details, leaving more questions than answers. One resource stood out, John Deakin and his Pelican's Perch articles:

http://www.avweb.com/news/pelican/182146-1.html

I readily understood John's topics even though I'm not a pilot. He writes simply, clearly, and with the background of a highly experienced pilot. John's articles gave me most of what I needed to know to put together all the concepts together.

I decided not to fix what isn't broken. YASim does a lot of things right or close enough. My project focus was fuel and temperatures and not much else. These things can be simulated outside of the YASim FDM, which means I didn't have to learn C++ or lobby others to add stuff to YASim that would probably break someone else's plane. The job could be done with Nasal scripting.

I wanted to model EGT and CHT in a way that let me plug in tabular numbers rather than do elaborate engineering calculations and hope the numbers come out in my favor. For my first attempts I tried to map EGT and CHT to power levels and BSFC (Brake Specific Fuel Consumption-- the amount of fuel required to produce one horsepower for one hour). Charts showing these relationships are fairly common for many engines. The trouble was that I could not find relationships that tied everything together. I'd sorta start getting close, then it would slip away. That's when I read the Pelican's Perch articles and learned that before I could understand engines I needed a solid understanding of mixtures.


Understanding Fuel-Air Mixture Ratios

The burning mix of fuel and air is the heart of the engine. Fuel flow is determined by the ratio of fuel mass to the air mass flowing through the engine. Fortunately air mass isn't hard to calculate. YASim provides usable power settings: throttle, torque, and manifold pressure, but its mixture value isn't exposed and isn't optimal anyway. YASim's manifold pressure requires a little fudging, but it's usable. More on that later. Mixture was the pesky missing ingredient.

YASim itself incorporates mixture into its piston engine calculations, but the methods used are muddled, non-modular, and integrated messily with other calculations. Many useful values aren't exposed and can't be tweaked. It would have been relatively simple to do in YASim what I'm doing here. I've yet to try to compile YASim, and I don't want to do something that might break the performance of other people's planes, so my focus remains on external scripted solutions.

Mixture is the combining of air and fuel in a ratio that allows the whole mess to burn and produce power. The useful mixture range is actually fairly narrow. Fuel burns completely at a stoichiometric ratio of 14.7 parts air to 1 part fuel, which can be written as 14.7:1 (air-fuel ratio, weight of air to weight of fuel) or 0.068 (fuel-air ratio, weight of fuel/weight of air). You get best power at about 12.5:1 (0.08), best economy around 16:1 (0.0625). Full rich mixtures can approach 10:1 (0.1) at sea level. Mixtures as lean as 25:1 (0.04) or as rich as 5.56:1 (0.18) won't burn at all. The practical mixture range for engines is 20:1 (0.05) to 8:1 (0.125).

For the rest of this discussion I'll abbreviate the mixture ratio as AFR even though I may actually be using the decimal fuel/air values rather than air:fuel ratios. Using AFR avoids confusion with the red-knob mixture control.

Optimal mixture settings for carburetors and injection systems are factory-set and adjusted by engine maintenance mechanics. A simulation needs to start somewhere, so let's assume a full-rich, wide-open-throttle (WOT) base configuration and assign this an AFR of 11.76:1 (0.085). In practice, a full-rich, WOT mixture is often richer than the base configuration. We'll see why in a moment.

AFR can be changed in flight by a number of mechanisms:

There are other possibilities, but these are the common ones. Let's look at each one in detail.

Boost pumps - Many boost pump scenarios will enrichen the mixture of injected engines due to higher fuel pressure. The pump increases fuel inlet pressure, so we should apply any boost-pump adjustments before other calculations.

Many radial engines around the time of WW II had a mixture device that replaced the manual mixture control with pre-set positions like: AUTO RICH, AUTO LEAN, IDLE CUT-OFF. These devices operated using a pressure-differential mechanism that monitored air passing through the venturi and air bypassing the venturi. As airflow increased, the pressure difference increased, displacing a diaphram which in turn operated a valve to introduce more fuel into the air mass according to a pre-calibrated positions.

Despite the "LEAN" nomenclature, these settings usually operated in the ROP realm. AUTO RICH was usually slightly rich of best-power for the engine, probably just over 0.08 AFR. AUTO LEAN was slightly rich of peak EGT. AUTO LEAN would place the AFR close to the realm of peak cylinder temps, but it was not employed unless the engine is operating below the max cruise limits recommended in the flight manual, so the engine is operating well under full power and has a nice stream of cool air to keep cylinder temps well down.

Automatic Mixture Control (AMC) - To understand what an Automatic Mixture Control does, we need to first understand that air density decreases as altitude and/or air temperature rise. So as air density decreases, the proportion of fuel to air increases. The effect on AFR becomes:

AFR = AFR * air density at SL / ambient air density

As ambient air density decreases, the air to fuel ratio gets smaller-- the mixture richens and the pilot compensates by pulling out the red mixture control. Keep in mind that I'm using the decimal fuel/air value as "AFR".

Auto-mixture devices maintain a desired AFR for air density and temperature conditions by means of a pressure-differential mechanism. If we assume that the device is working perfectly, an AMC simplifies the simulation. We don't have to do many calculations, we just assume AFR remains constant and the pilot never has to touch the mixture knob to compensate for altitude. But most general aviation piston engines won't have an AMC-- as air density falls, the pilot has to compensate manually.

Manual Mixture Control - Next comes the most important adjustment to AFR, the pilot's manual mixture control. This is usually just a valve on the main metered fuel jet, closing the jet as the control is moved toward lean settings.

Auto-Enrichment - Many engines have an auto-enrich feature that kicks in extra fuel at higher power settings. This helps keep the engine cool and aids in preventing detonation. For example, when pushing the throttle 2/3 in, a valve may begin to open, adding extra fuel. At WOT the valve is fully open, adding the maximum amount of extra fuel. This is all done automatically. The auto-enrich fuel jet is usually in parallel with the regular metered jet, so it is not affected by the mixture control. In many installations, the auto-enrichment mechanism is operated via the same linkage that controls the low-speed idle and idle-cutoff valves.

Since auto-enrichment and fuel boost pumps can inject a considerable amount of extra fuel in the mixture, WOT power settings may be significantly richer than the base AFR setting.

The four AFR modifiers are applied sequentially using the following order and conditions:

If using a boost pump:
   AFR = AFR + some boost pump value
If not using AMC:
   AFR = AFR * air density at SL / ambient air density
Mixture control adjustment:
   AFR = AFR * mixture setting, where the setting ranges from 0 (idle cutoff) to 1 (full rich)
If using auto-enrichment:
   AFR = AFR + some gain based on throttle position

When everything is added together, we finally have a mixture value. This gets us much closer to the goal of delivering realistic fuel flow and temperature numbers.

For a good article on mixture, check out:

http://www.aviationpros.com/article/10387634/mixed-up-about-fuel-mixtures

Fuel Flow

If we know the air-fuel ratio, then calculating fuel flow is fairly simple. It's a matter of knowing how much air we're ingesting and multiplying by the AFR to get the quantity of fuel required.

We need to calculate how much air mass is moving through the engine. To do that, we need to know altitude and ambient temperature for calculating air density, manifold pressure for how open the engine is for taking in air, RPM and engine displacement for how much air mass the engine can theoretically handle, and volumetric efficiency (VE), a practical adjustment to the theoretical value for how much air mass the engine can handle. No problem, right? With a little research, it's actually not too hard.

To find how much air mass we're moving at any given time, we need to know what volume the engine can theoretically move per second:

volume = (Displacment * RPM / 60 seconds) / 2

The 2 comes from 1 intake per 2 revolutions. This simplifies to:

volume = displacement * RPM / 120

We also need the air density. This can be found by:

air density = absolute pressure (Pa) / (specific gas constant * absolute temperature (K))

Using manifold pressure in inHg for pressure, a temperature in Celsius, and wanting an output in kg/m^3, this translates to:

air density = inHg * 3386.3886 / (287.058 * (273.15 + tempC))

So our air mass is starting to look like:

mass = volume * air density

But this is theoretical. In reality the engine is likely not moving this volume of air. Most are moving less due to inefficiencies in the intake path, valves, ports, and exhaust path. Some highly-tuned engines actually move more than theoretical. The actual quantity of air moved compared to the theoretical quantity is the volumetric efficiency, VE. VE can be calculated if you know RPM, displacement, BSFC and HP. VE tends to vary somewhat with RPM, but I chose to use a single fixed value for simplicity, because the actual ranges are hard to find. For a good discussion on volumetric efficiency, see:

http://www.epi-eng.com/piston_engine_technology/volumetric_efficiency.htm

OK, so air mass becomes:

mass = volume * air density * volumetric efficiency

Now that we know the air mass and we have previously determined the AFR, we can calculate fuel flow:

fuel flow (in kg/s) = mass * AFR

Pretty simple. If we are moving an air mass of 0.178 kg/m^3 and are using an AFR of 0.085, then we're moving fuel at the rate of 0.01513 kg/s, about 20 gallons/hr. (kg/s * 1318.39 = gal/hr)

So fuel flow in gallons per hour is:

fuel flow (gal/hr) = mass * AFR * 1318.39

The trick to good fuel flow values is knowing what numbers you want for the real engine and assigning a good base AFR value along with adjustment factors that give you those numbers. With common engines, you may be able to find those values from manuals and plug them in. With others you'll have to guess, but with good fuel-flow or BSFC tables for various power settings, the guess-work is minimized.

In my effort, the main controls for getting good values are the settings for base AFR and AFR adjustments (boost pump, auto-enrichment, if any), and selecting a reasonable volumetric efficiency. Optionally you could also filter fuel flow output through an interpolation table to modify the results according to some other parameter.

With this new and better value for fuel flow, we simply throw out the original FDM (YASim in this case) fuel-fuel value. The fuel system for our aircraft needs to be modified slightly to use this calculated value rather than YASim's value, but that's trivial and not discussed here.


More Thoughts:

Combustion efficiency - We really only care about the fact that an injector or a carburetor is metering fuel according to its configuration. Combustion efficiency is accounted for in the YASim power algorithms. Here we only care how much fuel is being consumed, regardless of its efficient use.

Single-Magneto Operation - In addition to redundancy, two magnetos (and two sparkplugs) are used to provide a more complete and therefore more efficient fuel burn. Operating with a single magneto causes an approximate 3% loss of power, and the engine runs slightly hotter due to prolonged fuel burning. This can also lead to detonation. Because this fuel flow simulation is factored by RPM, and a drop in RPM will occur when there is a drop in power due to YASim's single-magneto effects, this situation needs little further adjustment unless the developer wants to fine-tune the effect. Since you would not normally fly under a single magneto, the simulation benefit is very minor.


EGT and CHT

In a typical general aviation piston engine, cylinder head temperatures (CHT) are at their hottest when the mixture is approximately 50 degrees rich of peak (ROP) exhaust gas temperature (EGT), using values in Fahrenheit. Max power occurs between 50 and 100 degrees ROP. Numbers closer to 50 yield better economy at the expense of a slight CHT rise. Best economy occurs around 50 degrees lean of peak (LOP). As always when I write about this stuff, these numbers are for illustration only. Actual numbers vary considerably between engine models and even with individual engines of the same model. The main point is that engine temperatures are closely linked with the air-fuel mixture.

The goal here is to use tables to map maximum power EGT and CHT to AFR. By using AFR as the table index and scaling the result by actual power output, we can get pretty close to realistic numbers. If done right, the aircraft developer could populate the tables with actual values for a real engine. All that remains is to define a relationship between these values and the FDM (YASim) output.

Here's a configuration that maps AFR ranges to EGT and CHT values. Intermediate results are interpolated.

AFR EGT CHT  
0.0400 1000 250 lean burn limit
0.0500 1000 250 lean power limit
0.0625 1450 345 best economy
0.0712 1500 433 peak EGT
0.0756 1450 450 peak CHT
0.0800 1420 440 best power
0.0870 1350 375  
0.1000 1250 355 WOT, full rich
0.1250 1250 350 rich power limit
0.1800 1250 350 rich burn limit

So as long as we know where AFR is, we can pull out an expected value for EGT and CHT.

These values assume maximum power settings: WOT and max RPM prop position. But power settings will often not be maximum, so we need to adjust for power. An easy way to do this is to find the minimum temperature that approxmimates the leanest power setting that is reasonable, and interpolate a new value from this low value to the maximum power temperature based on current horse power output.

Horse power is not hard to estimate. Using standard equations for such things, we can factor RPM and torque to find horse power:

HP = RPM * torque / 5252

With that value we can form a ratio to a known maximum HP value and can get a temperature within the range:

EGT = HP/HP_max * (EGT_table - EGT_min) + EGT_min

Using values from the table above, let's say we're operating at a best economy mixture setting and a power setting at about 60%. The minimum practical operating temperature for EGT is given here as 1000 degrees F, the lean burn limit. Maximum power EGT temperature for best economy is 1450 degrees F. So we want to find a number that is 60% between 1000 and 1450, giving 1270 F.

Remember that these are just practical estimates, good enough for judging engine performace in flight. This method isn't trying to give laboratory results. The goal is to create a system where you can plug in whatever values you like, using real data from an engine monitor if available.

This works pretty well for EGT where temperature changes are almost instantaneous. For CHT we have to do more work, since cylinder temperatures change much more slowly. For the CHTs, the calculated temperatures become target values for CHT to seek. The actual CHT temps change slowly according to other factors, and may eventually rise or fall to the target temperature. More on that later.

For radial engines we can stop here and assume all cylinders exhibit approximately the same EGT and CHT. We can do this cheat because radial engines have very little variance in fuel distribution to each cylinder. In-line engines are less fortunate, as fuel distribution to the cylinders is less uniform. This is where the value of GAMI injectors comes in, where each injector is custom tuned to the needs of each cylinder. It's also the value of an engine monitoring system that shows the CHT and EGT values of each cylinder, so the pilot has a good idea what the engine is doing and can set LOP or ROP mixture and power appropriately with risking engine wear or damage.

What if we're using an in-line engine? Temperatures will vary with each cylinder. We could set up a system that pre-randomizes variances to each cylinder, but I prefer to use preset variances. So here's another data table that does just that:

Cylinder Variance
1 1.030
2 1.010
3 0.990
4 1.000
5 0.970
6 0.986

The variance is nothing more than a multiplier for the EGT and CHT temperature for that cylinder. In this example, cylinder #1 runs 3% hotter, and cylinder #4 does not vary at all. For a slightly more complex version we could create separate columns for EGT and CHT. But this works well enough for my purposes.


Aligning Results With YASim

YASim doesn't know anything about our numbers for AFR, EGT and CHT. Without help, any relationship between our numbers and YASim's best power and best economy mixture settings would be coincidental. We need maximum power to occur at about 80 degrees rich of peak (ROP), and best economy at about 50 degrees lean of peak (LOP). We need CHTs to be at their hottest when running about 50 degrees ROP. The trick is to find a way to align YASim results with our desired results.

Our only ties with YASim are mixture, RPM and torque. RPM and torque aren't problematic, but mixture is. YASim's mixture setting is linear with the mixture control, and if we were to use it, our low-end lean settings would be too lean to burn. In addition, YASim's mixture isn't aligned with my calculated AFR values. The problem can be addressed by re-mapping YASim mixture control positions to new values that yield the proper AFR to index into our temperature tables. Correcting for YASim's mixture control property aligns my scheme to YASim's power settings and corrects for YASim's linear mixture effects.

I generated a table for re-mapping mixture settings by flying at altitude intervals of 1000' starting at just above sea level, noting the YASim mixture control setting that yielded best-power (thrust) at each flight level, and pairing these with calculated (optimal) values assuming a best-power AFR of 0.8 (the high-end of theoretical best-power). For normally-aspirated engines the numbers give reasonable results up to 12,000 feet. A sample of results looks like this:

	Best-power mixture control value:
	YASim		Theoretical
	0.64		0.710
	0.65		0.730
	0.70		0.800
	0.77		0.880

I interpolate to get other values. So when you move the red-knobbed mixture control to a value of 0.70, the value that is actually used to affect AFR will be 0.8. You can view the value of Flightgear mixture setting under the property: /controls/engines/engine[i]/mixture where i is the selected engine, 0 in the case of single-engine planes.


Removing Heat

Engine temperatures are primarily dependent on mixture, power settings, and the engine's ability to remove heat. Frankly this is as far as I've gotten with engine simulation. For heat removal I have a number of cheats in place. They are rather lame, but they get the job done for now.

I'm interested in giving the pilot reasonable numbers that can be expected at given mixture and power ranges. Calculating the airflow over the engine, the surface area of the engine, heat transfer properties, oil's capacity to remove heat, the cooling effects of rich mixture, etc., are beyond what I can do and the various numbers are not generally available unless you designed the real engine. What's important is what the pilot sees.

As I tweak the simulation to deal with heat removal, I'll update this document.