Module: BrighterPlanet::Automobile::CarbonModel
- Defined in:
- lib/automobile/carbon_model.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/automobile/carbon_model.rb', line 27 def self.included(base) base.decide :emission, :with => :characteristics do ### Emission calculation # Returns the `emission` estimate (*kg CO<sub>2</sub>e*). committee :emission do #### Emission from fuel # **Complies:** GHG Protocol, ISO 14064-1 # # Multiplies `fuel consumed` (*l*) by the `emission factor` (*kg CO<sub>2</sub>e / l*) to give *kg CO<sub>2</sub>e*. quorum 'from fuel', :needs => [:fuel_consumed, :emission_factor], :appreciates => :fuel_type, :complies => [:ghg_protocol, :iso] do |characteristics| if characteristics[:fuel_type].andand.code == AutomobileFuelType::CODES[:electricity] 0.0 else characteristics[:fuel_consumed] * characteristics[:emission_factor] end end #### Emission from default # **Complies:** # # Displays an error message if the previous method fails. quorum 'default' do raise "The emission committee's default quorum should never be called" end end ### Emission factor calculation # Returns the `emission factor` (*kg CO<sub>2</sub>e / l*) committee :emission_factor do #### Emission factor from fuel type # **Complies:** GHG Protocol, ISO 14064-1 # # Looks up the automobile [fuel type](http://data.brighterplanet.com/fuel_types) `emission factor` (*kg CO2e / l*) quorum 'from fuel type', :needs => :fuel_type, :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:fuel_type].emission_factor end #### Default emission factor # **Complies:** GHG Protocol, ISO 14064-1 # # Uses a default `emission factor` of 2.49 *kg CO<sub>2</sub>e / l*, calculated from [EPA (2010)](http://www.epa.gov/climatechange/emissions/usinventoryreport.html) quorum 'default', :complies => [:ghg_protocol, :iso] do 20.781.pounds_per_gallon.to(:kilograms_per_litre) end end ### Fuel consumed calculation # Returns the `fuel consumed` (*l*). committee :fuel_consumed do #### Fuel consumed from fuel efficiency and distance # **Complies:** GHG Protocol, ISO 14064-1 # # Divides the `distance` (*km*) by the `fuel efficiency` (*km / l*) to give *l*. quorum 'from fuel efficiency and distance', :needs => [:fuel_efficiency, :distance], :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:distance] / characteristics[:fuel_efficiency] end end ### Distance calculation # Returns the `distance` (*km*). # This is the distance the automobile travelled during the `active subtimeframe`. committee :distance do #### Distance from annual distance # **Complies:** GHG Protocol, ISO 14064-1 # # Multiplies the `annual distance` (*km*) by the fraction of the calendar year in which the `timeframe` falls that overlaps with the `active subtimeframe`. quorum 'from annual distance', :needs => [:annual_distance, :active_subtimeframe], :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| characteristics[:annual_distance] * (characteristics[:active_subtimeframe] / timeframe.year) end end ### Annual distance calculation # Returns the `annual distance` (*km*). # This is the distance the automobile would travel if it were in use for the entire calendar year in which the `timeframe` falls. # Note that if either `acquisition` or `retirement` occurs during the calendar year in which the `timeframe` falls then `annual distance` will be MORE THAN the distance the automobile actually travelled during that calendar year. committee :annual_distance do #### Annual distance from annual distance estimate # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the `annual distance estimate` (*km*). quorum 'from annual distance estimate', :needs => :annual_distance_estimate, :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:annual_distance_estimate] end #### Annual distance from weekly distance # **Complies:** GHG Protocol, ISO 14064-1 # # Divides the `weekly distance estimate` (*km*) by 7 and multiplies by the number of days in the calendar year in which the `timeframe` falls. quorum 'from weekly distance estimate and timeframe', :needs => :weekly_distance_estimate, :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| (characteristics[:weekly_distance_estimate] / 7 ) * timeframe.year.days end #### Annual distance from daily distance # **Complies:** GHG Protocol, ISO 14064-1 # # Multiplies the `daily distance estimate` (*km*) by the number of days in the calendar year in which the `timeframe` falls. quorum 'from daily distance estimate and timeframe', :needs => :daily_distance_estimate, :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| characteristics[:daily_distance_estimate] * timeframe.year.days end #### Annual distance from daily duration and speed # **Complies:** GHG Protocol, ISO 14064-1 # # * Multiplies the `daily duration` (*hours*) by the `speed` (*km / hour*) to give *km* # * Multiplies the result by the number of days in the calendar year in which the `timeframe` falls. quorum 'from daily duration, speed, and timeframe', :needs => [:daily_duration, :speed], :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| characteristics[:daily_duration] * characteristics[:speed] * timeframe.year.days end #### Annual distance from size class # **Complies:** GHG Protocol, ISO 14064-1 # # Looks up the automobile [size class](http://data.brighterplanet.com/automobile_size_classes) `annual distance` (*km*). quorum 'from size class', :needs => :size_class, :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:size_class].annual_distance end #### Annual distance from fuel type # **Complies:** GHG Protocol, ISO 14064-1 # # Looks up the [fuel type](http://data.brighterplanet.com/fuel_types) `annual distance` (*km*). quorum 'from fuel type', :needs => :fuel_type, :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:fuel_type].annual_distance end #### Default annual distance # **Complies:** GHG Protocol, ISO 14064-1 # # Uses an `annual distance` of 19,021 *km*, calculated from total US automobile vehicle miles travelled and number of automobiles. quorum 'default', :complies => [:ghg_protocol, :iso] do 11819.miles.to(:kilometres) end end ### Annual distance estimate calculation # Returns the client-input `annual distance estimate` (*km*). # This is the average distance the automobile travels each week. ### Weekly distance estimate calculation # Returns the client-input `weekly distance estimate` (*km*). # This is the average distance the automobile travels each week. ### Daily distance estimate calculation # Returns the client-input `daily distance estimate` (*km*). # This is the average distance the automobile travels each day. ### Daily duration calculation # Returns the client-input `daily duration` (*hours*). ### Fuel efficiency calculation # Returns the `fuel efficiency` (*km / l*) committee :fuel_efficiency do #### Fuel efficiency from client input # **Complies:** All # # Uses the client-input `fuel efficiency` (*km / l*). #### Fuel efficiency from make model year variant and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the city and highway fuel efficiencies of the automobile [make model year variant](http://data.brighterplanet.com/automobile_variants) (*km / l*) # * Calculates the harmonic mean of those fuel efficiencies, weighted by `urbanity` quorum 'from make model year variant and urbanity', :needs => [:make_model_year_variant, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| fuel_efficiency_city = characteristics[:make_model_year_variant].fuel_efficiency_city fuel_efficiency_highway = characteristics[:make_model_year_variant].fuel_efficiency_highway urbanity = characteristics[:urbanity] if fuel_efficiency_city.present? and fuel_efficiency_highway.present? 1.0 / ((urbanity / fuel_efficiency_city) + ((1.0 - urbanity) / fuel_efficiency_highway)) end end #### Fuel efficiency from make model year and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the city and highway fuel efficiencies of the automobile [make model year](http://data.brighterplanet.com/automobile_model_years) (*km / l*) # * Calculates the harmonic mean of those fuel efficiencies, weighted by `urbanity` quorum 'from make model year and urbanity', :needs => [:make_model_year, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| fuel_efficiency_city = characteristics[:make_model_year].fuel_efficiency_city fuel_efficiency_highway = characteristics[:make_model_year].fuel_efficiency_highway urbanity = characteristics[:urbanity] if fuel_efficiency_city.present? and fuel_efficiency_highway.present? 1.0 / ((urbanity / fuel_efficiency_city) + ((1.0 - urbanity) / fuel_efficiency_highway)) end end #### Fuel efficiency from make model and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the city and highway fuel efficiencies of the automobile [make model](http://data.brighterplanet.com/automobile_models) (*km / l*) # * Calculates the harmonic mean of those fuel efficiencies, weighted by `urbanity` quorum 'from make model and urbanity', :needs => [:make_model, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| fuel_efficiency_city = characteristics[:make_model].fuel_efficiency_city fuel_efficiency_highway = characteristics[:make_model].fuel_efficiency_highway urbanity = characteristics[:urbanity] if fuel_efficiency_city.present? and fuel_efficiency_highway.present? 1.0 / ((urbanity / fuel_efficiency_city) + ((1.0 - urbanity) / fuel_efficiency_highway)) end end #### Fuel efficiency from size class, hybridity multiplier, and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the automobile [size class](http://data.brighterplanet.com/automobile_makes) city and highway fuel efficiency (*km / l*) # * Calculates the harmonic mean of those fuel efficiencies, weighted by `urbanity` # * Multiplies the result by the `hybridity multiplie`r quorum 'from size class, hybridity multiplier, and urbanity', :needs => [:size_class, :hybridity_multiplier, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| fuel_efficiency_city = characteristics[:size_class].fuel_efficiency_city fuel_efficiency_highway = characteristics[:size_class].fuel_efficiency_highway urbanity = characteristics[:urbanity] if fuel_efficiency_city.present? and fuel_efficiency_highway.present? (1.0 / ((urbanity / fuel_efficiency_city) + ((1.0 - urbanity) / fuel_efficiency_highway))) * characteristics[:hybridity_multiplier] end end #### Fuel efficiency from make year and hybridity multiplier # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the automobile [make year](http://data.brighterplanet.com/automobile_make_years) combined fuel efficiency (*km / l*) # * Multiplies the combined fuel efficiency by the `hybridity multiplier` quorum 'from make year and hybridity multiplier', :needs => [:make_year, :hybridity_multiplier], :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:make_year].fuel_efficiency * characteristics[:hybridity_multiplier] end #### Fuel efficiency from make and hybridity multiplier # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the automobile [make](http://data.brighterplanet.com/automobile_makes) combined fuel efficiency (*km / l*) # * Multiplies the combined fuel efficiency by the `hybridity multiplier` quorum 'from make and hybridity multiplier', :needs => [:make, :hybridity_multiplier], :complies => [:ghg_protocol, :iso] do |characteristics| if characteristics[:make].fuel_efficiency.nil? nil else characteristics[:make].fuel_efficiency * characteristics[:hybridity_multiplier] end end #### Fuel efficiency from hybridity multiplier # **Complies:** GHG Protocol, ISO 14064-1 # # * Takes a default `fuel efficiency` of 8.58 *km / l*, calculated from total US automobile vehicle miles travelled and gasoline and diesel consumption. # * Multiplies the `fuel efficiency` by the `hybridity multiplier` quorum 'from hybridity multiplier', :needs => :hybridity_multiplier, :complies => [:ghg_protocol, :iso] do |characteristics| 20.182.miles_per_gallon.to(:kilometres_per_litre) * characteristics[:hybridity_multiplier] end end ### Hybridity multiplier calculation # Returns the `hybridity multiplier`. # This value may be used to adjust the fuel efficiency based on whether the automobile is a hybrid or conventional vehicle. committee :hybridity_multiplier do #### Hybridity multiplier from size class, hybridity, and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the appropriate city and highway hybridity multipliers for the automobile [size class](http://data.brighterplanet.com/automobile_size_classes) # * Calculates the harmonic mean of those multipliers, weighted by `urbanity` quorum 'from size class, hybridity, and urbanity', :needs => [:size_class, :hybridity, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| drivetrain = characteristics[:hybridity] ? :hybrid : :conventional urbanity = characteristics[:urbanity] size_class = characteristics[:size_class] fuel_efficiency_multipliers = { :city => size_class.send(:"#{drivetrain}_fuel_efficiency_city_multiplier"), :highway => size_class.send(:"#{drivetrain}_fuel_efficiency_highway_multiplier") } if fuel_efficiency_multipliers.values.any?(&:nil?) nil else 1.0 / ((urbanity / fuel_efficiency_multipliers[:city]) + ((1.0 - urbanity) / fuel_efficiency_multipliers[:highway])) end end #### Hybridity multiplier from hybridity and urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Looks up the appropriate default city and highway hybridity multipliers # * Calculates the harmonic mean of those multipliers, weighted by `urbanity` quorum 'from hybridity and urbanity', :needs => [:hybridity, :urbanity], :complies => [:ghg_protocol, :iso] do |characteristics| drivetrain = characteristics[:hybridity] ? :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 #### Default hybridity multiplier # **Complies:** GHG Protocol, ISO 14064-1 # # Uses a default `hybridity multiplier` of 1. quorum 'default', :complies => [:ghg_protocol, :iso] do 1.0 end end ### Hybridity calculation # Returns the client-input `hybridity`. This indicates whether the automobile is a hybrid electric vehicle or a conventional vehicle. ### Size class calculation # Returns the client-input automobile [size class](http://data.brighterplanet.com/automobile_size_classes). ### Speed calculation # Returns the average `speed` at which the automobile travels (*km / hour*) committee :speed do #### Speed from urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # * Takes average city and highway driving speeds from [EPA (2006)](http://www.epa.gov/fueleconomy/420r06017.pdf) and converts from *miles / hour* to *km / hour* # * Calculates the harmonic mean of those speeds, weighted by `urbanity` quorum 'from urbanity', :needs => :urbanity, :complies => [:ghg_protocol, :iso] do |characteristics| 1 / (characteristics[:urbanity] / 19.9.miles.to(:kilometres) + (1 - characteristics[:urbanity]) / 57.1.miles.to(:kilometres)) end end ### Urbanity calculation # Returns the `urbanity`. # This is the fraction of the total distance driven that occurs on towns and city streets as opposed to highways (defined using a 45 miles per hour "speed cutpoint"). committee :urbanity do #### Urbanity from client input # **Complies:** All # # Uses the client-input `urbanity`. #### Default urbanity # **Complies:** GHG Protocol, ISO 14064-1 # # Uses an `urbanity` of 0.43 after [EPA (2009) Appendix A](http://www.epa.gov/otaq/cert/mpg/fetrends/420r09014-appx-a.pdf) quorum 'default', :complies => [:ghg_protocol, :iso] do 0.43 end end ### Fuel type calculation # Returns the `fuel type` used by the automobile. committee :fuel_type do #### Fuel type from client input # **Complies:** All # # Uses the client-input [fuel type](http://data.brighterplanet.com/fuel_types). #### Fuel type from make model year variant # **Complies:** GHG Protocol, ISO 14064-1 # # Looks up the [variant](http://data.brighterplanet.com/automobile_variants) `fuel type`. quorum 'from make model year variant', :needs => :make_model_year_variant, :complies => [:ghg_protocol, :iso] do |characteristics| characteristics[:make_model_year_variant].fuel_type end end ### Active subtimeframe calculation # Returns the portion of the `timeframe` that falls between the `acquisition` and `retirement`. committee :active_subtimeframe do #### Active subtimeframe from timeframe, acquisition, and retirement # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the portion of the `timeframe` that falls between `acquisition` and `retirement`. quorum 'from acquisition and retirement', :needs => [:acquisition, :retirement], :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| Timeframe.constrained_new characteristics[:acquisition].to_date, characteristics[:retirement].to_date, timeframe end end ### Acquisition calculation # Returns the date of the automobile's `acquisition`. # This is the date the automobile was put into use. committee :acquisition do #### Acquisition from client input # **Complies:** All # # Uses the client-input `acquisition`. #### Acquisition from make model year variant # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the first day of the client-input automobile [make model year variant](http://data.brighterplanet.com/automobile_variants) year. quorum 'from make model year variant', :needs => [:make_model_year_variant], :complies => [:ghg_protocol, :iso] do |characteristics| Date.new characteristics[:make_model_year_variant].year, 1, 1 end #### Acquisition from make model year # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the first day of the client-input automobile [make model year](http://data.brighterplanet.com/automobile_model_years) year. quorum 'from make model year', :needs => [:make_model_year], :complies => [:ghg_protocol, :iso] do |characteristics| Date.new characteristics[:make_model_year].year, 1, 1 end #### Acquisition from make year # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the first day of the client-input automobile [make year](http://data.brighterplanet.com/automobile_make_years) year. quorum 'from make year', :needs => [:make_year], :complies => [:ghg_protocol, :iso] do |characteristics| Date.new characteristics[:make_year].year, 1, 1 end #### Acquisition from timeframe or retirement # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the first day of the `timeframe`, or the `retirement`, whichever is earlier. quorum 'from retirement', :appreciates => :retirement, :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| [ timeframe.from, characteristics[:retirement] ].compact.min end end ### Retirement calculation # Returns the date of the automobile's `retirement`. # This is the date the automobile was taken out of use. committee :retirement do #### Retirement from client input # **Complies:** All # # Uses the client-input `retirement`. #### Retirement from timeframe or acquisition # **Complies:** GHG Protocol, ISO 14064-1 # # Uses the last day of the `timeframe`, or the `acquisition`, whichever is later. quorum 'from acquisition', :appreciates => :acquisition, :complies => [:ghg_protocol, :iso] do |characteristics, timeframe| [ timeframe.to, characteristics[:acquisition] ].compact.max end end ### Make model year variant calculation # Returns the client-input automobile [make model year variant](http://data.brighterplanet.com/automobile_variants). ### Make model year calculation # Returns the client-input automobile [make model year](http://data.brighterplanet.com/automobile_model_years). ### Make model calculation # Returns the client-input automobile [make model](http://data.brighterplanet.com/automobile_models). ### Make year calculation # Returns the client-input automobile [make year](http://data.brighterplanet.com/automobile_make_years). ### Make calculation # Returns the client-input automobile [make](http://data.brighterplanet.com/automobile_makes). ### Timeframe calculation # Returns the `timeframe`. # This is the period during which to calculate emissions. #### Timeframe from client input # **Complies:** All # # Uses the client-input `timeframe`. #### Default timeframe # **Complies:** All # # Uses the current calendar year. end end |