General Disclaimer:   (HV) (DC) injury or death hazard,   use at your own risk,   may void warranty.

Difference between revisions of "Template:Mpge"

From My wiki
Jump to navigation Jump to search
(removed spaces from output which must be condensed when finished.)
(Initial conversion code, not yet implamented.)
Line 1: Line 1:
 
<includeonly>''XX mpge''<!--
 
<includeonly>''XX mpge''<!--
 
 
This is the Template:Mpg code, will need more complexity for mpge calculations:
 
This is the Template:Mpg code, will need more complexity for mpge calculations:
 
Catch each fuel type and convert to kWh equivalent, or zero that fuels value.
 
Catch each fuel type and convert to kWh equivalent, or zero that fuels value.
Line 7: Line 6:
 
Sum all fuel values, and calculate the mpge.
 
Sum all fuel values, and calculate the mpge.
 
Output L100km and mpge (Imperial) if requested, Link to units if requested.
 
Output L100km and mpge (Imperial) if requested, Link to units if requested.
 
 
{{{1}}}&nbsp;
 
{{{1}}}&nbsp;
 
{{#switch:{{{lk|}}}|on=[[Miles per gallon|mpg&ndash;U.S.]]|=mpg&ndash;U.S.}}
 
{{#switch:{{{lk|}}}|on=[[Miles per gallon|mpg&ndash;U.S.]]|=mpg&ndash;U.S.}}
Line 14: Line 12:
 
{{#expr:{{{1}}}* 1.20105680 round 1}}&nbsp;
 
{{#expr:{{{1}}}* 1.20105680 round 1}}&nbsp;
 
{{#switch:{{{lk|}}}|on=[[Imperial MPG|mpg&ndash;imp]]|=mpg&ndash;imp}}
 
{{#switch:{{{lk|}}}|on=[[Imperial MPG|mpg&ndash;imp]]|=mpg&ndash;imp}}
)--></includeonly><noinclude>
+
)--></includeonly><noinclude><!--
 +
Set all values to zero
 +
-->{{#vardefine:miles|0}}{{#vardefine:km|0}}<!--
 +
-->{{#vardefine:btu|0}}{{#vardefine:gas|0}}{{#vardefine:diesel|0}}{{#vardefine:kWh|0}}<!--
 +
-->{{#vardefine:mpg|0}}{{#vardefine:L100km|0}}<!--
 +
btu per gallon of gasoline
 +
-->{{ #vardefine: btug  | 114100 }}<!--
 +
btu per gallon of diesel
 +
-->{{ #vardefine: btud  | {{ #expr: {{ #var: btug }} / 0.88 }} }}<!--
 +
btu per kWh
 +
-->{{ #vardefine: btuk  | {{ #expr: {{ #var: btug }} / 33.6 }} }}<!--
 +
 
 +
Using Test case with statically assigned variables for the moment:
 +
    http://www.eaa-phev.org/wiki/Image:Capture0060.png
 +
28 miles on 15.495 kWh is 1.807 mi/kWh or 61 MPGe.
 +
    28 miles @ 78.5 mpg is 0.357 gal. of gas,
 +
    Equal to 11.995 kWh of electricity, @33.6 kWh/gal
 +
    Plus the 3.5 kWh used charged for 15.495 kWh total energy.
 +
-->{{#vardefine:miles|28}}<!--
 +
{{#vardefine:gas|0.357}}
 +
-->{{#vardefine:mpg|78.5}}<!--
 +
-->{{#vardefine:kWh|3.5}}<!--
 +
Show the initial values
 +
-->{| border=1 cellpadding=3
 +
|| miles        || km        || mpg        || gas        || diesel        || kWh        || btu       
 +
|-
 +
||{{#var:miles}}||{{#var:km}}||{{#var:mpg}}||{{#var:gas}}||{{#var:diesel}}||{{#var:kWh}}||{{#var:btu}}
 +
|-
 +
<!--
 +
If km is given convert to miles + miles to preserve miles if given
 +
-->{{ #vardefine: miles | {{ #expr: {{ #var: km    }} * 1.609344        + {{ #var: miles }} }} }}<!--
 +
Convert miles to km
 +
-->{{ #vardefine: km    | {{ #expr: {{ #var: miles  }} * 0.621371                            }} }}<!--
 +
Convert mpg into gas (gallons) + gas to preserve gas if given
 +
ERROR: Not defining mpg will cause a "Division by zero" error, need a working if statement or remove mpg option!!
 +
-->{{ #vardefine: gas  | {{ #expr: {{ #var: miles  }} / {{ #var: mpg }} + {{ #var: gas  }} }} }}<!--
 +
Convert fuels into btu equivalent
 +
-->{{ #vardefine: btu  | {{ #expr: {{ #var: gas    }} * {{ #var:btug }} + {{ #var: btu  }} }} }}<!--
 +
-->{{ #vardefine: btu  | {{ #expr: {{ #var: diesel }} * {{ #var:btud }} + {{ #var: btu  }} }} }}<!--
 +
-->{{ #vardefine: btu  | {{ #expr: {{ #var: kWh    }} * {{ #var:btuk }} + {{ #var: btu  }} }} }}<!--
 +
Convert sum of all btu back into gal(lons of gas)
 +
-->{{ #vardefine: gal  | {{ #expr: {{ #var: btu }} / {{ #var:btug }} }} }}<!--
 +
Divide miles by gal for the final mpge
 +
-->{{ #vardefine: mpge  | {{ #expr: {{ #var: miles }} / {{ #var: gal }} round 2 }} }}<!--
 +
Show the resulting values, and the final mpge result
 +
-->
 +
||{{#var:miles}}||{{#var:km}}||{{#var:mpg}}||{{#var:gas}}||{{#var:diesel}}||{{#var:kWh}}||{{#var:btu}}
 +
|}
 +
* mpge = {{ #var: mpge }}
 +
 
 +
----
  
 
Template to convert fuel mileage from various fuels or combinations of fuels into [[MPGe]] Miles per Gallon of Gasoline Equivalent.
 
Template to convert fuel mileage from various fuels or combinations of fuels into [[MPGe]] Miles per Gallon of Gasoline Equivalent.

Revision as of 14:59, 16 January 2008

miles km mpg gas diesel kWh btu
28 0 78.5 0 0 3.5 0
28 17.398388 78.5 0.35668789808917 0 3.5 52583.505838641
  • mpge = 60.76

Template to convert fuel mileage from various fuels or combinations of fuels into MPGe Miles per Gallon of Gasoline Equivalent.

  • {{mpge|miles=50.00|kWh=10.00}} results in XX mpge
  • {{mpge|km=80.00|kWh=10.00}} results in XX mpge
  • {{mpge|miles=50.00|kWh=10.00|metric=on}} results in XX mpge
  • {{mpge|miles=50.00|kWh=10.00|imperial=on}} results in XX mpge
  • {{mpge|miles=50.00|gas=1.000}} results in XX mpge
  • {{mpge|miles=50.00|diesel=1.000|lk=on}} results in XX mpge
  • {{mpge|L100km=50}} results in XX mpge
  • {{mpge|mpg=50}} results in XX mpge

Options:

See also:


Amount of fuel = 1 gallon of gasoline (measured in units for fuel type)
Gasoline (regular unleaded) 1 Gallon = 114,100 BTUs
Diesel .88 Gallons
Liquid Natural Gas 126.67 Cubic Feet
Compressed Natural Gas 33.56 Kilowatt hours
Liquefied Petroleum Gas 1.35 Gallons
Methanol 2.01 Gallons
Ethanol 100% 1.500 Gallons
Ethanol 85% 1.425 Gallons
Ethanol 10% 1.050 Gallons
Electricity 33.56 Kilowatt hours