impact_model.rb |
|
|---|---|
|
Copyright © 2010 Brighter Planet. See LICENSE for details. Contact Brighter Planet for dual-license arrangements. |
|
Computation carbon modelThis model is used by Brighter Planet’s carbon emission web service to estimate the greenhouse gas emissions of server use. Timeframe and activity periodThe model estimates the emissions that occur during a particular CalculationsThe final estimate is the result of the calculations detailed below. These calculations are performed in reverse order, starting with the last calculation listed and finishing with the MethodsTo accomodate varying client input, each calculation may have one or more methods. These are listed under each calculation in order from most to least preferred. Each method is named according to the values it requires. If any of these values is not available the method will be ignored. If all the methods for a calculation are ignored, the calculation will not return a value. “Default” methods do not require any values, and so a calculation with a default method will always return a value. CollaborationContributions to this carbon 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 Computation
module ImpactModel
def self.included(base)
base.decide :impact, :with => :characteristics do |
Emission calculationReturns the |
committee :carbon do |
Emission from CO2 emission, CH4 emission, and N2O emission |
quorum 'from co2 emission, ch4 emission, and n2o emission', :needs => [:co2_emission, :ch4_emission, :n2o_emission] do |characteristics| |
|
Adds |
characteristics[:co2_emission] + characteristics[:ch4_emission] + characteristics[:n2o_emission]
end
end
|
CO2 emission calculationReturns the |
committee :co2_emission do |
CO2 emission from electricity use, CO2 emission factor, date, and timeframe |
quorum 'from electricity use, co2 emission factor, date, and timeframe', :needs => [:electricity_use, :co2_emission_factor, :date] do |characteristics, timeframe| |
|
Checks whether the computation |
if timeframe.include? Date.parse(characteristics[:date].to_s) |
|
Multiplies |
characteristics[:electricity_use] * characteristics[:co2_emission_factor]
else |
|
If the |
0
end
end
end
|
CO2 biogenic emission calculationReturns the |
committee :co2_biogenic_emission do |
CO2 biogenic emission from electricity use, CO2 biogenic emission factor, date, and timeframe |
quorum 'from electricity use, co2 biogenic emission factor, date, and timeframe', :needs => [:electricity_use, :co2_biogenic_emission_factor, :date] do |characteristics, timeframe| |
|
Checks whether the computation |
if timeframe.include? Date.parse(characteristics[:date].to_s) |
|
Multiplies |
characteristics[:electricity_use] * characteristics[:co2_biogenic_emission_factor]
else |
|
If the |
0
end
end
end
|
CH4 emission calculationReturns the |
committee :ch4_emission do |
CH4 emission from electricity use, CH4 emission factor, date, and timeframe |
quorum 'from electricity use, ch4 emission factor, date, and timeframe', :needs => [:electricity_use, :ch4_emission_factor, :date] do |characteristics, timeframe| |
|
Checks whether the computation |
if timeframe.include? Date.parse(characteristics[:date].to_s) |
|
Multiplies |
characteristics[:electricity_use] * characteristics[:ch4_emission_factor]
else |
|
If the |
0
end
end
end
|
N2O emission calculationReturns the |
committee :n2o_emission do |
N2O emission from electricity use, N2O emission factor, date, and timeframe |
quorum 'from electricity use, n2o emission factor, date, and timeframe', :needs => [:electricity_use, :n2o_emission_factor, :date] do |characteristics, timeframe| |
|
Checks whether the computation |
if timeframe.include? Date.parse(characteristics[:date].to_s) |
|
Multiplies |
characteristics[:electricity_use] * characteristics[:n2o_emission_factor]
else |
|
If the |
0
end
end
end
|
CO2 emission factor calculationReturns the |
committee :co2_emission_factor do |
CO2 emission factor from eGRID subregion |
quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics| |
|
Looks up the eGRID subregion |
characteristics[:egrid_subregion].electricity_co2_emission_factor
end
end
|
CO2 biogenic emission factor calculationReturns the |
committee :co2_biogenic_emission_factor do |
CO2 biogenic emission factor from eGRID subregion |
quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics| |
|
Looks up the eGRID subregion |
characteristics[:egrid_subregion].electricity_co2_biogenic_emission_factor
end
end
|
CH4 emission factor calculationReturns the |
committee :ch4_emission_factor do |
CH4 emission factor from eGRID subregion |
quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics| |
|
Looks up the eGRID subregion |
characteristics[:egrid_subregion].electricity_ch4_emission_factor
end
end
|
N2O emission factor calculationReturns the |
committee :n2o_emission_factor do |
N2O emission factor from eGRID subregion |
quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics| |
|
Looks up the eGRID subregion |
characteristics[:egrid_subregion].electricity_n2o_emission_factor
end
end
|
Electricity use calculationReturns |
committee :electricity_use do |
Electricity use from duration, electricity intensity, PUE, and electricity loss factor |
quorum 'from duration, electricity intensity, PUE, and electricity loss factor', :needs => [:duration, :electricity_intensity, :power_usage_effectiveness, :electricity_loss_factor] do |characteristics| |
|
Divides |
(characteristics[:duration] / 3600.0 * characteristics[:electricity_intensity] * characteristics[:power_usage_effectiveness]) / (1 - characteristics[:electricity_loss_factor])
end
end
|
Electricity loss factor calculationReturns the |
committee :electricity_loss_factor do |
Electricity loss factor from eGRID region |
quorum 'from eGRID region', :needs => :egrid_region do |characteristics| |
|
Looks up the eGRID region |
characteristics[:egrid_region].loss_factor
end
end
|
eGRID region calculationReturns the |
committee :egrid_region do |
eGRID region from eGRID subregion |
quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics| |
|
Looks up the eGRID subregion |
characteristics[:egrid_subregion].egrid_region
end
end
|
eGRID subregion calculationReturns the |
committee :egrid_subregion do |
eGRID subregion from zip code |
quorum 'from zip code', :needs => :zip_code do |characteristics| |
|
Looks up the zip code |
characteristics[:zip_code].egrid_subregion
end
|
eGRID subregion from carrier region |
quorum 'from carrier region', :needs => :carrier_region do |characteristics| |
|
Looks up the carrier region |
characteristics[:carrier_region].egrid_subregion
end
|
Default eGRID subregion |
quorum 'default' do |
|
Uses the fallback eGRID subregion, representing the U.S. average. |
EgridSubregion.fallback
end
end
|
Zip code calculationReturns the client-input |
|
Carrier region calculationReturns the client-input carrier region of the data center. |
|
Power usage effectiveness calculationReturns the |
committee :power_usage_effectiveness do |
Power usage effectivenss from client inputUses the client-input |
|
Power usage effectiveness from carrier |
quorum 'from carrier', :needs => :carrier do |characteristics| |
|
Looks up the carrier |
characteristics[:carrier].power_usage_effectiveness
end
end
|
Electricity intensity calculationReturns the |
committee :electricity_intensity do |
Electricity intensity from client inputUses the client-input |
|
Electricity intensity from carrier instance class |
quorum 'from carrier instance class', :needs => :carrier_instance_class do |characteristics| |
|
Looks up the carrier instance class |
characteristics[:carrier_instance_class].electricity_intensity
end
end
|
Carrier instance class calculationReturns the computation |
committee :carrier_instance_class do |
Carrier instance class from client inputUses the client-input carrier instance class. |
|
Default carrier instance class |
quorum 'default' do |
|
Assumes Amazon m1.small. |
ComputationCarrierInstanceClass.fallback
end
end
|
Carrier calculationReturns the computation |
committee :carrier do |
Carrier from client inputUses the client-input carrier. |
|
Default carrier |
quorum 'default' do |
|
Assumes Amazon. |
ComputationCarrier.fallback
end
end
|
Duration calculationReturns the computation’s |
committee :duration do |
Duration from client inputUses the client-input |
|
Default duration |
quorum 'default' do |
|
Assumes 3,600 seconds. |
base.fallback.duration
end
end
|
Date calculationReturns the |
committee :date do |
Date from client inputUses the client-input |
|
Date from timeframe |
quorum 'from timeframe' do |characteristics, timeframe| |
|
Assumes the first day of the |
timeframe.from
end
end
|
Timeframe calculationReturns the |
|
Timeframe from client inputComplies: All Uses the client-input |
|
Default timeframeComplies: All Uses the current calendar year. |
end
end
end
end
end |