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,10 +1,11 @@
1
1
  <?xml version="1.0"?>
2
2
  <measure>
3
3
  <schema_version>3.0</schema_version>
4
+ <error>wrong number of arguments (given 1, expected 0)</error>
4
5
  <name>default_feature_reports</name>
5
6
  <uid>9ee3135a-8070-4408-bfa1-b75fecf9dd4f</uid>
6
- <version_id>d4f5b2e2-f93d-4ce2-9c68-ed29714fdc0c</version_id>
7
- <version_modified>20201208T230102Z</version_modified>
7
+ <version_id>136d51d4-9a61-48cd-b068-0e02c4094e76</version_id>
8
+ <version_modified>20210427T174740Z</version_modified>
8
9
  <xml_checksum>FB304155</xml_checksum>
9
10
  <class_name>DefaultFeatureReports</class_name>
10
11
  <display_name>DefaultFeatureReports</display_name>
@@ -120,12 +121,6 @@
120
121
  <usage_type>readmeerb</usage_type>
121
122
  <checksum>703C9964</checksum>
122
123
  </file>
123
- <file>
124
- <filename>example_model.osm</filename>
125
- <filetype>osm</filetype>
126
- <usage_type>test</usage_type>
127
- <checksum>CC4BFFAF</checksum>
128
- </file>
129
124
  <file>
130
125
  <filename>README.md</filename>
131
126
  <filetype>md</filetype>
@@ -138,11 +133,17 @@
138
133
  <usage_type>license</usage_type>
139
134
  <checksum>BBD19F47</checksum>
140
135
  </file>
136
+ <file>
137
+ <filename>example_model.osm</filename>
138
+ <filetype>osm</filetype>
139
+ <usage_type>test</usage_type>
140
+ <checksum>A178EC04</checksum>
141
+ </file>
141
142
  <file>
142
143
  <filename>default_feature_reports_test.rb</filename>
143
144
  <filetype>rb</filetype>
144
145
  <usage_type>test</usage_type>
145
- <checksum>19681175</checksum>
146
+ <checksum>0C4ED2E7</checksum>
146
147
  </file>
147
148
  <file>
148
149
  <version>
@@ -153,8 +154,7 @@
153
154
  <filename>measure.rb</filename>
154
155
  <filetype>rb</filetype>
155
156
  <usage_type>script</usage_type>
156
- <checksum>48AEB753</checksum>
157
+ <checksum>CD1AFD42</checksum>
157
158
  </file>
158
159
  </files>
159
160
  </measure>
160
- <error>wrong number of arguments (given 1, expected 0)</error>
@@ -1,27 +1,27 @@
1
- OpenStudio(R), Copyright (c) 2008-2020, Alliance for Sustainable Energy, LLC. All rights reserved.
1
+ URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ contributors. All rights reserved.
2
3
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted
4
- provided that the following conditions are met:
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
5
6
 
6
- (1) Redistributions of source code must retain the above copyright notice, this list of conditions
7
- and the following disclaimer.
7
+ Redistributions of source code must retain the above copyright notice, this list
8
+ of conditions and the following disclaimer.
8
9
 
9
- (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions
10
- and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+ Redistributions in binary form must reproduce the above copyright notice, this
11
+ list of conditions and the following disclaimer in the documentation and/or other
12
+ materials provided with the distribution.
13
+
14
+ Neither the name of the copyright holder nor the names of its contributors may be
15
+ used to endorse or promote products derived from this software without specific
16
+ prior written permission.
11
17
 
12
- (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse
13
- or promote products derived from this software without specific prior written permission from the
14
- respective party.
15
-
16
- (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other
17
- derivative works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar
18
- designation without specific prior written permission from Alliance for Sustainable Energy, LLC.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
21
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT,
23
- OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
25
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27
+ OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,40 +1,46 @@
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
 
43
+ # This measure is originally from https://github.com/urbanopt/DES_HVAC
38
44
  # start the measure
39
45
  class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
40
46
  # human readable name
@@ -67,52 +73,38 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
67
73
  super(runner, user_arguments)
68
74
 
69
75
  result = OpenStudio::IdfObjectVector.new
70
-
71
- # To use the built-in error checking we need the model...
72
- # get the last model and sql file
73
- model = runner.lastOpenStudioModel
74
- if model.empty?
75
- runner.registerError('Cannot find last model.')
76
- return false
77
- end
78
- model = model.get
79
-
80
- # use the built-in error checking
81
- if !runner.validateUserArguments(arguments(model), user_arguments)
82
- return false
83
- end
84
-
85
- result << OpenStudio::IdfObject.load('Output:Variable,,Site Mains Water Temperature,hourly;').get
86
- result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,hourly;').get
87
- result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Relative Humidity,hourly;').get
88
- result << OpenStudio::IdfObject.load('Output:Meter,Cooling:Electricity,hourly;').get
89
- result << OpenStudio::IdfObject.load('Output:Meter,Heating:Electricity,hourly;').get
90
- result << OpenStudio::IdfObject.load('Output:Meter,Heating:Gas,hourly;').get
91
- result << OpenStudio::IdfObject.load('Output:Meter,InteriorLights:Electricity,hourly;').get
92
- result << OpenStudio::IdfObject.load('Output:Meter,Fans:Electricity,hourly;').get
93
- result << OpenStudio::IdfObject.load('Output:Meter,InteriorEquipment:Electricity,hourly;').get # Joules
94
- result << OpenStudio::IdfObject.load('Output:Meter,ExteriorLighting:Electricity,hourly;').get # Joules
95
- result << OpenStudio::IdfObject.load('Output:Meter,Electricity:Facility,hourly;').get # Joules
96
- result << OpenStudio::IdfObject.load('Output:Meter,Gas:Facility,hourly;').get # Joules
97
- result << OpenStudio::IdfObject.load('Output:Meter,Heating:EnergyTransfer,hourly;').get # Joules
98
- result << OpenStudio::IdfObject.load('Output:Meter,WaterSystems:EnergyTransfer,hourly;').get # Joules
76
+ result << OpenStudio::IdfObject.load('Output:Variable,,Site Mains Water Temperature,timestep;').get
77
+ result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Drybulb Temperature,timestep;').get
78
+ result << OpenStudio::IdfObject.load('Output:Variable,,Site Outdoor Air Relative Humidity,timestep;').get
79
+ result << OpenStudio::IdfObject.load('Output:Meter,Cooling:Electricity,timestep;').get
80
+ result << OpenStudio::IdfObject.load('Output:Meter,Heating:Electricity,timestep;').get
81
+ result << OpenStudio::IdfObject.load('Output:Meter,Heating:NaturalGas,timestep;').get
82
+ result << OpenStudio::IdfObject.load('Output:Meter,InteriorLights:Electricity,timestep;').get
83
+ result << OpenStudio::IdfObject.load('Output:Meter,Fans:Electricity,timestep;').get
84
+ result << OpenStudio::IdfObject.load('Output:Meter,InteriorEquipment:Electricity,timestep;').get # Joules
85
+ result << OpenStudio::IdfObject.load('Output:Meter,ExteriorLighting:Electricity,timestep;').get # Joules
86
+ result << OpenStudio::IdfObject.load('Output:Meter,Electricity:Facility,timestep;').get # Joules
87
+ result << OpenStudio::IdfObject.load('Output:Meter,Electricity:Facility,timestep;').get # #Using this for data at timestep interval
88
+ result << OpenStudio::IdfObject.load('Output:Meter,Gas:Facility,timestep;').get # Joules
89
+ result << OpenStudio::IdfObject.load('Output:Meter,Heating:EnergyTransfer,timestep;').get # Joules
90
+ result << OpenStudio::IdfObject.load('Output:Meter,WaterSystems:EnergyTransfer,timestep;').get # Joules
99
91
  # these variables are used for the modelica export.
100
- result << OpenStudio::IdfObject.load('Output:Variable,*,Zone Predicted Sensible Load to Setpoint Heat Transfer Rate,hourly;').get # watts according to e+
101
- result << OpenStudio::IdfObject.load('Output:Variable,*,Water Heater Total Demand Heat Transfer Rate,hourly;').get # Watts
92
+ result << OpenStudio::IdfObject.load('Output:Variable,*,Zone Predicted Sensible Load to Setpoint Heat Transfer Rate,timestep;').get # watts according to e+
93
+ result << OpenStudio::IdfObject.load('Output:Variable,*,Water Heater Total Demand Heat Transfer Rate,timestep;').get # Watts
102
94
 
103
95
  return result
104
96
  end
105
97
 
106
- def extract_timeseries_into_matrix(sqlfile, data, variable_name, key_value = nil, default_if_empty=0)
98
+ def extract_timeseries_into_matrix(sqlfile, data, variable_name, key_value = nil, default_if_empty = 0, timestep)
107
99
  log "Executing query for #{variable_name}"
108
100
  column_name = variable_name
109
101
  if key_value
110
- ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name, key_value)
111
- # ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name, key_value)
102
+ # ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name, key_value)
103
+ ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name, key_value)
112
104
  column_name += "_#{key_value}"
113
105
  else
114
- ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name)
115
- # ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name)
106
+ # ts = sqlfile.timeSeries('RUN PERIOD 1', 'Hourly', variable_name)
107
+ ts = sqlfile.timeSeries('RUN PERIOD 1', 'Zone Timestep', variable_name)
116
108
  end
117
109
  log 'Iterating over timeseries'
118
110
  column = [column_name.delete(':').delete(' ')] # Set the header of the data to the variable name, removing : and spaces
@@ -120,7 +112,7 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
120
112
  if ts.empty?
121
113
  log "No time series for #{variable_name}:#{key_value}... defaulting to #{default_if_empty}"
122
114
  # needs to be data.size-1 since the column name is already stored above (+=)
123
- column += [default_if_empty] * (data.size-1)
115
+ column += [default_if_empty] * (data.size - 1)
124
116
  else
125
117
  ts = ts.get if ts.respond_to?(:get)
126
118
  ts = ts.first if ts.respond_to?(:first)
@@ -154,10 +146,10 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
154
146
  log "Finished extracting #{variable_name}"
155
147
  end
156
148
 
157
- def create_new_variable_sum(data, new_var_name, include_str, options=nil)
149
+ def create_new_variable_sum(data, new_var_name, include_str, options = nil)
158
150
  var_info = {
159
- name: new_var_name,
160
- var_indexes: []
151
+ name: new_var_name,
152
+ var_indexes: []
161
153
  }
162
154
  data.each_with_index do |row, index|
163
155
  if index.zero?
@@ -212,6 +204,9 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
212
204
  end
213
205
  model = model.get
214
206
 
207
+ timesteps_per_hour = model.getTimestep.numberOfTimestepsPerHour.to_i
208
+ timestep = 60 / timesteps_per_hour # timestep in minutes
209
+
215
210
  sqlFile = runner.lastEnergyPlusSqlFile
216
211
  if sqlFile.empty?
217
212
  runner.registerError('Cannot find last sql file.')
@@ -233,45 +228,47 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
233
228
  ]
234
229
 
235
230
  # just grab one of the variables to get the date/time stamps
236
- # ts = sqlFile.timeSeries('RUN PERIOD 1', 'Zone Timestep', 'Cooling:Electricity')
237
- ts = sqlFile.timeSeries('RUN PERIOD 1', 'Hourly', 'Cooling:Electricity')
238
- unless ts.empty?
231
+ attribute_name = 'Electricity:Facility'
232
+ ts = sqlFile.timeSeries('RUN PERIOD 1', 'Zone Timestep', attribute_name)
233
+ if ts.empty?
234
+ runner.registerError("This feature does not have the attribute '#{attribute_name}' to enable this measure to work." \
235
+ 'To resolve, simulate a building with electricity or remove this measure from your workflow.')
236
+ else
239
237
  ts = ts.first
240
238
  dt_base = nil
241
239
  # Save off the date time values
242
240
  ts.dateTimes.each_with_index do |dt, index|
243
- runner.registerInfo("My index is #{index}")
244
241
  dt_base = DateTime.parse(dt.to_s) if dt_base.nil?
245
242
  dt_current = DateTime.parse(dt.to_s)
246
243
  rows << [
247
244
  DateTime.parse(dt.to_s).strftime('%m/%d/%Y %H:%M'),
248
- dt.date.monthOfYear.value,
249
- dt.date.dayOfMonth,
250
- dt.date.dayOfWeek.value,
251
- dt.time.hours,
252
- dt.time.minutes,
253
- dt_current.to_time.to_i - dt_base.to_time.to_i
245
+ dt.date.monthOfYear.value,
246
+ dt.date.dayOfMonth,
247
+ dt.date.dayOfWeek.value,
248
+ dt.time.hours,
249
+ dt.time.minutes,
250
+ dt_current.to_time.to_i - dt_base.to_time.to_i + timestep * 60
254
251
  ]
255
252
  end
256
253
  end
257
254
 
258
255
  # add in the other variables by columns -- should really pull this from the report variables defined above
259
- extract_timeseries_into_matrix(sqlFile, rows, 'Site Outdoor Air Drybulb Temperature', 'Environment', 0)
260
- extract_timeseries_into_matrix(sqlFile, rows, 'Site Outdoor Air Relative Humidity', 'Environment', 0)
261
- extract_timeseries_into_matrix(sqlFile, rows, 'Heating:Electricity', nil, 0)
262
- extract_timeseries_into_matrix(sqlFile, rows, 'Heating:Gas', nil, 0)
263
- extract_timeseries_into_matrix(sqlFile, rows, 'Cooling:Electricity', nil, 0)
264
- extract_timeseries_into_matrix(sqlFile, rows, 'Electricity:Facility', nil, 0)
265
- extract_timeseries_into_matrix(sqlFile, rows, 'Gas:Facility', nil, 0)
266
- extract_timeseries_into_matrix(sqlFile, rows, 'Heating:EnergyTransfer', nil, 0)
267
- extract_timeseries_into_matrix(sqlFile, rows, 'WaterSystems:EnergyTransfer', nil, 0)
256
+ extract_timeseries_into_matrix(sqlFile, rows, 'Site Outdoor Air Drybulb Temperature', 'Environment', 0, timestep)
257
+ extract_timeseries_into_matrix(sqlFile, rows, 'Site Outdoor Air Relative Humidity', 'Environment', 0, timestep)
258
+ extract_timeseries_into_matrix(sqlFile, rows, 'Heating:Electricity', nil, 0, timestep)
259
+ extract_timeseries_into_matrix(sqlFile, rows, 'Heating:NaturalGas', nil, 0, timestep)
260
+ extract_timeseries_into_matrix(sqlFile, rows, 'Cooling:Electricity', nil, 0, timestep)
261
+ extract_timeseries_into_matrix(sqlFile, rows, 'Electricity:Facility', nil, 0, timestep)
262
+ extract_timeseries_into_matrix(sqlFile, rows, 'Gas:Facility', nil, 0, timestep)
263
+ extract_timeseries_into_matrix(sqlFile, rows, 'Heating:EnergyTransfer', nil, 0, timestep)
264
+ extract_timeseries_into_matrix(sqlFile, rows, 'WaterSystems:EnergyTransfer', nil, 0, timestep)
268
265
 
269
266
  # get all zones and save the names for later use in aggregation.
270
267
  tz_names = []
271
268
  model.getThermalZones.each do |tz|
272
269
  tz_names << tz.name.get if tz.name.is_initialized
273
- extract_timeseries_into_matrix(sqlFile, rows, 'Zone Predicted Sensible Load to Setpoint Heat Transfer Rate', tz_names.last, 0)
274
- extract_timeseries_into_matrix(sqlFile, rows, 'Water Heater Heating Rate', tz_names.last, 0)
270
+ extract_timeseries_into_matrix(sqlFile, rows, 'Zone Predicted Sensible Load to Setpoint Heat Transfer Rate', tz_names.last, 0, timestep)
271
+ extract_timeseries_into_matrix(sqlFile, rows, 'Water Heater Heating Rate', tz_names.last, 0, timestep)
275
272
  end
276
273
 
277
274
  # sum up a couple of the columns and create a new columns
@@ -346,7 +343,7 @@ class ExportModelicaLoads < OpenStudio::Measure::ReportingMeasure
346
343
  # Find the total runtime for energyplus and save it into a registerValue
347
344
  total_time = -999
348
345
  location_of_file = ['../eplusout.end', './run/eplusout.end']
349
- first_index = location_of_file.map {|f| File.exist?(f)}.index(true)
346
+ first_index = location_of_file.map { |f| File.exist?(f) }.index(true)
350
347
  if first_index
351
348
  match = File.read(location_of_file[first_index]).to_s.match(/Elapsed.Time=(.*)hr(.*)min(.*)sec/)
352
349
  total_time = match[1].to_i * 3600 + match[2].to_i * 60 + match[3].to_f
@@ -3,8 +3,8 @@
3
3
  <schema_version>3.0</schema_version>
4
4
  <name>export_modelica_loads</name>
5
5
  <uid>7051db01-2e55-4223-b5b5-fee615b68dd0</uid>
6
- <version_id>7782f28c-19e6-449d-8cf3-e3f915550ebd</version_id>
7
- <version_modified>20201203T151454Z</version_modified>
6
+ <version_id>e80d1948-12bf-4a07-b8b2-cab73c6f8235</version_id>
7
+ <version_modified>20210427T174740Z</version_modified>
8
8
  <xml_checksum>2C8A3EEF</xml_checksum>
9
9
  <class_name>ExportModelicaLoads</class_name>
10
10
  <display_name>Export Modelica Loads</display_name>
@@ -41,18 +41,6 @@
41
41
  <usage_type>doc</usage_type>
42
42
  <checksum>00000000</checksum>
43
43
  </file>
44
- <file>
45
- <filename>export_modelica_loads_test.rb</filename>
46
- <filetype>rb</filetype>
47
- <usage_type>test</usage_type>
48
- <checksum>83EC81AC</checksum>
49
- </file>
50
- <file>
51
- <filename>example_model.osm</filename>
52
- <filetype>osm</filetype>
53
- <usage_type>test</usage_type>
54
- <checksum>39B6E26C</checksum>
55
- </file>
56
44
  <file>
57
45
  <filename>USA_CO_Golden-NREL.724666_TMY3.epw</filename>
58
46
  <filetype>epw</filetype>
@@ -65,18 +53,30 @@
65
53
  <usage_type>resource</usage_type>
66
54
  <checksum>3F69E3FB</checksum>
67
55
  </file>
68
- <file>
69
- <filename>LICENSE.md</filename>
70
- <filetype>md</filetype>
71
- <usage_type>license</usage_type>
72
- <checksum>E0468DD6</checksum>
73
- </file>
74
56
  <file>
75
57
  <filename>README.md</filename>
76
58
  <filetype>md</filetype>
77
59
  <usage_type>readme</usage_type>
78
60
  <checksum>544E6A47</checksum>
79
61
  </file>
62
+ <file>
63
+ <filename>export_modelica_loads_test.rb</filename>
64
+ <filetype>rb</filetype>
65
+ <usage_type>test</usage_type>
66
+ <checksum>15232067</checksum>
67
+ </file>
68
+ <file>
69
+ <filename>example_model.osm</filename>
70
+ <filetype>osm</filetype>
71
+ <usage_type>test</usage_type>
72
+ <checksum>A2B6C1DD</checksum>
73
+ </file>
74
+ <file>
75
+ <filename>LICENSE.md</filename>
76
+ <filetype>md</filetype>
77
+ <usage_type>license</usage_type>
78
+ <checksum>BBD19F47</checksum>
79
+ </file>
80
80
  <file>
81
81
  <version>
82
82
  <software_program>OpenStudio</software_program>
@@ -86,7 +86,7 @@
86
86
  <filename>measure.rb</filename>
87
87
  <filetype>rb</filetype>
88
88
  <usage_type>script</usage_type>
89
- <checksum>AE19F661</checksum>
89
+ <checksum>DA574F8F</checksum>
90
90
  </file>
91
91
  </files>
92
92
  </measure>
@@ -1 +1,27 @@
1
- Insert your license here
1
+ URBANopt (tm), Copyright (c) 2019-2020, Alliance for Sustainable Energy, LLC, and other
2
+ contributors. All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ Redistributions of source code must retain the above copyright notice, this list
8
+ of conditions and the following disclaimer.
9
+
10
+ Redistributions in binary form must reproduce the above copyright notice, this
11
+ list of conditions and the following disclaimer in the documentation and/or other
12
+ materials provided with the distribution.
13
+
14
+ Neither the name of the copyright holder nor the names of its contributors may be
15
+ used to endorse or promote products derived from this software without specific
16
+ prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27
+ OF THE POSSIBILITY OF SUCH DAMAGE.