Module: BrighterPlanet::Lodging::CarbonModel

Defined in:
lib/lodging/carbon_model.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



22
23
24
25
26
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
# File 'lib/lodging/carbon_model.rb', line 22

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 rooms, duration, and emission factor
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Multiplies `rooms` by `duration` and the `emission factor` (*kg CO<sub>2</sub>e / room-night*) to give (*kg CO<sub>2</sub>e).
      quorum 'from rooms, duration, and emission factor', :needs => [:rooms, :duration, :emission_factor] do |characteristics|
        characteristics[:rooms] * characteristics[:duration] * characteristics[:emission_factor]
      end
      
      #### Default emission
      # **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 / room-night*)
    committee :emission_factor do
      #### Emission factor from fuel intensities and eGRID
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # - Looks up the [natural gas](http://data.brighterplanet.com/fuels) emission factor (*kg CO<sub>2</sub>e / cubic m*)
      # - Looks up the [fuel oil](http://data.brighterplanet.com/fuels) emission factor (*kg CO<sub>2</sub>e / l*)
      # - Looks up the [eGRID subregion](http://data.brighterplanet.com/egrid_subregions) electricity emission factor
      # - Looks up the [eGRID region](http://data.brighterplanet.com/egrid_regions) electricity loss factor
      # - Adjusts the electricity emission factor upwards by dividing by 1 - the electricity loss factor
      # - Divides the natural gas emission factor (*kg CO<sub>2</sub>e / cubic m*) by the natural gas energy content (38,339,000 *J / cubic m*) to give an energy-based natural gas emission factor (*kg CO<sub>2</sub>e / J*)
      # - Divides the fuel oil emission factor (*kg CO<sub>2</sub>e / l*) by the fuel oil energy content (38,655,000 *J / l*) to give an energy-based fuel oil emission factor (*kg CO<sub>2</sub>e / J*)
      # - Divides the energy-based natural gas emission factor by 0.817 and the energy-based fuel oil emission factor by 0.846, adds these together and divides by 2, and divides by 0.95. This gives a district heat emission factor (*kg CO<sub>2</sub>e / J*) based on the assumption that district heat is produced by 50% natural gas and 50% fuel oil, natural gas boilers are 81.7% efficient, fuel oil boilers are 84.6% efficient, and transmission losses are 5%.
      # - Multiplies `natural gas intensity` by the natural gas emission factor, `fuel oil intensity` by the fuel oil emission factor, `electricity intensity` by the electricity emission factor, and `district heat intensity` by the district heat emission factor
      # - Adds these together
      quorum 'from fuel intensities and eGRID', :needs => [:natural_gas_intensity, :fuel_oil_intensity, :electricity_intensity, :district_heat_intensity, :egrid_subregion, :egrid_region] do |characteristics|
        natural_gas = FuelType.find_by_name "Commercial Natural Gas"
        fuel_oil = FuelType.find_by_name "Distillate Fuel Oil 2"
        natural_gas_energy_ef = natural_gas.emission_factor / 38_339_000
        fuel_oil_energy_ef = fuel_oil.emission_factor / 38_655_000
        district_heat_emission_factor = (((natural_gas_energy_ef / 0.817) / 2) + ((fuel_oil_energy_ef / 0.846) / 2)) / 0.95
        
        (characteristics[:natural_gas_intensity] * natural_gas.emission_factor) +
          (characteristics[:fuel_oil_intensity] * fuel_oil.emission_factor) +
          (characteristics[:electricity_intensity] / (1 - characteristics[:egrid_region].loss_factor) * characteristics[:egrid_subregion].electricity_emission_factor) +
          (characteristics[:district_heat_intensity] * district_heat_emission_factor)
      end
    end
    
    ### Natural gas intensity calculation
    # Returns the `natural gas intensity` (*cubic m / room-night*).
    committee :natural_gas_intensity do
      #### Natural gas intensity from census division
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [census division](http://data.brighterplanet.com/census_divisions) `natural gas intensity` (*cubic m / room-night*).
      quorum 'from census division', :needs => :census_division do |characteristics|
        characteristics[:census_division].lodging_building_natural_gas_intensity
      end
      
      #### Natural gas intensity from lodging class
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [lodging class](http://data.brighterplanet.com/lodging_class) `natural gas intensity` (*cubic m / room-night*).
      quorum 'from lodging class', :needs => :lodging_class do |characteristics|
        characteristics[:lodging_class].natural_gas_intensity
      end
    end
    
    ### Fuel oil intensity calculation
    # Returns the `fuel oil intensity` (*l / room-night*).
    committee :fuel_oil_intensity do
      #### Fuel oil intensity from census division
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [census division](http://data.brighterplanet.com/census_divisions) `fuel oil intensity` (*l / room-night*).
      quorum 'from census division', :needs => :census_division do |characteristics|
        characteristics[:census_division].lodging_building_fuel_oil_intensity
      end
      
      #### Fuel oil intensity from lodging class
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [lodging class](http://data.brighterplanet.com/lodging_class) `fuel oil intensity` (*l / room-night*).
      quorum 'from lodging class', :needs => :lodging_class do |characteristics|
        characteristics[:lodging_class].fuel_oil_intensity
      end
    end
    
    ### Electricity intensity calculation
    # Returns the `electricity intensity` (*kWh / room-night*).
    committee :electricity_intensity do
      #### Electricity intensity from census division
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [census division](http://data.brighterplanet.com/census_divisions) `electricity intensity` (*kWh / room-night*).
      quorum 'from census division', :needs => :census_division do |characteristics|
        characteristics[:census_division].lodging_building_electricity_intensity
      end
      
      #### Electricity intensity from lodging class
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [lodging class](http://data.brighterplanet.com/lodging classes) `electricity intensity` (*kWh / room-night*).
      quorum 'from lodging class', :needs => :lodging_class do |characteristics|
        characteristics[:lodging_class].electricity_intensity
      end
    end
    
    ### District heat intensity calculation
    # Returns the `district heat intensity` (*J / room-night*).
    committee :district_heat_intensity do
      #### District heat intensity from census division
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [census division](http://data.brighterplanet.com/census_divisions) `district heat intensity` (*J / room-night*).
      quorum 'from census division', :needs => :census_division do |characteristics|
        characteristics[:census_division].lodging_building_district_heat_intensity
      end
      
      #### District heat intensity from lodging class
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [lodging class](http://data.brighterplanet.com/lodging_classes) `district heat intensity` (*J / room-night*).
      quorum 'from lodging class', :needs => :lodging_class do |characteristics|
        characteristics[:lodging_class].district_heat_intensity
      end
    end
    
    ### Lodging class calculation
    # Returns the [lodging class](http://data.brighterplanet.com/lodging_classes).
    committee :lodging_class do
      #### Lodging class from client input
      # **Complies:** All
      #
      # Uses the client-input [loding class](http://data.brighterplanet.com/lodging_classes).
      
      #### Default lodging class
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Uses an artificial [lodging class](http://data.brighterplanet.com/lodging_classes) that represents the U.S. average.
      quorum 'default' do
        LodgingClass.find_by_name 'Average'
      end
    end
    
    ### eGRID region calculation
    # Returns the lodging's [eGRID region](http://data.brighterplanet.com/egrid_regions).
    committee :egrid_region do
      #### eGRID region from eGRID subregion
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [eGRID subregion](http://data.brighterplanet.com/egrid_subregions) `eGRID region`.
      quorum 'from eGRID subregion', :needs => :egrid_subregion do |characteristics|
        characteristics[:egrid_subregion].egrid_region
      end
    end
    
    ### eGRID subregion calculation
    # Returns the lodging's [eGRID subregion](http://data.brighterplanet.com/egrid_subregions).
    committee :egrid_subregion do
      #### eGRID subregion from zip code
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [zip code](http://data.brighterplanet.com/zip_codes) `eGRID subregion`.
      quorum 'from zip code', :needs => :zip_code do |characteristics|
        characteristics[:zip_code].egrid_subregion
      end
      
      #### Default eGRID subregion
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Uses an artificial [eGRID subregion](http://data.brighterplanet.com/egrid_subregions) that represents the U.S. average.
      quorum 'default' do
        EgridSubregion.find_by_abbreviation 'US'
      end
    end
    
    ### Census division calculation
    # Returns the lodging's [census division](http://data.brighterplanet.com/census_divisions).
    committee :census_division do
      #### Census division from state
      # Looks up the [state](http://data.brighterplanet.com/states) `census division`.
      quorum 'from state', :needs => :state do |characteristics|
        characteristics[:state].census_division
      end
    end
    
    ### State calculation
    # Returns the lodging's [state](http://data.brighterplanet.com/states).
    committee :state do
      #### State from zip code
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Looks up the [zip code](http://data.brighterplanet.com/zip_codes) `state`.
      quorum 'from zip code', :needs => :zip_code do |characteristics|
        characteristics[:zip_code].state
      end
    end
    
    ### Zip code calculation
    # Returns the client-input [zip code](http://data.brighterplanet.com/zip_codes).
    
    ### Duration calculation
    # Returns the stay's `duration` (*nights*).
    committee :duration do
      #### Duration from client input
      # **Complies:** All
      #
      # Uses the client-input `duration` (*nights*).
      
      #### Default duration
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Uses 1 *night*.
      quorum 'default' do
        1
      end
    end
    
    ### Rooms calculation
    # Returns the number of `rooms` used.
    committee :rooms do
      #### Rooms from client input
      # **Complies:** All
      #
      # Uses the client-input number of `rooms`.
      
      #### Default rooms
      # **Complies:** GHG Protocol, ISO 14064-1, Climate Registry Protocol
      #
      # Uses 1 room.
      quorum 'default' do
        1
      end
    end
  end
end