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.)
(example of inaccurate comparison, and a correction.)
 
(3 intermediate revisions by the same user not shown)
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>''' This template is still under development, some of this is for debugging '''<!--
 +
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 class="wikitable"
 +
! !! miles        !! km        !! mpg        !! gas        !! diesel        !! kWh        !! btu       
 +
|-
 +
|| Pre ||{{#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
 +
-->
 +
|| Post ||{{#var:miles}}||{{#var:km}}||{{#var:mpg}}||{{#var:gas}}||{{#var:diesel}}||{{#var:kWh}}||{{#var:btu}}
 +
|}
 +
* Result mpge = {{ #var: mpge }}
  
 +
{{TOCright}}
 +
==Use Examples==
 
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.
 
*<nowiki>{{mpge|miles=50.00|kWh=10.00}}</nowiki> results in {{mpge|miles=50.00|kWh=10.00}}
 
*<nowiki>{{mpge|miles=50.00|kWh=10.00}}</nowiki> results in {{mpge|miles=50.00|kWh=10.00}}
Line 26: Line 73:
 
*<nowiki>{{mpge|mpg=50}}</nowiki> results in {{mpge|mpg=50}}
 
*<nowiki>{{mpge|mpg=50}}</nowiki> results in {{mpge|mpg=50}}
  
Options:
+
Per [http://www.extremetech.com/article2/0,1697,2277050,00.asp BMW Tops Toyota Prius In Fuel Economy Tests]
 +
which claims the BMW 520d got 41.9 mpg(diesel) while the Prius got 40.1 mpg(gas).
 +
However the energy content of gas and diesel fuels differ, so we can adjust the diesel into an mpge equivalent
 +
{{mpge|miles=41.9|diesel=1.000|lk=on}} '''41.9mpg(diesel) * 0.88 = 36.872 mpge''' versus the 40.1mpge of the Prius.
 +
 
 +
==Options==
 
* Make units [[W:Wikipedia:Manual of Style (links)|wikilinked]] by attaching <code><nowiki>|lk=on</nowiki></code>.
 
* Make units [[W:Wikipedia:Manual of Style (links)|wikilinked]] by attaching <code><nowiki>|lk=on</nowiki></code>.
 
*:The [[W:WP:MOS|manual of style]] suggests that you only link the first instance.
 
*:The [[W:WP:MOS|manual of style]] suggests that you only link the first instance.
  
See also:
+
==See also==
 
* [[Template:Mpg]] - For U.S. gallons version
 
* [[Template:Mpg]] - For U.S. gallons version
 
* [[Template:Mpg (Imperial)]] - For Imperial (UK) gallons version
 
* [[Template:Mpg (Imperial)]] - For Imperial (UK) gallons version
Line 36: Line 88:
 
* [[W:Template:Convert]]
 
* [[W:Template:Convert]]
  
 
+
==Conversion Metrics==
{| border=1
+
{| border=1 class="wikitable"
| colspan=2 | Amount of fuel = 1 gallon of gasoline (measured in units for fuel type)
+
! colspan=2 | Amount of fuel = 1 gallon of gasoline (measured in units for fuel type)
 
|-
 
|-
 
|| Gasoline (regular unleaded) || 1 Gallon = 114,100 [[W:BTU|BTUs]]
 
|| Gasoline (regular unleaded) || 1 Gallon = 114,100 [[W:BTU|BTUs]]

Latest revision as of 21:13, 20 March 2008

This template is still under development, some of this is for debugging

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.
miles km mpg gas diesel kWh btu
Pre 28 0 78.5 0 0 3.5 0
Post 28 17.398388 78.5 0.35668789808917 0 3.5 52583.505838641
  • Result mpge = 60.76

Use Examples

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

Per BMW Tops Toyota Prius In Fuel Economy Tests which claims the BMW 520d got 41.9 mpg(diesel) while the Prius got 40.1 mpg(gas). However the energy content of gas and diesel fuels differ, so we can adjust the diesel into an mpge equivalent XX mpge 41.9mpg(diesel) * 0.88 = 36.872 mpge versus the 40.1mpge of the Prius.

Options

See also

Conversion Metrics

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