urbanopt-reporting 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +36 -0
  3. data/Rakefile +16 -6
  4. data/doc_templates/copyright_ruby.txt +17 -7
  5. data/lib/measures/default_feature_reports/measure.rb +121 -97
  6. data/lib/measures/default_feature_reports/measure.xml +11 -11
  7. data/lib/measures/export_modelica_loads/LICENSE.md +23 -23
  8. data/lib/measures/export_modelica_loads/measure.rb +93 -96
  9. data/lib/measures/export_modelica_loads/measure.xml +21 -21
  10. data/lib/measures/export_time_series_modelica/LICENSE.md +27 -1
  11. data/lib/measures/export_time_series_modelica/measure.rb +165 -163
  12. data/lib/measures/export_time_series_modelica/measure.xml +18 -18
  13. data/lib/measures/export_time_series_modelica/resources/os_lib_helper_methods.rb +40 -35
  14. data/lib/urbanopt/reporting.rb +16 -6
  15. data/lib/urbanopt/reporting/default_reports.rb +16 -6
  16. data/lib/urbanopt/reporting/default_reports/construction_cost.rb +16 -6
  17. data/lib/urbanopt/reporting/default_reports/date.rb +16 -6
  18. data/lib/urbanopt/reporting/default_reports/distributed_generation.rb +16 -6
  19. data/lib/urbanopt/reporting/default_reports/end_use.rb +54 -23
  20. data/lib/urbanopt/reporting/default_reports/end_uses.rb +16 -6
  21. data/lib/urbanopt/reporting/default_reports/extension.rb +16 -6
  22. data/lib/urbanopt/reporting/default_reports/feature_report.rb +21 -7
  23. data/lib/urbanopt/reporting/default_reports/generator.rb +16 -6
  24. data/lib/urbanopt/reporting/default_reports/location.rb +16 -6
  25. data/lib/urbanopt/reporting/default_reports/logger.rb +16 -6
  26. data/lib/urbanopt/reporting/default_reports/power_distribution.rb +16 -6
  27. data/lib/urbanopt/reporting/default_reports/program.rb +17 -7
  28. data/lib/urbanopt/reporting/default_reports/reporting_period.rb +16 -6
  29. data/lib/urbanopt/reporting/default_reports/scenario_report.rb +25 -13
  30. data/lib/urbanopt/reporting/default_reports/schema/scenario_csv_columns.txt +11 -10
  31. data/lib/urbanopt/reporting/default_reports/schema/scenario_schema.json +4 -1
  32. data/lib/urbanopt/reporting/default_reports/solar_pv.rb +16 -6
  33. data/lib/urbanopt/reporting/default_reports/storage.rb +16 -6
  34. data/lib/urbanopt/reporting/default_reports/thermal_storage.rb +16 -6
  35. data/lib/urbanopt/reporting/default_reports/timeseries_csv.rb +17 -7
  36. data/lib/urbanopt/reporting/default_reports/validator.rb +16 -6
  37. data/lib/urbanopt/reporting/default_reports/wind.rb +16 -6
  38. data/lib/urbanopt/reporting/derived_extension.rb +16 -6
  39. data/lib/urbanopt/reporting/version.rb +17 -7
  40. data/urbanopt-reporting-gem.gemspec +3 -3
  41. metadata +9 -9
@@ -1,41 +1,47 @@
1
- # *******************************************************************************
2
- # OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC.
3
- # All rights reserved.
4
- # Redistribution and use in source and binary forms, with or without
5
- # modification, are permitted provided that the following conditions are met:
6
- #
7
- # (1) Redistributions of source code must retain the above copyright notice,
8
- # this list of conditions and the following disclaimer.
9
- #
10
- # (2) Redistributions in binary form must reproduce the above copyright notice,
11
- # this list of conditions and the following disclaimer in the documentation
12
- # and/or other materials provided with the distribution.
13
- #
14
- # (3) Neither the name of the copyright holder nor the names of any contributors
15
- # may be used to endorse or promote products derived from this software without
16
- # specific prior written permission from the respective party.
17
- #
18
- # (4) Other than as required in clauses (1) and (2), distributions in any form
19
- # of modifications or other derivative works may not use the "OpenStudio"
20
- # trademark, "OS", "os", or any other confusingly similar designation without
21
- # specific prior written permission from Alliance for Sustainable Energy, LLC.
22
- #
23
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS
24
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25
- # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26
- # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE
27
- # UNITED STATES GOVERNMENT, OR THE UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF
28
- # THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
30
- # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31
- # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
- # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33
- # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
- # *******************************************************************************
1
+ # *********************************************************************************
2
+ # URBANopt™, Copyright (c) 2019-2021, Alliance for Sustainable Energy, LLC, and other
3
+ # contributors. All rights reserved.
4
+
5
+ # Redistribution and use in source and binary forms, with or without modification,
6
+ # are permitted provided that the following conditions are met:
7
+
8
+ # Redistributions of source code must retain the above copyright notice, this list
9
+ # of conditions and the following disclaimer.
10
+
11
+ # Redistributions in binary form must reproduce the above copyright notice, this
12
+ # list of conditions and the following disclaimer in the documentation and/or other
13
+ # materials provided with the distribution.
14
+
15
+ # Neither the name of the copyright holder nor the names of its contributors may be
16
+ # used to endorse or promote products derived from this software without specific
17
+ # prior written permission.
18
+
19
+ # Redistribution of this software, without modification, must refer to the software
20
+ # by the same designation. Redistribution of a modified version of this software
21
+ # (i) may not refer to the modified version by the same designation, or by any
22
+ # confusingly similar designation, and (ii) must refer to the underlying software
23
+ # originally provided by Alliance as “URBANopt”. Except to comply with the foregoing,
24
+ # the term “URBANopt”, or any confusingly similar designation may not be used to
25
+ # refer to any modified version of this software or any modified version of the
26
+ # underlying software originally provided by Alliance without the prior written
27
+ # consent of Alliance.
28
+
29
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
30
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32
+ # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
+ # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
37
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
38
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
39
+ # *********************************************************************************
35
40
 
36
41
  require 'erb'
37
42
 
38
43
 
44
+ # This measure is originally from https://github.com/urbanopt/DES_HVAC
39
45
  # start the measure
40
46
  class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
41
47
  Dir[File.dirname(__FILE__) + '/resources/*.rb'].each { |file| require file }
@@ -61,25 +67,25 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
61
67
  puts "#{Time.now}: #{str}"
62
68
  end
63
69
 
64
- def arguments(_model)
70
+ def arguments(_model)
65
71
  args = OpenStudio::Measure::OSArgumentVector.new
66
-
72
+
67
73
  hhw_loop_name = OpenStudio::Measure::OSArgument.makeStringArgument('hhw_loop_name', true)
68
74
  hhw_loop_name.setDisplayName('Name or Partial Name of Heating Hot Water Loop, non-case-sensitive')
69
75
  hhw_loop_name.setDefaultValue('hot')
70
76
  args << hhw_loop_name
71
-
72
- chw_loop_name = OpenStudio::Measure::OSArgument.makeStringArgument('chw_loop_name', true)
77
+
78
+ chw_loop_name = OpenStudio::Measure::OSArgument.makeStringArgument('chw_loop_name', true)
73
79
  chw_loop_name.setDisplayName('Name or Partial Name of Chilled Water Loop, non-case-sensitive')
74
80
  chw_loop_name.setDefaultValue('chilled')
75
81
  args << chw_loop_name
76
-
77
- dec_places_mass_flow = OpenStudio::Measure::OSArgument.makeIntegerArgument('dec_places_mass_flow', true)
82
+
83
+ dec_places_mass_flow = OpenStudio::Measure::OSArgument.makeIntegerArgument('dec_places_mass_flow', true)
78
84
  dec_places_mass_flow.setDisplayName('Number of Decimal Places to Round Mass Flow Rate')
79
85
  dec_places_mass_flow.setDescription('Number of decimal places to which mass flow rate will be rounded')
80
86
  dec_places_mass_flow.setDefaultValue(3)
81
87
  args << dec_places_mass_flow
82
-
88
+
83
89
  dec_places_temp = OpenStudio::Measure::OSArgument.makeIntegerArgument('dec_places_temp', true)
84
90
  dec_places_temp.setDisplayName('Number of Decimal Places to Round Temperature')
85
91
  dec_places_temp.setDescription('Number of decimal places to which temperature will be rounded')
@@ -94,7 +100,6 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
94
100
  super(runner, user_arguments)
95
101
 
96
102
  result = OpenStudio::IdfObjectVector.new
97
-
98
103
 
99
104
  # To use the built-in error checking we need the model...
100
105
  # get the last model and sql file
@@ -107,53 +112,50 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
107
112
 
108
113
  # use the built-in error checking
109
114
  return false unless runner.validateUserArguments(arguments(model), user_arguments)
110
-
111
- ##Read in argumetns related to variables for output requests
112
- hhw_loop_name = runner.getStringArgumentValue('hhw_loop_name', user_arguments)
113
- chw_loop_name = runner.getStringArgumentValue('chw_loop_name', user_arguments)
114
-
115
115
 
116
- #Identify key names for output variables.
117
- plantloops = model.getPlantLoops
116
+ ##Read in argumetns related to variables for output requests
117
+ hhw_loop_name = runner.getStringArgumentValue('hhw_loop_name', user_arguments)
118
+ chw_loop_name = runner.getStringArgumentValue('chw_loop_name', user_arguments)
119
+
120
+ #Identify key names for output variables.
121
+ plantloops = model.getPlantLoops
118
122
 
119
123
  selected_plant_loops = []
120
124
  i = 0
121
-
122
- variable_name1 = 'System Node Mass Flow Rate'
123
- variable_name2 = 'System Node Temperature'
124
- reporting_frequency = 'timestep'
125
125
 
126
-
126
+ variable_name1 = 'System Node Mass Flow Rate'
127
+ variable_name2 = 'System Node Temperature'
128
+ reporting_frequency = 'timestep'
129
+
127
130
  plantloops.each do |plantLoop|
128
- log "plant loop name #{plantLoop.name.get.to_s}"
129
- if plantLoop.name.get.to_s.downcase.include? chw_loop_name.to_s
130
- #Extract plant loop information
131
- selected_plant_loops[0]=plantLoop
132
- key_value_chw_outlet = selected_plant_loops[0].demandOutletNode.name.to_s
133
- key_value_chw_inlet = selected_plant_loops[0].demandInletNode.name.to_s
134
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_outlet},#{variable_name2},timestep;").get
135
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_inlet},#{variable_name2},timestep;").get
136
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_outlet},#{variable_name1},timestep;").get
137
- end
138
- if plantLoop.name.get.to_s.downcase.include? hhw_loop_name.to_s and !plantLoop.name.get.to_s.downcase.include? "service" and !plantLoop.name.get.to_s.downcase.include? "domestic"
139
- #Extract plant loop information
140
- selected_plant_loops[1]=plantLoop
141
- key_value_hhw_outlet = selected_plant_loops[1].demandOutletNode.name.to_s
142
- key_value_hhw_inlet = selected_plant_loops[1].demandInletNode.name.to_s
143
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_outlet},#{variable_name2},timestep;").get
144
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_inlet},#{variable_name2},timestep;").get
145
- result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_outlet},#{variable_name1},timestep;").get
146
- end
147
- end
148
-
131
+ log "plant loop name #{plantLoop.name.get.to_s}"
132
+ if plantLoop.name.get.to_s.downcase.include? chw_loop_name.to_s
133
+ #Extract plant loop information
134
+ selected_plant_loops[0]=plantLoop
135
+ key_value_chw_outlet = selected_plant_loops[0].demandOutletNode.name.to_s
136
+ key_value_chw_inlet = selected_plant_loops[0].demandInletNode.name.to_s
137
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_outlet},#{variable_name2},timestep;").get
138
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_inlet},#{variable_name2},timestep;").get
139
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_chw_outlet},#{variable_name1},timestep;").get
140
+ end
141
+ if plantLoop.name.get.to_s.downcase.include? hhw_loop_name.to_s and !plantLoop.name.get.to_s.downcase.include? "service" and !plantLoop.name.get.to_s.downcase.include? "domestic"
142
+ #Extract plant loop information
143
+ selected_plant_loops[1]=plantLoop
144
+ key_value_hhw_outlet = selected_plant_loops[1].demandOutletNode.name.to_s
145
+ key_value_hhw_inlet = selected_plant_loops[1].demandInletNode.name.to_s
146
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_outlet},#{variable_name2},timestep;").get
147
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_inlet},#{variable_name2},timestep;").get
148
+ result << OpenStudio::IdfObject.load("Output:Variable,#{key_value_hhw_outlet},#{variable_name1},timestep;").get
149
+ end
150
+ end
149
151
 
150
152
  result << OpenStudio::IdfObject.load('Output:Variable,,Site Mains Water Temperature,hourly;').get
151
153
  result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,hourly;').get
152
154
  result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Relative Humidity,hourly;').get
153
155
  result << OpenStudio::IdfObject.load('Output:Meter,Cooling:Electricity,hourly;').get
154
- result << OpenStudio::IdfObject.load('Output:Meter,Cooling:Electricity,timestep;').get ##Using this for data at timestep interval
156
+ result << OpenStudio::IdfObject.load('Output:Meter,Electricity:Facility,timestep;').get ##Using this for data at timestep interval
155
157
  result << OpenStudio::IdfObject.load('Output:Meter,Heating:Electricity,hourly;').get
156
- result << OpenStudio::IdfObject.load('Output:Meter,Heating:Gas,hourly;').get
158
+ result << OpenStudio::IdfObject.load('Output:Meter,Heating:NaturalGas,hourly;').get
157
159
  result << OpenStudio::IdfObject.load('Output:Meter,InteriorLights:Electricity,hourly;').get
158
160
  result << OpenStudio::IdfObject.load('Output:Meter,Fans:Electricity,hourly;').get
159
161
  result << OpenStudio::IdfObject.load('Output:Meter,InteriorEquipment:Electricity,hourly;').get # Joules
@@ -169,17 +171,16 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
169
171
  result
170
172
  end
171
173
 
172
- def extract_timeseries_into_matrix(sqlfile, data, variable_name, str, key_value = nil, default_if_empty = 0,dec_places, timestep)
174
+ def extract_timeseries_into_matrix(sqlfile, data, variable_name, str, key_value = nil, default_if_empty = 0,dec_places, timestep)
173
175
  log "Executing query for #{variable_name}"
174
176
  #column_name = variable_name
175
177
  if key_value
176
- #ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name, key_value)
177
- ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name, key_value)
178
+ ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name, key_value)
178
179
  #column_name += "_#{key_value}"
179
- column_name=str
180
+ column_name=str
180
181
  else
181
182
  #ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name)
182
- ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name)
183
+ ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name)
183
184
  end
184
185
  log 'Iterating over timeseries'
185
186
  column = [column_name.delete(':').delete(' ')] # Set the header of the data to the variable name, removing : and spaces
@@ -191,7 +192,7 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
191
192
  else
192
193
  ts = ts.get if ts.respond_to?(:get)
193
194
  ts = ts.first if ts.respond_to?(:first)
194
-
195
+
195
196
  start = Time.now
196
197
  # Iterating in OpenStudio can take up to 60 seconds with 10min data. The quick_proc takes 0.03 seconds.
197
198
  # for i in 0..ts.values.size - 1
@@ -200,24 +201,21 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
200
201
  # end
201
202
 
202
203
  quick_proc = ts.values.to_s.split(',')
203
- quick_proc[0]=quick_proc[0].split('(', 2).last #cleanup necessary to remove opening paren
204
- quick_proc=quick_proc.map(&:to_f)
205
- x = 0
204
+ quick_proc[0]=quick_proc[0].split('(', 2).last #cleanup necessary to remove opening paren
205
+ quick_proc=quick_proc.map(&:to_f)
206
+ x = 0
206
207
  len = quick_proc.length
207
- log "quick proc #{quick_proc}"
208
- while(x < len) #Round to the # of decimal places specified
208
+ log "quick proc #{quick_proc}"
209
+ while(x < len) #Round to the # of decimal places specified
209
210
  quick_proc[x]=(quick_proc[x]).round(dec_places)
210
211
  x=x+1
211
- end
212
- quick_proc=quick_proc.map(&:to_s)
212
+ end
213
+ quick_proc=quick_proc.map(&:to_s)
213
214
 
214
-
215
215
  # the first and last have some cleanup items because of the Vector method
216
- quick_proc[0] = quick_proc[0].gsub(/^.*\(/, '')
217
- quick_proc[-1] = quick_proc[-1].delete(')')
216
+ quick_proc[0] = quick_proc[0].gsub(/^.*\(/, '')
217
+ quick_proc[-1] = quick_proc[-1].delete(')')
218
218
  column += quick_proc
219
-
220
-
221
219
 
222
220
  log "Took #{Time.now - start} to iterate"
223
221
  end
@@ -279,9 +277,11 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
279
277
 
280
278
  # use the built-in error checking
281
279
  return false unless runner.validateUserArguments(arguments(model), user_arguments)
282
-
283
- args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
284
- if !args then return false end
280
+
281
+ args = OsLib_HelperMethods.createRunVariables(runner, model, user_arguments, arguments(model))
282
+ if !args
283
+ return false
284
+ end
285
285
 
286
286
  # lookup and replace argument values from upstream measures
287
287
  if args['use_upstream_args'] == true
@@ -291,7 +291,7 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
291
291
  if !value_from_osw.empty?
292
292
  runner.registerInfo("Replacing argument named #{arg} from current measure with a value of #{value_from_osw[:value]} from #{value_from_osw[:measure_name]}.")
293
293
  new_val = value_from_osw[:value]
294
- # todo - make code to handle non strings more robust. check_upstream_measure_for_arg could pass bakc the argument type
294
+ # TODO: make code to handle non strings more robust. check_upstream_measure_for_arg could pass back the argument type
295
295
  if arg == 'hhw_loop_name'
296
296
  args[arg] = new_val.to_s
297
297
  elsif arg == 'chw_loop_name'
@@ -303,9 +303,9 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
303
303
  end
304
304
  end
305
305
  hhw_loop_name = args['hhw_loop_name']
306
- chw_loop_name = args['chw_loop_name']
307
- dec_places_temp = args['dec_places_temp']
308
- dec_places_mass_flow = args['dec_places_mass_flow']
306
+ chw_loop_name = args['chw_loop_name']
307
+ dec_places_temp = args['dec_places_temp']
308
+ dec_places_mass_flow = args['dec_places_mass_flow']
309
309
  # get the last model and sql file
310
310
  model = runner.lastOpenStudioModel
311
311
  if model.empty?
@@ -313,10 +313,9 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
313
313
  return false
314
314
  end
315
315
  model = model.get
316
-
317
316
 
318
- timesteps_per_hour=model.getTimestep.numberOfTimestepsPerHour.to_i
319
- timestep=60/timesteps_per_hour #timestep in minutes
317
+ timesteps_per_hour=model.getTimestep.numberOfTimestepsPerHour.to_i
318
+ timestep=60/timesteps_per_hour #timestep in minutes
320
319
 
321
320
  sqlFile = runner.lastEnergyPlusSqlFile
322
321
  if sqlFile.empty?
@@ -339,9 +338,12 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
339
338
  ]
340
339
 
341
340
  # just grab one of the variables to get the date/time stamps
342
- ts = sqlFile.timeSeries('RUN PERIOD 1', 'Zone Timestep', 'Cooling:Electricity')
343
- #ts = sqlFile.timeSeries('RUN PERIOD 1', 'Hourly', 'Cooling:Electricity')
344
- unless ts.empty?
341
+ attribute_name = 'Electricity:Facility'
342
+ ts = sqlFile.timeSeries('RUN PERIOD 1', 'Zone Timestep', attribute_name)
343
+ if ts.empty?
344
+ runner.registerError("This feature does not have the attribute '#{attribute_name}' to enable this measure to work." \
345
+ "To resolve, simulate a building with electricity or remove this measure from your workflow.")
346
+ else
345
347
  ts = ts.first
346
348
  dt_base = nil
347
349
  # Save off the date time values
@@ -355,7 +357,7 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
355
357
  dt.date.dayOfWeek.value,
356
358
  dt.time.hours,
357
359
  dt.time.minutes,
358
- dt_current.to_time.to_i - dt_base.to_time.to_i + timestep*60
360
+ dt_current.to_time.to_i - dt_base.to_time.to_i + timestep*60
359
361
  ]
360
362
  end
361
363
  end
@@ -364,69 +366,69 @@ class ExportTimeSeriesLoadsCSV < OpenStudio::Measure::ReportingMeasure
364
366
 
365
367
  selected_plant_loops = []
366
368
  i = 0
367
-
368
- key_var={}
369
+
370
+ key_var={}
369
371
 
370
372
  plantloops.each do |plantLoop|
371
- if plantLoop.name.get.to_s.downcase.include? chw_loop_name.to_str
372
- #Extract plant loop information
373
- selected_plant_loops[0]=plantLoop
374
- end
375
- if plantLoop.name.get.to_s.downcase.include? hhw_loop_name.to_str
376
- #Get plant loop information
377
- selected_plant_loops[1]=plantLoop
378
- end
373
+ if plantLoop.name.get.to_s.downcase.include? chw_loop_name.to_str
374
+ #Extract plant loop information
375
+ selected_plant_loops[0]=plantLoop
376
+ end
377
+ if plantLoop.name.get.to_s.downcase.include? hhw_loop_name.to_str
378
+ #Get plant loop information
379
+ selected_plant_loops[1]=plantLoop
380
+ end
381
+ end
382
+
383
+ if !selected_plant_loops[1].nil?
384
+ #Set up variables for output
385
+ key_value_hhw_outlet = selected_plant_loops[1].demandOutletNode.name.to_s
386
+ key_value_hhw_inlet = selected_plant_loops[1].demandInletNode.name.to_s
387
+ key_var['hhw_outlet_massflow']='massFlowRateHeating'
388
+ key_var['hhw_outlet_temp']='heatingReturnTemperature[C]'
389
+ key_var['hhw_inlet_temp']='heatingSupplyTemperature[C]'
390
+ #Extract time series
391
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['hhw_outlet_temp'], key_value_hhw_outlet, 0, dec_places_temp, timestep)
392
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['hhw_inlet_temp'], key_value_hhw_inlet, 0, dec_places_temp, timestep)
393
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Mass Flow Rate', key_var['hhw_outlet_massflow'], key_value_hhw_outlet, 0, dec_places_mass_flow, timestep)
394
+ else
395
+ runner.registerWarning("No hot water loop found. If one is expected, make sure the hot water loop name argument provides a string present in its name.")
379
396
  end
380
-
381
- if !selected_plant_loops[1].nil?
382
- #Set up variables for output
383
- key_value_hhw_outlet = selected_plant_loops[1].demandOutletNode.name.to_s
384
- key_value_hhw_inlet = selected_plant_loops[1].demandInletNode.name.to_s
385
- key_var['hhw_outlet_massflow']='massFlowRateHeating'
386
- key_var['hhw_outlet_temp']='heatingReturnTemperature[C]'
387
- key_var['hhw_inlet_temp']='heatingSupplyTemperature[C]'
388
- #Extract time series
389
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['hhw_outlet_temp'], key_value_hhw_outlet, 0, dec_places_temp, timestep)
390
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['hhw_inlet_temp'], key_value_hhw_inlet, 0, dec_places_temp, timestep)
391
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Mass Flow Rate', key_var['hhw_outlet_massflow'], key_value_hhw_outlet, 0, dec_places_mass_flow, timestep)
392
- else
393
- runner.registerWarning("No hot water loop found. If one is expected, make sure the hot water loop name argument provides a string present in its name.")
394
- end
395
-
396
- if !selected_plant_loops[0].nil?
397
- #Set up variables for outputs
398
- key_value_chw_outlet = selected_plant_loops[0].demandOutletNode.name.to_s
399
- key_value_chw_inlet = selected_plant_loops[0].demandInletNode.name.to_s
400
- key_var['chw_outlet_massflow']='massFlowRateCooling'
401
- key_var['chw_outlet_temp']='ChilledWaterReturnTemperature[C]'
402
- key_var['chw_inlet_temp']='ChilledWaterSupplyTemperature[C]'
403
- #Extract time series
404
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['chw_outlet_temp'], key_value_chw_outlet, 0, dec_places_temp,timestep)
405
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['chw_inlet_temp'], key_value_chw_inlet, 0, dec_places_temp,timestep)
406
- extract_timeseries_into_matrix(sqlFile, rows, 'System Node Mass Flow Rate', key_var['chw_outlet_massflow'], key_value_chw_outlet, 0, dec_places_mass_flow,timestep)
407
- else
408
- runner.registerWarning("No chilled water loop found. If one is expected, make sure the chilled water loop name argument provides a string present in its name.")
409
- end
410
-
411
-
412
- if selected_plant_loops[0].nil? and selected_plant_loops[1].nil?
413
- runner.registerWarning("No HVAC plant loops found. If one or more plant loops are expected, make sure they follow the naming conventions mentioned in the previous warnings.")
414
- end
415
-
416
- if !selected_plant_loops.nil?
417
- # convert this to CSV object
418
- File.open('./building_loads.csv', 'w') do |f|
419
- rows.each do |row|
420
- f << row.join(',') << "\n"
397
+
398
+ if !selected_plant_loops[0].nil?
399
+ #Set up variables for outputs
400
+ key_value_chw_outlet = selected_plant_loops[0].demandOutletNode.name.to_s
401
+ key_value_chw_inlet = selected_plant_loops[0].demandInletNode.name.to_s
402
+ key_var['chw_outlet_massflow']='massFlowRateCooling'
403
+ key_var['chw_outlet_temp']='ChilledWaterReturnTemperature[C]'
404
+ key_var['chw_inlet_temp']='ChilledWaterSupplyTemperature[C]'
405
+ #Extract time series
406
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['chw_outlet_temp'], key_value_chw_outlet, 0, dec_places_temp,timestep)
407
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Temperature', key_var['chw_inlet_temp'], key_value_chw_inlet, 0, dec_places_temp,timestep)
408
+ extract_timeseries_into_matrix(sqlFile, rows, 'System Node Mass Flow Rate', key_var['chw_outlet_massflow'], key_value_chw_outlet, 0, dec_places_mass_flow,timestep)
409
+ else
410
+ runner.registerWarning("No chilled water loop found. If one is expected, make sure the chilled water loop name argument provides a string present in its name.")
411
+ end
412
+
413
+
414
+ if selected_plant_loops[0].nil? and selected_plant_loops[1].nil?
415
+ runner.registerWarning("No HVAC plant loops found. If one or more plant loops are expected, make sure they follow the naming conventions mentioned in the previous warnings.")
416
+ end
417
+
418
+ if !selected_plant_loops.nil?
419
+ # convert this to CSV object
420
+ File.open('./building_loads.csv', 'w') do |f|
421
+ rows.each do |row|
422
+ f << row.join(',') << "\n"
423
+ end
421
424
  end
422
- end
423
- end
425
+ end
424
426
 
425
427
  true
426
428
  ensure
427
429
  sqlFile&.close
428
430
  end
429
- end
431
+ end
430
432
 
431
433
 
432
434
  # register the measure to be used by the application