Originally Posted by
mbaskett
I dredged this up via search as I was looking for a math equation to calculate MPG, and I started really digging into the previously mentioned calculations and was bothered by having a constant that you may have to manipulate to make your output more accurate. Just seemed wrong to me. Doc Sean posted a good equation that is pretty spot on with static input for fuel weight, but I really felt the need to verify it and also account for those with Flex Fuel capabilities so decided to do some math surrounding just the units of the logged data. If anyone has done this in chemistry, physics or other classes, they know it sucks. Anyways, here's what I came up with. I used the resulting calculation to do a quick spot check logging a drive around town and it seems to be pretty accurate as compared to my truck's output on the dash..
FYI, it does take into account the weights (as posted previously in this thread) of gasoline/ethanol at the varying percentages reported by a flex fuel sensor, but does NOT account for variations in fuel temperature that may affect final true weight per volume. If you don't have a flex fuel sensor, you can just put a constant in the equation for the lb/gal of your fuel.
Gasoline 100% = 6.16 lb/gal
Ethanol 100% = 6.567 lb/gal
Start by taking injector flow rate and pulse width, including a multiplier to reach common units of time and simplify units to just 'lb'
(flow rate(lb/hr) * (pulse width(s) / 3600(s/hr))) = lb
Next, add in number of injector pulses per engine revolution. Assuming a V8 here.
(flow rate(lb/hr) * (pulse width(s) / 3600(s/hr)) * 4(pulse/rev) = lb/rev
Now we bring in the Engine Speed and simplify units.
(flow rate(lb/hr) * (pulse width(s) / 3600(s/hr)) * 4(pulse/rev) * Engine Speed(rev/min)) = lb/min
This adds in the weight per volume calculation of fuel and further simplifies units
(flow rate(lb/hr) * (pulse width(s) / 3600(s/hr)) * 4(pulse/rev) * Engine Speed(rev/min)) / (6.16(lb/gal)-6.16(lb/gal)*Percent Alcohol+6.567(lb/gal)*Percent Alcohol) = gal/min
Now we add a multiplier to covert units to gal/hr so it can align with the vehicle speed sensor units in the next step
(60(min/hr) * (flow rate(lb/hr) * (pulse width(s) / 3600(s/hr)) * 4(pulse/rev) * Engine Speed(rev/min)) / (6.16(lb/gal)-6.16(lb/gal)*Percent Alcohol+6.567(lb/gal)*Percent Alcohol) = gal/hr
Adding in vehicle speed to the equation and simplifying units to the final desired of mile/gal : MPG
Vehicle Speed(mile/hr) / (60(min/hr) * (flow rate(lb/hr) * (pulse width(s) / 3600(s/hr)) * 4(pulse/rev) * Engine Speed(rev/min)) / (6.16(lb/gal)-6.16(lb/gal)*Pct Alc+6.567(lb/gal)*Pct Alc)) = mile/gal
Here I pulled the various multipliers out of the various locations of the equation so we can combine them in the final step
Vehicle Speed(mile/hr) / (60(min/hr)*4(pulse/rev)/3600(s/hr) * (flow rate(lb/hr) * pulse width(s) * Engine Speed(rev/min)) / (6.16(lb/gal)-6.16(lb/gal)*Pct Alc+6.567(lb/gal)*Pct Alc)) = mile/gal
Combined multipliers. This is where my professors would say that your multipliers (constants) may have some really funky units... I know you can simplify them further, but for the sake of this exercise, it's good enough...
Vehicle Speed(mile/hr) / (240(min*pulse/hr*rev)/3600(s/hr) * (flow rate(lb/hr) * pulse width(s) * Engine Speed(rev/min)) / (6.16(lb/gal)-6.16(lb/gal)*Pct Alc+6.567(lb/gal)*Pct Alc)) = mile/gal
So at the end, for a V8, your HP Tuners user math expression could be:
[50020.114]/(((240/3600)*[6210.72]*[50151.248.avg(700)]*[50070.56])/(6.16-(6.16*[82.155])+(6.567*[82.155])))
Further manipulation of the equation structure can get it to:
(15*[50020.114]*(6.16-(6.16*[82.155])+(6.567*[82.155])))/([6210.72]*[50151.248.avg(700)]*[50070.56])
Removing parentheses and allowing order of operations to take place normally:
15*[50020.114]*(6.16-(6.16*[82.155])+(6.567*[82.155]))/[6210.72]/[50151.248.avg(700)]/[50070.56]
The '15' constant is for a V8. I believe a V6 should use '20', and a 4 cyl should use '30'
Considering that I was able to replicate Doc Sean's calc makes me feel confident that his is accurate. I could go further and simplify the fuel mixture calculations, but doing so would lose the ability to modify the weights of 100% gas vs. 100% ethanol should you choose to do so (based off better or different weight data that may account for thermal expansion).
Anyways, I hope this helps someone out there. Cheers!