openstudio-extension 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/openstudio/extension/core/CreateResults.rb +178 -1
- data/lib/openstudio/extension/core/os_lib_geometry.rb +255 -77
- data/lib/openstudio/extension/core/os_lib_model_generation.rb +2521 -83
- data/lib/openstudio/extension/core/os_lib_reporting.rb +133 -30
- data/lib/openstudio/extension/version.rb +1 -1
- metadata +2 -3
- data/lib/openstudio/extension/core/os_lib_cofee.rb +0 -259
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3faa07577e5a2980e7cacc747e5fb9f3ceb5cdb7
|
4
|
+
data.tar.gz: b4e220c8aca2e0227e65866ded3d1af1b7b19958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23ec9c229a5618bc27932844884998bb41fac6f57c5753d2d79f2c2702652e37e7836d42e75e9f3c78a2e0321729284fec4a012e80995dee89359f3b7a7fa440
|
7
|
+
data.tar.gz: da121f8ec77b913ec6d61c528ffb78841ec645dcd0fb7b126df4668f87f3df74e56f7ef8bf9068d6b81b4e02ae4aa17922a9d33abba4fc94a52dc509cae28ff3
|
data/CHANGELOG.md
CHANGED
@@ -45,6 +45,23 @@ module OsLib_CreateResults
|
|
45
45
|
# @param end_mo [String] the end month for the peak demand window
|
46
46
|
# @param end_day [Integer] the end day for the peak demand window
|
47
47
|
# @param end_hr [Integer] the end hour for the peak demand window, using 24-hr clock
|
48
|
+
# @param electricity_consumption_tou_periods [Array<Hash>] optional array of hashes to add
|
49
|
+
# time-of-use electricity consumption values to the annual consumption information.
|
50
|
+
# Periods may overlap, but should be listed in the order in which they must be checked,
|
51
|
+
# where the value will be assigned to the first encountered period it falls into.
|
52
|
+
# An example hash looks like this:
|
53
|
+
# {
|
54
|
+
# 'tou_name' => 'system_peak',
|
55
|
+
# 'tou_id' => 1,
|
56
|
+
# 'skip_weekends' => true,
|
57
|
+
# 'skip_holidays' => true,
|
58
|
+
# 'start_mo' => 'July',
|
59
|
+
# 'start_day' => 1,
|
60
|
+
# 'start_hr' => 14,
|
61
|
+
# 'end_mo' => 'August',
|
62
|
+
# 'end_day' => 31,
|
63
|
+
# 'end_hr' => 18
|
64
|
+
# }
|
48
65
|
# @return [OpenStudio::AttributeVector] a vector of results needed by EDAPT
|
49
66
|
def create_results(skip_weekends = true,
|
50
67
|
skip_holidays = true,
|
@@ -53,7 +70,8 @@ module OsLib_CreateResults
|
|
53
70
|
start_hr = 14,
|
54
71
|
end_mo = 'September',
|
55
72
|
end_day = 30,
|
56
|
-
end_hr = 18
|
73
|
+
end_hr = 18,
|
74
|
+
electricity_consumption_tou_periods = [])
|
57
75
|
|
58
76
|
# get the current version of OS being used to determine if sql query
|
59
77
|
# changes are needed (for when E+ changes).
|
@@ -497,6 +515,83 @@ module OsLib_CreateResults
|
|
497
515
|
@runner.registerValue('annual_demand_electricity_peak_demand', 0.0, 'kW')
|
498
516
|
end
|
499
517
|
|
518
|
+
# Describe the TOU periods
|
519
|
+
electricity_consumption_tou_periods.each do |tou_pd|
|
520
|
+
@runner.registerInfo("TOU period #{tou_pd['tou_id']} represents #{tou_pd['tou_name']} and covers #{tou_pd['start_mo']}-#{tou_pd['start_day']} to #{tou_pd['end_mo']}-#{tou_pd['end_day']} from #{tou_pd['start_hr']} to #{tou_pd['end_hr']}, skip weekends = #{tou_pd['skip_weekends']}, skip holidays = #{tou_pd['skip_holidays']}")
|
521
|
+
end
|
522
|
+
|
523
|
+
# electricity time-of-use periods
|
524
|
+
elec = @sql.timeSeries(ann_env_pd, 'Zone Timestep', 'Electricity:Facility', '')
|
525
|
+
if elec.is_initialized && day_types
|
526
|
+
elec = elec.get
|
527
|
+
# Put timeseries into array
|
528
|
+
elec_vals = []
|
529
|
+
ann_elec_vals = elec.values
|
530
|
+
for i in 0..(ann_elec_vals.size - 1)
|
531
|
+
elec_vals << ann_elec_vals[i]
|
532
|
+
end
|
533
|
+
|
534
|
+
# Put values into array
|
535
|
+
elec_times = []
|
536
|
+
ann_elec_times = elec.dateTimes
|
537
|
+
for i in 0..(ann_elec_times.size - 1)
|
538
|
+
elec_times << ann_elec_times[i]
|
539
|
+
end
|
540
|
+
|
541
|
+
# Loop through the time/value pairs and find the peak
|
542
|
+
# excluding the times outside of the Xcel peak demand window
|
543
|
+
electricity_tou_vals = Hash.new(0)
|
544
|
+
elec_times.zip(elec_vals).each_with_index do |vs, ind|
|
545
|
+
date_time = vs[0]
|
546
|
+
joules = vs[1]
|
547
|
+
day_type = day_types[ind]
|
548
|
+
time = date_time.time
|
549
|
+
date = date_time.date
|
550
|
+
|
551
|
+
# puts("#{val_kW}kW; #{date}; #{time}; #{day_of_week.valueName}")
|
552
|
+
|
553
|
+
# Determine which TOU period this hour falls into
|
554
|
+
tou_period_assigned = false
|
555
|
+
electricity_consumption_tou_periods.each do |tou_pd|
|
556
|
+
pd_start_date = OpenStudio::DateTime.new(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(tou_pd['start_mo']), tou_pd['start_day'], timeseries_yr), OpenStudio::Time.new(0, 0, 0, 0))
|
557
|
+
pd_end_date = OpenStudio::DateTime.new(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(tou_pd['end_mo']), tou_pd['end_day'], timeseries_yr), OpenStudio::Time.new(0, 24, 0, 0))
|
558
|
+
pd_start_time = OpenStudio::Time.new(0, tou_pd['start_hr'], 0, 0)
|
559
|
+
pd_end_time = OpenStudio::Time.new(0, tou_pd['end_hr'], 0, 0)
|
560
|
+
# Skip times outside of the correct months
|
561
|
+
next if date_time < pd_start_date || date_time > pd_end_date
|
562
|
+
# Skip times before some time and after another time
|
563
|
+
next if time < pd_start_time || time > pd_end_time
|
564
|
+
# Skip weekends if asked
|
565
|
+
if tou_pd['skip_weekends']
|
566
|
+
# Sunday = 1, Saturday = 7
|
567
|
+
next if day_type == 1 || day_type == 7
|
568
|
+
end
|
569
|
+
# Skip holidays if asked
|
570
|
+
if tou_pd['skip_holidays']
|
571
|
+
# Holiday = 8
|
572
|
+
next if day_type == 8
|
573
|
+
end
|
574
|
+
# If here, this hour falls into the specified period
|
575
|
+
tou_period_assigned = true
|
576
|
+
electricity_tou_vals[tou_pd['tou_id']] += joules
|
577
|
+
break
|
578
|
+
end
|
579
|
+
# Ensure that the value fell into a period
|
580
|
+
unless tou_period_assigned
|
581
|
+
@runner.registerError("Did not find a TOU period covering #{time} on #{date}, kWh will not be included in any TOU period.")
|
582
|
+
end
|
583
|
+
end
|
584
|
+
# Register values for any time-of-use period with kWh
|
585
|
+
electricity_tou_vals.each do |tou_pd_id, joules_in_pd|
|
586
|
+
gj_in_pd = OpenStudio.convert(joules_in_pd, 'J', 'GJ').get
|
587
|
+
kwh_in_pd = OpenStudio.convert(joules_in_pd, 'J', 'kWh').get
|
588
|
+
@runner.registerValue("annual_consumption_electricity_tou_#{tou_pd_id}", gj_in_pd, 'GJ')
|
589
|
+
@runner.registerInfo("TOU period #{tou_pd_id} annual electricity consumption = #{kwh_in_pd} kWh.")
|
590
|
+
end
|
591
|
+
else
|
592
|
+
@runner.registerError('Electricity timeseries (Electricity:Facility at zone timestep) could not be found, cannot determine the information needed to calculate savings or incentives.')
|
593
|
+
end
|
594
|
+
|
500
595
|
# electricity_annual_avg_peak_demand
|
501
596
|
val = @sql.electricityTotalEndUses
|
502
597
|
if val.is_initialized
|
@@ -587,6 +682,88 @@ module OsLib_CreateResults
|
|
587
682
|
@runner.registerValue('annual_demand_district_cooling_peak_demand', 0.0, 'kW')
|
588
683
|
end
|
589
684
|
|
685
|
+
# district cooling time-of-use periods
|
686
|
+
dist_clg = @sql.timeSeries(ann_env_pd, 'Zone Timestep', 'DistrictCooling:Facility', '')
|
687
|
+
if dist_clg.is_initialized && day_types
|
688
|
+
dist_clg = dist_clg.get
|
689
|
+
# Put timeseries into array
|
690
|
+
dist_clg_vals = []
|
691
|
+
ann_dist_clg_vals = dist_clg.values
|
692
|
+
for i in 0..(ann_dist_clg_vals.size - 1)
|
693
|
+
dist_clg_vals << ann_dist_clg_vals[i]
|
694
|
+
end
|
695
|
+
|
696
|
+
# Put values into array
|
697
|
+
dist_clg_times = []
|
698
|
+
ann_dist_clg_times = dist_clg.dateTimes
|
699
|
+
for i in 0..(ann_dist_clg_times.size - 1)
|
700
|
+
dist_clg_times << ann_dist_clg_times[i]
|
701
|
+
end
|
702
|
+
|
703
|
+
# Loop through the time/value pairs and find the peak
|
704
|
+
# excluding the times outside of the Xcel peak demand window
|
705
|
+
dist_clg_tou_vals = Hash.new(0)
|
706
|
+
dist_clg_times.zip(dist_clg_vals).each_with_index do |vs, ind|
|
707
|
+
date_time = vs[0]
|
708
|
+
joules = vs[1]
|
709
|
+
day_type = day_types[ind]
|
710
|
+
time = date_time.time
|
711
|
+
date = date_time.date
|
712
|
+
|
713
|
+
# puts("#{val_kW}kW; #{date}; #{time}; #{day_of_week.valueName}")
|
714
|
+
|
715
|
+
# Determine which TOU period this hour falls into
|
716
|
+
tou_period_assigned = false
|
717
|
+
electricity_consumption_tou_periods.each do |tou_pd|
|
718
|
+
pd_start_date = OpenStudio::DateTime.new(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(tou_pd['start_mo']), tou_pd['start_day'], timeseries_yr), OpenStudio::Time.new(0, 0, 0, 0))
|
719
|
+
pd_end_date = OpenStudio::DateTime.new(OpenStudio::Date.new(OpenStudio::MonthOfYear.new(tou_pd['end_mo']), tou_pd['end_day'], timeseries_yr), OpenStudio::Time.new(0, 24, 0, 0))
|
720
|
+
pd_start_time = OpenStudio::Time.new(0, tou_pd['start_hr'], 0, 0)
|
721
|
+
pd_end_time = OpenStudio::Time.new(0, tou_pd['end_hr'], 0, 0)
|
722
|
+
# Skip times outside of the correct months
|
723
|
+
next if date_time < pd_start_date || date_time > pd_end_date
|
724
|
+
# Skip times before some time and after another time
|
725
|
+
next if time < pd_start_time || time > pd_end_time
|
726
|
+
# Skip weekends if asked
|
727
|
+
if tou_pd['skip_weekends']
|
728
|
+
# Sunday = 1, Saturday = 7
|
729
|
+
next if day_type == 1 || day_type == 7
|
730
|
+
end
|
731
|
+
# Skip holidays if asked
|
732
|
+
if tou_pd['skip_holidays']
|
733
|
+
# Holiday = 8
|
734
|
+
next if day_type == 8
|
735
|
+
end
|
736
|
+
# If here, this hour falls into the specified period
|
737
|
+
tou_period_assigned = true
|
738
|
+
dist_clg_tou_vals[tou_pd['tou_id']] += joules
|
739
|
+
break
|
740
|
+
end
|
741
|
+
# Ensure that the value fell into a period
|
742
|
+
unless tou_period_assigned
|
743
|
+
@runner.registerError("Did not find a TOU period covering #{time} on #{date}, kWh will not be included in any TOU period.")
|
744
|
+
end
|
745
|
+
end
|
746
|
+
# Register values for any time-of-use period with kWh
|
747
|
+
dist_clg_tou_vals.each do |tou_pd_id, joules_in_pd|
|
748
|
+
gj_in_pd = OpenStudio.convert(joules_in_pd, 'J', 'GJ').get
|
749
|
+
kwh_in_pd = OpenStudio.convert(joules_in_pd, 'J', 'kWh').get
|
750
|
+
@runner.registerValue("annual_consumption_district_cooling_tou_#{tou_pd_id}", gj_in_pd, 'GJ')
|
751
|
+
@runner.registerInfo("TOU period #{tou_pd_id} annual district cooling consumption = #{kwh_in_pd} kWh.")
|
752
|
+
end
|
753
|
+
else
|
754
|
+
# If TOU periods were specified but this model has no district cooling, report zeroes
|
755
|
+
if electricity_consumption_tou_periods.size > 0
|
756
|
+
# Get the TOU ids
|
757
|
+
tou_ids = []
|
758
|
+
electricity_consumption_tou_periods.each do |tou_pd|
|
759
|
+
tou_ids << tou_pd['tou_id']
|
760
|
+
end
|
761
|
+
tou_ids.uniq.each do |tou_id|
|
762
|
+
@runner.registerValue("annual_consumption_district_cooling_tou_#{tou_id}", 0.0, 'GJ')
|
763
|
+
end
|
764
|
+
end
|
765
|
+
end
|
766
|
+
|
590
767
|
else
|
591
768
|
@runner.registerError('Could not find an annual run period')
|
592
769
|
return OpenStudio::Attribute.new('report', result_elems)
|