@@ -202,18 +202,22 @@ def energyPlusOutputRequests(runner, user_arguments)
202
202
has_fuel = hpxml . has_fuels ( Constants . FossilFuels , hpxml . to_doc )
203
203
has_fuel [ HPXML ::FuelTypeElectricity ] = true
204
204
205
- # Fuel outputs
205
+ # Has production
206
206
has_pv = @hpxml_buildings . select { |hpxml_bldg | !hpxml_bldg . pv_systems . empty? } . size > 0
207
+ has_battery = @model . getElectricLoadCenterStorageLiIonNMCBatterys . size > 0 # has modeled battery
208
+ has_generator = @hpxml_buildings . select { |hpxml_bldg | !hpxml_bldg . generators . empty? } . size > 0
209
+
210
+ # Fuel outputs
207
211
fuels . each do |( fuel_type , is_production ) , fuel |
208
212
fuel . meters . each do |meter |
209
213
next unless has_fuel [ hpxml_fuel_map [ fuel_type ] ]
210
- next if is_production && !has_pv
214
+ next if is_production && !has_pv # we don't need to request these meters if there isn't pv
215
+ next if meter . include? ( 'ElectricStorage' ) && !has_battery # we don't need to request this meter if there isn't a modeled battery
216
+ next if meter . include? ( 'Cogeneration' ) && !has_generator # we don't need to request this meter if there isn't a generator
211
217
212
218
result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,monthly;" ) . get
213
219
if fuel_type == FT ::Elec && @hpxml_header . utility_bill_scenarios . has_detailed_electric_rates
214
220
result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,hourly;" ) . get
215
- else
216
- result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,monthly;" ) . get
217
221
end
218
222
end
219
223
end
@@ -698,8 +702,8 @@ def get_utility_bills(fuels, utility_rates, utility_bills, utility_bill_scenario
698
702
# @return [Hash] Fuel type, is_production => Fuel object
699
703
def setup_fuel_outputs ( )
700
704
fuels = { }
701
- fuels [ [ FT ::Elec , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeElectricity } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeElectricity ) )
702
- fuels [ [ FT ::Elec , true ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeElectricity } Produced:Facility " ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeElectricity ) )
705
+ fuels [ [ FT ::Elec , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeElectricity } :Facility" , "ElectricStorage: #{ EPlus :: FuelTypeElectricity } Produced" , "Cogeneration: #{ EPlus :: FuelTypeElectricity } Produced" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeElectricity ) )
706
+ fuels [ [ FT ::Elec , true ] ] = Fuel . new ( meters : [ "Photovoltaic: #{ EPlus ::FuelTypeElectricity } Produced" , "PowerConversion: #{ EPlus :: FuelTypeElectricity } Produced "] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeElectricity ) )
703
707
fuels [ [ FT ::Gas , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeNaturalGas } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeNaturalGas ) )
704
708
fuels [ [ FT ::Oil , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeOil } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeOil ) )
705
709
fuels [ [ FT ::Propane , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypePropane } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypePropane ) )
@@ -744,18 +748,17 @@ def get_outputs(fuels, utility_bill_scenario)
744
748
745
749
timeseries_freq = 'monthly'
746
750
timeseries_freq = 'hourly' if fuel_type == FT ::Elec && !utility_bill_scenario . elec_tariff_filepath . nil?
747
- fuel . timeseries = get_report_meter_data_timeseries ( fuel . meters , unit_conv , 0 , timeseries_freq )
751
+ fuel . timeseries = get_report_meter_data_timeseries ( fuel . meters , unit_conv , timeseries_freq )
748
752
end
749
753
end
750
754
751
755
# Get the reported timeseries data from the fuel meters.
752
756
#
753
757
# @param meter_names [Array<String>] array of EnergyPlus meter names
754
758
# @param unit_conv [Double] the scalar that converts 1 Joule into units of the fuel meters
755
- # @param unit_adder [Double] the value to add after applying the scalar
756
759
# @param timeseries_freq [String] the frequency of the requested timeseries data
757
760
# @return [Array<Double>] array of timeseries data
758
- def get_report_meter_data_timeseries ( meter_names , unit_conv , unit_adder , timeseries_freq )
761
+ def get_report_meter_data_timeseries ( meter_names , unit_conv , timeseries_freq )
759
762
msgpack_timeseries_name = { 'hourly' => 'Hourly' ,
760
763
'monthly' => 'Monthly' } [ timeseries_freq ]
761
764
begin
@@ -766,12 +769,18 @@ def get_report_meter_data_timeseries(meter_names, unit_conv, unit_adder, timeser
766
769
return [ 0.0 ]
767
770
end
768
771
indexes = cols . each_index . select { |i | meter_names . include? cols [ i ] [ 'Variable' ] }
772
+ meter_names = indexes . each . collect { |i | cols [ i ] [ 'Variable' ] }
773
+ indexes = Hash [ indexes . zip ( meter_names ) ]
774
+
769
775
vals = [ ]
770
776
rows . each do |row |
771
777
row = row [ row . keys [ 0 ] ]
772
778
val = 0.0
773
- indexes . each do |i |
774
- val += row [ i ] * unit_conv + unit_adder
779
+ indexes . each do |i , meter_name |
780
+ r = row [ i ]
781
+ r *= -1 if [ "ElectricStorage:#{ EPlus ::FuelTypeElectricity } Produced" , "Cogeneration:#{ EPlus ::FuelTypeElectricity } Produced" ] . include? ( meter_name ) # positive for this meter means producing
782
+
783
+ val += r * unit_conv
775
784
end
776
785
vals << val
777
786
end
0 commit comments