@@ -202,18 +202,22 @@ def energyPlusOutputRequests(runner, user_arguments)
202202 has_fuel = hpxml . has_fuels ( Constants . FossilFuels , hpxml . to_doc )
203203 has_fuel [ HPXML ::FuelTypeElectricity ] = true
204204
205- # Fuel outputs
205+ # Has production
206206 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
207211 fuels . each do |( fuel_type , is_production ) , fuel |
208212 fuel . meters . each do |meter |
209213 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
211217
212218 result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,monthly;" ) . get
213219 if fuel_type == FT ::Elec && @hpxml_header . utility_bill_scenarios . has_detailed_electric_rates
214220 result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,hourly;" ) . get
215- else
216- result << OpenStudio ::IdfObject . load ( "Output:Meter,#{ meter } ,monthly;" ) . get
217221 end
218222 end
219223 end
@@ -698,8 +702,8 @@ def get_utility_bills(fuels, utility_rates, utility_bills, utility_bill_scenario
698702 # @return [Hash] Fuel type, is_production => Fuel object
699703 def setup_fuel_outputs ( )
700704 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 ) )
703707 fuels [ [ FT ::Gas , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeNaturalGas } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeNaturalGas ) )
704708 fuels [ [ FT ::Oil , false ] ] = Fuel . new ( meters : [ "#{ EPlus ::FuelTypeOil } :Facility" ] , units : UtilityBills . get_fuel_units ( HPXML ::FuelTypeOil ) )
705709 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)
744748
745749 timeseries_freq = 'monthly'
746750 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 )
748752 end
749753 end
750754
751755 # Get the reported timeseries data from the fuel meters.
752756 #
753757 # @param meter_names [Array<String>] array of EnergyPlus meter names
754758 # @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
756759 # @param timeseries_freq [String] the frequency of the requested timeseries data
757760 # @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 )
759762 msgpack_timeseries_name = { 'hourly' => 'Hourly' ,
760763 'monthly' => 'Monthly' } [ timeseries_freq ]
761764 begin
@@ -766,12 +769,18 @@ def get_report_meter_data_timeseries(meter_names, unit_conv, unit_adder, timeser
766769 return [ 0.0 ]
767770 end
768771 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+
769775 vals = [ ]
770776 rows . each do |row |
771777 row = row [ row . keys [ 0 ] ]
772778 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
775784 end
776785 vals << val
777786 end
0 commit comments