impact_model.rb |
|
|---|---|
|
Copyright © 2010 Brighter Planet. See LICENSE for details. Contact Brighter Planet for dual-license arrangements. |
|
Bus trip impact modelThis model is used by the Brighter Planet CM1 web service to calculate the per-passenger impacts of a bus trip, 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 BusTrip
module ImpactModel
def self.included(base)
base.decide :impact, :with => :characteristics do |
|
|
|
Carbon (kg CO2e)One passenger’s share of the trip’s 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_3, :iso, :tcr] do |characteristics|
characteristics[:co2_emission] + characteristics[:ch4_emission] + characteristics[:n2o_emission] + characteristics[:hfc_emission]
end
end
|
CO2 emission (kg)One passenger’s share of the trip’s CO2 emissions from anthropogenic sources during |
committee :co2_emission do |
|
Multiply each |
quorum 'from fuel uses', :needs => :fuel_uses,
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:fuel_uses][:gasoline] * BusFuel.find_by_name("Gasoline").co2_emission_factor +
characteristics[:fuel_uses][:diesel] * BusFuel.find_by_name("Diesel").co2_emission_factor +
characteristics[:fuel_uses][:cng] * BusFuel.find_by_name("CNG").co2_emission_factor +
characteristics[:fuel_uses][:lng] * BusFuel.find_by_name("LNG").co2_emission_factor +
characteristics[:fuel_uses][:lpg] * BusFuel.find_by_name("LPG").co2_emission_factor +
characteristics[:fuel_uses][:methanol] * BusFuel.find_by_name("Methanol").co2_emission_factor +
characteristics[:fuel_uses][:biodiesel] * BusFuel.find_by_name("Biodiesel").co2_emission_factor
end
end
|
CO2 biogenic emission (kg)One passenger’s share of the trip’s CO2 emissions from biogenic sources during |
committee :co2_biogenic_emission do |
|
Multiply each |
quorum 'from fuel uses', :needs => :fuel_uses,
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:fuel_uses][:gasoline] * BusFuel.find_by_name("Gasoline").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:diesel] * BusFuel.find_by_name("Diesel").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:cng] * BusFuel.find_by_name("CNG").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:lng] * BusFuel.find_by_name("LNG").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:lpg] * BusFuel.find_by_name("LPG").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:methanol] * BusFuel.find_by_name("Methanol").co2_biogenic_emission_factor +
characteristics[:fuel_uses][:biodiesel] * BusFuel.find_by_name("Biodiesel").co2_biogenic_emission_factor
end
end
|
CH4 emission (kg CO2e)One passenger’s share of the trip’s CH4 emissions during |
committee :ch4_emission do |
|
Sum the |
quorum 'from distance per passenger and fuel uses', :needs => [:distance_per_passenger, :fuel_uses],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
total_fuel = characteristics[:fuel_uses].values.inject(:+)
if total_fuel > 0
characteristics[:fuel_uses][:gasoline] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Gasoline").ch4_emission_factor +
characteristics[:fuel_uses][:diesel] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Diesel").ch4_emission_factor +
characteristics[:fuel_uses][:cng] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("CNG").ch4_emission_factor +
characteristics[:fuel_uses][:lng] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("LNG").ch4_emission_factor +
characteristics[:fuel_uses][:lpg] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("LPG").ch4_emission_factor +
characteristics[:fuel_uses][:methanol] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Methanol").ch4_emission_factor +
characteristics[:fuel_uses][:biodiesel] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Biodiesel").ch4_emission_factor
else
0
end
end
end
|
N2O emission (kg CO2e)One passenger’s share of the trip’s N2O emissions during |
committee :n2o_emission do |
|
Sum the |
quorum 'from distance per passenger and fuel uses', :needs => [:distance_per_passenger, :fuel_uses],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
total_fuel = characteristics[:fuel_uses].values.inject(:+)
if total_fuel > 0
characteristics[:fuel_uses][:gasoline] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Gasoline").n2o_emission_factor +
characteristics[:fuel_uses][:diesel] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Diesel").n2o_emission_factor +
characteristics[:fuel_uses][:cng] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("CNG").n2o_emission_factor +
characteristics[:fuel_uses][:lng] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("LNG").n2o_emission_factor +
characteristics[:fuel_uses][:lpg] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("LPG").n2o_emission_factor +
characteristics[:fuel_uses][:methanol] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Methanol").n2o_emission_factor +
characteristics[:fuel_uses][:biodiesel] / total_fuel * characteristics[:distance_per_passenger] * BusFuel.find_by_name("Biodiesel").n2o_emission_factor
else
0
end
end
end
|
HFC emission (kg CO2e)One passenger’s share of the trip’s HFC emissions during |
committee :hfc_emission do |
|
Multiply |
quorum 'from distance per passenger and bus class', :needs => [:distance_per_passenger, :bus_class],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:distance_per_passenger] * characteristics[:bus_class].air_conditioning_emission_factor
end
end
=begin |
Energy (MJ)One passenger’s share of the trip’s energy use during |
committee :energy do |
|
Multiply each |
quorum 'from fuel uses', :needs => :fuel_uses do |characteristics|
characteristics[:fuel_uses][:gasoline] * BusFuel.find_by_name("Gasoline").energy_content +
characteristics[:fuel_uses][:diesel] * BusFuel.find_by_name("Diesel").energy_content +
characteristics[:fuel_uses][:cng] * BusFuel.find_by_name("CNG").energy_content +
characteristics[:fuel_uses][:lng] * BusFuel.find_by_name("LNG").energy_content +
characteristics[:fuel_uses][:lpg] * BusFuel.find_by_name("LPG").energy_content +
characteristics[:fuel_uses][:methanol] * BusFuel.find_by_name("Methanol").energy_content +
characteristics[:fuel_uses][:biodiesel] * BusFuel.find_by_name("Biodiesel").energy_content
end
end
=end
=begin
NOTE: electricity use is negligible (contributes about 0.001% of total emissions)
=end
|
Fuel uses (l)One passenger’s share of the trip’s use of each of a variety of bus fuels during |
committee :fuel_uses do |
|
For each fuel, multiply |
quorum 'from distance per passenger and bus class', :needs => [:distance_per_passenger, :bus_class],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
{
:gasoline => (characteristics[:distance_per_passenger] * characteristics[:bus_class].gasoline_intensity),
:diesel => (characteristics[:distance_per_passenger] * characteristics[:bus_class].diesel_intensity),
:cng => (characteristics[:distance_per_passenger] * characteristics[:bus_class].cng_intensity),
:lng => (characteristics[:distance_per_passenger] * characteristics[:bus_class].lng_intensity),
:lpg => (characteristics[:distance_per_passenger] * characteristics[:bus_class].lpg_intensity),
:methanol => (characteristics[:distance_per_passenger] * characteristics[:bus_class].methanol_intensity),
:biodiesel => (characteristics[:distance_per_passenger] * characteristics[:bus_class].biodiesel_intensity)
}
end
end
|
Distance per passenger (km)The distance traveled per passenger during |
committee :distance_per_passenger do |
|
If |
quorum 'from distance, passengers, date, and timeframe', :needs => [:distance, :passengers, :date],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics, timeframe|
=begin
FIXME TODO date should already be coerced
=end
date = characteristics[:date].is_a?(Date) ? characteristics[:date] : Date.parse(characteristics[:date].to_s)
timeframe.include?(date) ? characteristics[:distance] / characteristics[:passengers] : 0
end
end
|
Distance (km)The trip’s distance. |
committee :distance do |
|
Use client input, if available. |
|
|
Otherwise divide |
quorum 'from duration and speed', :needs => [:duration, :speed],
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:duration] / 3600.0 * characteristics[:speed]
end
|
|
Otherwise use the |
quorum 'from bus class', :needs => :bus_class do |characteristics|
characteristics[:bus_class].distance
end
end
|
Speed (km / hour)The trip’s average speed. |
committee :speed do |
|
Use the bus class average speed (km / hour). |
quorum 'from bus class', :needs => :bus_class,
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:bus_class].speed
end
end
|
Duration (seconds)The trip’s duration. Use client input, if available. |
|
PassengersThe number of passengers on the bus. |
committee :passengers do |
|
Use the bus class average number of passengers. |
quorum 'from bus class', :needs => :bus_class,
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics|
characteristics[:bus_class].passengers
end
end
|
Bus classThe type of bus used. |
committee :bus_class do |
|
Use client input, if available. |
|
|
Otherwise use an artificial bus class that represents US averages. |
quorum 'default',
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do
BusClass.fallback
end
end
|
Date (date)The day the trip occurred. |
committee :date do |
|
Use client input, if available. |
|
|
Otherwise use the first day of |
quorum 'from timeframe',
:complies => [:ghg_protocol_scope_3, :iso, :tcr] do |characteristics, timeframe|
timeframe.from
end
end
end
end
end
end
end |