impact_model.rb |
|
|---|---|
|
Copyright © 2010 Brighter Planet. See LICENSE for details. Contact Brighter Planet for dual-license arrangements. |
|
Automobile impact modelThis model is used by the Brighter Planet CM1 web service to calculate the impacts of an automobile, such as energy use and greenhouse gas emissions. |
|
TimeframeThe model calculates impacts that occured during a particular time period ( The default |
|
CalculationsThe final impacts are the result of the calculations below. These are performed in reverse order, starting with the last calculation listed and finishing with the greenhouse gas emissions calculation. Each calculation listing shows:
Some methods use |
|
Standard complianceWhen compliance with a particular standard is requested, all methods that do not comply with that standard are ignored.
Thus any Client input complies with all standards. |
|
CollaborationContributions to this impact model are actively encouraged and warmly welcomed. This library includes a comprehensive test suite to ensure that your changes do not cause regressions. All changes should include test coverage for new functionality. Please see sniff, our emitter testing framework, for more information. |
module BrighterPlanet
module Automobile
module ImpactModel
def self.included(base)
base.decide :impact, :with => :characteristics do |
|
|
|
Carbon (kg CO2e)The automobile’s total anthropogenic greenhouse gas emissions during |
committee :carbon do |
|
Sum |
quorum 'from co2 emission, ch4 emission, n2o emission, and hfc emission', :needs => [:co2_emission, :ch4_emission, :n2o_emission, :hfc_emission],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:co2_emission] + characteristics[:ch4_emission] + characteristics[:n2o_emission] + characteristics[:hfc_emission]
end
end
|
CO2 emission (kg)The automobile’s CO2 emissions from anthropogenic sources during |
committee :co2_emission do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].co2_emission_factor
end
end
|
CO2 biogenic emission (kg)The automobile’s CO2 emissions from biogenic sources during |
committee :co2_biogenic_emission do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].co2_biogenic_emission_factor
end
end
|
CH4 emission (kg CO2e)The automobile’s CH4 emissions during |
committee :ch4_emission do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].ch4_emission_factor
end
end
|
N2O emission (kg CO2e)The automobile’s N2O emissions during |
committee :n2o_emission do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].n2o_emission_factor
end
end
|
HFC emission (kg CO2e)The automobile’s HFC emissions during |
committee :hfc_emission do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].hfc_emission_factor
end
end
|
Energy (MJ)The automobile’s energy use during |
committee :energy do |
|
Multiply |
quorum 'from fuel use and automobile fuel', :needs => [:fuel_use, :automobile_fuel] do |characteristics|
characteristics[:fuel_use] * characteristics[:automobile_fuel].energy_content
end
end
|
Fuel use (l)The automobile’s fuel use during |
committee :fuel_use do |
|
Use client input, if available. |
|
|
Otherwise divide |
quorum 'from fuel efficiency and distance', :needs => [:fuel_efficiency, :distance],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:distance] / characteristics[:fuel_efficiency]
end
end
|
Distance (km)The distance the automobile travelled during |
committee :distance do |
|
Multiply |
quorum 'from annual distance', :needs => [:annual_distance, :active_subtimeframe],
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
characteristics[:annual_distance] * (characteristics[:active_subtimeframe] / timeframe.year)
end
end
|
Annual distance (km)The distance the automobile would travel if it were used for the entire calendar year in which |
committee :annual_distance do |
|
Use client input, if available. |
|
|
Otherwise divide |
quorum 'from weekly distance and timeframe', :needs => :weekly_distance,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
(characteristics[:weekly_distance] / 7 ) * timeframe.year.days
end
|
|
Otherwise multiply |
quorum 'from daily distance and timeframe', :needs => :daily_distance,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
characteristics[:daily_distance] * timeframe.year.days
end
|
|
Otherwise divide |
quorum 'from daily duration, speed, and timeframe', :needs => [:daily_duration, :speed],
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
characteristics[:daily_duration] / 3600.0 * characteristics[:speed] * timeframe.year.days
end
|
|
Otherwise use the |
quorum 'from size class', :needs => :size_class,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:size_class].annual_distance
end
|
|
Otherwise use the |
quorum 'from automobile fuel', :needs => :automobile_fuel,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:automobile_fuel].annual_distance
end
end
|
Weekly distance (km)The average distance the automobile is driven each week. Use client input if available. |
|
Daily distance (km)The average distance the automobile is driven each day. Use client input if available. |
|
Daily duration (seconds)The average time the automobile is driven each day. Use client input, if available. |
|
Automobile fuelThe automobile’s fuel type. |
committee :automobile_fuel do |
|
Use client input, if available. |
|
|
Otherwise use the |
quorum 'from make model year', :needs => :make_model_year,
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:make_model_year].automobile_fuel
end
|
|
Otherwise use the average automobile fuel. |
quorum 'default',
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
AutomobileFuel.fallback
end
end
|
Speed (km / hour)The automobile’s average speed. |
committee :speed do |
|
Use client input, if available. |
|
|
Otherwise look up the United States average automobile city speed (km / hour) and automobile highway speed (km / hour).
Calculate the harmonic mean of those speeds weighted by |
quorum 'from urbanity', :needs => :urbanity,
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
1 / (characteristics[:urbanity] / Country.united_states.automobile_city_speed + (1 - characteristics[:urbanity]) / Country.united_states.automobile_highway_speed)
end
end
|
Fuel efficiency (km / l)The automobile’s fuel efficiency. |
committee :fuel_efficiency do |
|
Use client input, if available. |
|
|
Otherwise look up the |
quorum 'from make model year and urbanity', :needs => [:make_model_year, :urbanity],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
1.0 / (
(characteristics[:urbanity] / characteristics[:make_model_year].fuel_efficiency_city) +
((1.0 - characteristics[:urbanity]) / characteristics[:make_model_year].fuel_efficiency_highway)
)
end
|
|
Otherwise look up the |
quorum 'from make model and urbanity', :needs => [:make_model, :urbanity],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
1.0 / (
(characteristics[:urbanity] / characteristics[:make_model].fuel_efficiency_city) +
((1.0 - characteristics[:urbanity]) / characteristics[:make_model].fuel_efficiency_highway)
)
end
|
|
Otherwise look up the |
quorum 'from size class, hybridity multiplier, and urbanity', :needs => [:size_class, :hybridity_multiplier, :urbanity],
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
(1.0 / (
(characteristics[:urbanity] / characteristics[:size_class].fuel_efficiency_city) +
((1.0 - characteristics[:urbanity]) / characteristics[:size_class].fuel_efficiency_highway)
)) * characteristics[:hybridity_multiplier]
end
|
|
Otherwise look up the |
quorum 'from make year and hybridity multiplier', :needs => [:make_year, :hybridity_multiplier],
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:make_year].fuel_efficiency * characteristics[:hybridity_multiplier]
end
|
|
Otherwise look up the |
quorum 'from make and hybridity multiplier', :needs => [:make, :hybridity_multiplier],
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
characteristics[:make].fuel_efficiency * characteristics[:hybridity_multiplier]
end
|
|
Otherwise look up the United States average automobile fuel efficiency (km / l).
Multiply by |
quorum 'from hybridity multiplier', :needs => :hybridity_multiplier,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
Country.united_states.automobile_fuel_efficiency * characteristics[:hybridity_multiplier]
end
end
|
Hybridity multiplier (dimensionless)A multiplier used to adjust fuel efficiency if we know the automobile is a hybrid or conventional vehicle. |
committee :hybridity_multiplier do |
|
Check whether the |
quorum 'from size class, hybridity, and urbanity', :needs => [:size_class, :hybridity, :urbanity],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
drivetrain = (characteristics[:hybridity] == true) ? :hybrid : :conventional
city_multiplier = characteristics[:size_class].send(:"#{drivetrain}_fuel_efficiency_city_multiplier")
highway_multiplier = characteristics[:size_class].send(:"#{drivetrain}_fuel_efficiency_highway_multiplier")
if city_multiplier and highway_multiplier
1.0 / ((characteristics[:urbanity] / city_multiplier) + ((1.0 - characteristics[:urbanity]) / highway_multiplier))
end
end
|
|
Otherwise look up the average size class |
quorum 'from hybridity and urbanity', :needs => [:hybridity, :urbanity],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
drivetrain = (characteristics[:hybridity] == true) ? :hybrid : :conventional
urbanity = characteristics[:urbanity]
fuel_efficiency_multipliers = {
:city => AutomobileSizeClass.fallback.send(:"#{drivetrain}_fuel_efficiency_city_multiplier"),
:highway => AutomobileSizeClass.fallback.send(:"#{drivetrain}_fuel_efficiency_highway_multiplier")
}
1.0 / ((urbanity / fuel_efficiency_multipliers[:city]) + ((1.0 - urbanity) / fuel_efficiency_multipliers[:highway]))
end
|
|
Otherwise use a multiplier of 1.0. |
quorum 'default',
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do
1.0
end
end
|
Hybridity (boolean)True if the automobile is a hybrid vehicle. False if the automobile is a conventional vehicle. Use client input, if available. |
|
Size classThe automobile’s size class. Use client input, if available. |
|
Urbanity (%)The fraction of the total distance driven that is in towns and cities rather than highways. Highways are defined as all driving at speeds of 45 miles per hour or greater. |
committee :urbanity do |
|
Use the United States average automobile urbanity (%). |
quorum 'default',
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do
Country.united_states.automobile_urbanity
end
end
|
Active subtimeframe (date range)The portion of |
committee :active_subtimeframe do |
|
Calculate the portion of |
quorum 'from acquisition and retirement', :needs => [:acquisition, :retirement],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
Timeframe.constrained_new characteristics[:acquisition].to_date, characteristics[:retirement].to_date, timeframe
end
end
|
Acquisition (date)The date the automobile was put into use. |
committee :acquisition do |
|
Use client input, if available. |
|
|
Otherwise use the first day of |
quorum 'from year', :needs => :year,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics|
Date.new characteristics[:year].year, 1, 1
end
|
|
Otherwise use whichever is earlier: the first day of |
quorum 'default', :appreciates => :retirement,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
[ timeframe.from, characteristics[:retirement] ].compact.min
end
end
|
Retirement (date)The date the automobile was taken out of use. |
committee :retirement do |
|
Use client input, if available. |
|
|
Otherwise use whichever is later: the last day of |
quorum 'default', :appreciates => :acquisition,
:complies => [:ghg_protocol_scope_3, :iso] do |characteristics, timeframe|
[ timeframe.to, characteristics[:acquisition] ].compact.max
end
end
|
Make model yearThe automobile’s make, model, and year. |
committee :make_model_year do |
|
Check whether the |
quorum 'from make, model, and year', :needs => [:make, :model, :year],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
AutomobileMakeModelYear.find_by_make_name_and_model_name_and_year(characteristics[:make].name, characteristics[:model].name, characteristics[:year].year)
end
end
|
Make yearThe automobile’s make and year. |
committee :make_year do |
|
Check whether the |
quorum 'from make and year', :needs => [:make, :year],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
AutomobileMakeYear.find_by_make_name_and_year(characteristics[:make].name, characteristics[:year].year)
end
end
|
Make modelThe automobile’s make and model. |
committee :make_model do |
|
Check whether the |
quorum 'from make and model', :needs => [:make, :model],
:complies => [:ghg_protocol_scope_1, :ghg_protocol_scope_3, :iso] do |characteristics|
AutomobileMakeModel.find_by_make_name_and_model_name(characteristics[:make].name, characteristics[:model].name)
end
end
|
YearThe automobile’s year of manufacture. Use client input, if available. |
|
ModelThe automobile’s model. Use client input, if available. |
|
MakeThe automobile’s make. Use client input, if available. |
end
end
end
end
end |