Skip to content

Commit f20b724

Browse files
authored
Merge pull request #1771 from NREL/ruby-docs
More ruby documentation
2 parents 5fa2512 + d7865a1 commit f20b724

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4672
-2275
lines changed

Diff for: BuildResidentialHPXML/measure.rb

+17-17
Original file line numberDiff line numberDiff line change
@@ -2366,18 +2366,18 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
23662366

23672367
solar_thermal_system_type_choices = OpenStudio::StringVector.new
23682368
solar_thermal_system_type_choices << 'none'
2369-
solar_thermal_system_type_choices << HPXML::SolarThermalSystemType
2369+
solar_thermal_system_type_choices << HPXML::SolarThermalSystemTypeHotWater
23702370

23712371
solar_thermal_collector_loop_type_choices = OpenStudio::StringVector.new
23722372
solar_thermal_collector_loop_type_choices << HPXML::SolarThermalLoopTypeDirect
23732373
solar_thermal_collector_loop_type_choices << HPXML::SolarThermalLoopTypeIndirect
23742374
solar_thermal_collector_loop_type_choices << HPXML::SolarThermalLoopTypeThermosyphon
23752375

23762376
solar_thermal_collector_type_choices = OpenStudio::StringVector.new
2377-
solar_thermal_collector_type_choices << HPXML::SolarThermalTypeEvacuatedTube
2378-
solar_thermal_collector_type_choices << HPXML::SolarThermalTypeSingleGlazing
2379-
solar_thermal_collector_type_choices << HPXML::SolarThermalTypeDoubleGlazing
2380-
solar_thermal_collector_type_choices << HPXML::SolarThermalTypeICS
2377+
solar_thermal_collector_type_choices << HPXML::SolarThermalCollectorTypeEvacuatedTube
2378+
solar_thermal_collector_type_choices << HPXML::SolarThermalCollectorTypeSingleGlazing
2379+
solar_thermal_collector_type_choices << HPXML::SolarThermalCollectorTypeDoubleGlazing
2380+
solar_thermal_collector_type_choices << HPXML::SolarThermalCollectorTypeICS
23812381

23822382
arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('solar_thermal_system_type', solar_thermal_system_type_choices, true)
23832383
arg.setDisplayName('Solar Thermal: System Type')
@@ -2401,7 +2401,7 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
24012401
arg = OpenStudio::Measure::OSArgument::makeChoiceArgument('solar_thermal_collector_type', solar_thermal_collector_type_choices, true)
24022402
arg.setDisplayName('Solar Thermal: Collector Type')
24032403
arg.setDescription('The collector type of the solar thermal system.')
2404-
arg.setDefaultValue(HPXML::SolarThermalTypeEvacuatedTube)
2404+
arg.setDefaultValue(HPXML::SolarThermalCollectorTypeEvacuatedTube)
24052405
args << arg
24062406

24072407
arg = OpenStudio::Measure::OSArgument::makeDoubleArgument('solar_thermal_collector_azimuth', true)
@@ -3471,7 +3471,7 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
34713471
# Define what happens when the measure is run.
34723472
#
34733473
# @param model [OpenStudio::Model::Model] OpenStudio Model object
3474-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
3474+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
34753475
# @param user_arguments [OpenStudio::Measure::OSArgumentMap] OpenStudio measure arguments
34763476
# @return [Boolean] true if successful
34773477
def run(model, runner, user_arguments)
@@ -3794,7 +3794,7 @@ def argument_errors(args)
37943794
module HPXMLFile
37953795
# Create the closed-form geometry, and then call individual set_xxx methods
37963796
#
3797-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
3797+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
37983798
# @param model [OpenStudio::Model::Model] OpenStudio Model object
37993799
# @param args [Hash] Map of :argument_name => value
38003800
# @param epw_path [String] Path to the EPW weather file
@@ -3923,7 +3923,7 @@ def self.need_weather_based_on_args(args)
39233923

39243924
# Check for errors in hpxml, and validate hpxml_doc against hpxml_path
39253925
#
3926-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
3926+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
39273927
# @param hpxml [HPXML] HPXML object
39283928
# @param hpxml_doc [Oga::XML::Element] Root XML element of the HPXML document
39293929
# @param hpxml_path [TODO] TODO
@@ -3964,7 +3964,7 @@ def self.validate_hpxml(runner, hpxml, hpxml_doc, hpxml_path)
39643964

39653965
# Create 3D geometry (surface, subsurfaces) for a given unit type
39663966
#
3967-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
3967+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
39683968
# @param model [OpenStudio::Model::Model] OpenStudio Model object
39693969
# @param args [Hash] Map of :argument_name => value
39703970
# @return [Boolean] True if successful
@@ -4058,7 +4058,7 @@ def self.unavailable_period_exists(hpxml, column_name, begin_month, begin_day, b
40584058
# - emissions scenarios
40594059
# - utility bill scenarios
40604060
#
4061-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
4061+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
40624062
# @param hpxml [HPXML] HPXML object
40634063
# @param args [Hash] Map of :argument_name => value
40644064
# @return [Boolean] true if no errors, otherwise false
@@ -6571,7 +6571,7 @@ def self.set_hot_water_distribution(hpxml_bldg, args)
65716571
standard_piping_length = args[:hot_water_distribution_standard_piping_length]
65726572
else
65736573
recirculation_control_type = args[:hot_water_distribution_recirc_control_type]
6574-
recirculation_piping_length = args[:hot_water_distribution_recirc_piping_length]
6574+
recirculation_piping_loop_length = args[:hot_water_distribution_recirc_piping_length]
65756575
recirculation_branch_piping_length = args[:hot_water_distribution_recirc_branch_piping_length]
65766576
recirculation_pump_power = args[:hot_water_distribution_recirc_pump_power]
65776577
end
@@ -6580,7 +6580,7 @@ def self.set_hot_water_distribution(hpxml_bldg, args)
65806580
system_type: args[:hot_water_distribution_system_type],
65816581
standard_piping_length: standard_piping_length,
65826582
recirculation_control_type: recirculation_control_type,
6583-
recirculation_piping_length: recirculation_piping_length,
6583+
recirculation_piping_loop_length: recirculation_piping_loop_length,
65846584
recirculation_branch_piping_length: recirculation_branch_piping_length,
65856585
recirculation_pump_power: recirculation_pump_power,
65866586
pipe_r_value: args[:hot_water_distribution_pipe_r],
@@ -6632,8 +6632,8 @@ def self.set_solar_thermal(hpxml_bldg, args, weather)
66326632
collector_azimuth = args[:solar_thermal_collector_azimuth]
66336633
latitude = HPXMLDefaults.get_default_latitude(args[:site_latitude], weather) unless weather.nil?
66346634
collector_tilt = Geometry.get_absolute_tilt(tilt_str: args[:solar_thermal_collector_tilt], roof_pitch: args[:geometry_roof_pitch], latitude: latitude)
6635-
collector_frta = args[:solar_thermal_collector_rated_optical_efficiency]
6636-
collector_frul = args[:solar_thermal_collector_rated_thermal_losses]
6635+
collector_rated_optical_efficiency = args[:solar_thermal_collector_rated_optical_efficiency]
6636+
collector_rated_thermal_losses = args[:solar_thermal_collector_rated_thermal_losses]
66376637
storage_volume = args[:solar_thermal_storage_volume]
66386638
end
66396639

@@ -6648,8 +6648,8 @@ def self.set_solar_thermal(hpxml_bldg, args, weather)
66486648
collector_type: collector_type,
66496649
collector_azimuth: collector_azimuth,
66506650
collector_tilt: collector_tilt,
6651-
collector_frta: collector_frta,
6652-
collector_frul: collector_frul,
6651+
collector_rated_optical_efficiency: collector_rated_optical_efficiency,
6652+
collector_rated_thermal_losses: collector_rated_thermal_losses,
66536653
storage_volume: storage_volume,
66546654
water_heating_system_idref: hpxml_bldg.water_heating_systems[0].id,
66556655
solar_fraction: solar_fraction)

Diff for: BuildResidentialHPXML/measure.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema_version>3.1</schema_version>
44
<name>build_residential_hpxml</name>
55
<uid>a13a8983-2b01-4930-8af2-42030b6e4233</uid>
6-
<version_id>635a8ab6-45f1-4969-b2c5-f308519438f8</version_id>
7-
<version_modified>2024-07-11T16:09:59Z</version_modified>
6+
<version_id>c4dd5a2c-b6ac-467e-b914-ad2f0d59cf23</version_id>
7+
<version_modified>2024-07-17T17:04:58Z</version_modified>
88
<xml_checksum>2C38F48B</xml_checksum>
99
<class_name>BuildResidentialHPXML</class_name>
1010
<display_name>HPXML Builder</display_name>
@@ -7406,19 +7406,19 @@
74067406
<filename>measure.rb</filename>
74077407
<filetype>rb</filetype>
74087408
<usage_type>script</usage_type>
7409-
<checksum>F41033B3</checksum>
7409+
<checksum>09586CC1</checksum>
74107410
</file>
74117411
<file>
74127412
<filename>geometry.rb</filename>
74137413
<filetype>rb</filetype>
74147414
<usage_type>resource</usage_type>
7415-
<checksum>8E4E4C7F</checksum>
7415+
<checksum>3BCF34D6</checksum>
74167416
</file>
74177417
<file>
74187418
<filename>test_build_residential_hpxml.rb</filename>
74197419
<filetype>rb</filetype>
74207420
<usage_type>test</usage_type>
7421-
<checksum>C0AF4CE1</checksum>
7421+
<checksum>4924B90F</checksum>
74227422
</file>
74237423
</files>
74247424
</measure>

Diff for: BuildResidentialHPXML/resources/geometry.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Geometry
55
# Create a 3D representation of a single-family detached home using the following arguments.
66
#
7-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
7+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
88
# @param model [OpenStudio::Model::Model] OpenStudio Model object
99
# @param geometry_unit_cfa [Double] conditioned floor area (ft2)
1010
# @param geometry_average_ceiling_height [Double] average ceiling height (ft)
@@ -1237,7 +1237,7 @@ def self.create_apartment(model:,
12371237

12381238
# Place a door subsurface on an exterior wall surface (with enough area) prioritized by front, then back, then left, then right, and lowest story.
12391239
#
1240-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
1240+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
12411241
# @param model [OpenStudio::Model::Model] OpenStudio Model object
12421242
# @param door_area [Double] the area of the opaque door(s) (ft2)
12431243
# @return [Boolean] true if successful
@@ -1373,7 +1373,7 @@ def self.create_doors(runner:,
13731373

13741374
# Place window subsurfaces on exterior wall surfaces (or skylight subsurfaces on roof surfaces) using target facade areas based on either window to wall area ratios or window areas.
13751375
#
1376-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
1376+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
13771377
# @param model [OpenStudio::Model::Model] OpenStudio Model object
13781378
# @param window_front_wwr [Double] ratio of window to wall area for the unit's front facade (frac)
13791379
# @param window_back_wwr [Double] ratio of window to wall area for the unit's back facade (frac)
@@ -2279,7 +2279,7 @@ def self.get_wall_area_for_windows(surface:,
22792279
# @param max_single_window_area [Double] maximum area for a single window (ft2)
22802280
# @param facade [String] front, back, left, or right
22812281
# @param model [OpenStudio::Model::Model] OpenStudio Model object
2282-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
2282+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
22832283
# @return [Boolean] true if successful
22842284
def self.add_windows_to_wall(surface:,
22852285
window_area:,

Diff for: BuildResidentialHPXML/tests/test_build_residential_hpxml.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ def _set_measure_argument_values(hpxml_file, args)
579579
args['solar_thermal_system_type'] = 'none'
580580
args['solar_thermal_collector_area'] = 40.0
581581
args['solar_thermal_collector_loop_type'] = HPXML::SolarThermalLoopTypeDirect
582-
args['solar_thermal_collector_type'] = HPXML::SolarThermalTypeEvacuatedTube
582+
args['solar_thermal_collector_type'] = HPXML::SolarThermalCollectorTypeEvacuatedTube
583583
args['solar_thermal_collector_azimuth'] = 180
584584
args['solar_thermal_collector_tilt'] = 20
585585
args['solar_thermal_collector_rated_optical_efficiency'] = 0.5
@@ -764,7 +764,7 @@ def _set_measure_argument_values(hpxml_file, args)
764764
args['pv_system_array_tilt'] = 'roofpitch'
765765
args['pv_system_2_array_tilt'] = 'roofpitch+15'
766766
elsif ['extra-dhw-solar-latitude.xml'].include? hpxml_file
767-
args['solar_thermal_system_type'] = HPXML::SolarThermalSystemType
767+
args['solar_thermal_system_type'] = HPXML::SolarThermalSystemTypeHotWater
768768
args['solar_thermal_collector_tilt'] = 'Latitude-15'
769769
elsif ['extra-second-refrigerator.xml'].include? hpxml_file
770770
args['extra_refrigerator_location'] = HPXML::LocationConditionedSpace

Diff for: BuildResidentialScheduleFile/measure.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def arguments(model) # rubocop:disable Lint/UnusedMethodArgument
8888
# Define what happens when the measure is run.
8989
#
9090
# @param model [OpenStudio::Model::Model] OpenStudio Model object
91-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
91+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
9292
# @param user_arguments [OpenStudio::Measure::OSArgumentMap] OpenStudio measure arguments
9393
# @return [Boolean] true if successful
9494
def run(model, runner, user_arguments)
@@ -176,7 +176,7 @@ def run(model, runner, user_arguments)
176176

177177
# Write out the HPXML file with the output CSV path containing occupancy schedules.
178178
#
179-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
179+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
180180
# @param doc [Oga::XML::Document] Oga XML Document object
181181
# @param hpxml_path [String] path of the input HPXML file
182182
# @param hpxml_output_path [String] path of the output HPXML file
@@ -192,7 +192,7 @@ def write_modified_hpxml(runner, doc, hpxml_path, hpxml_output_path, schedules_f
192192

193193
# Create and export the occupancy schedules.
194194
#
195-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
195+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
196196
# @param hpxml [HPXML] HPXML object
197197
# @param hpxml_bldg [HPXML::Building] HPXML Building object representing an individual dwelling unit
198198
# @param weather [WeatherFile] Weather object containing EPW information

Diff for: BuildResidentialScheduleFile/measure.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<schema_version>3.1</schema_version>
44
<name>build_residential_schedule_file</name>
55
<uid>f770b2db-1a9f-4e99-99a7-7f3161a594b1</uid>
6-
<version_id>b471ba87-0ebb-4a48-a305-9a4f6a16e1c5</version_id>
7-
<version_modified>2024-07-11T02:46:37Z</version_modified>
6+
<version_id>82cc5cf7-51fc-435c-9ea1-429bf4b72080</version_id>
7+
<version_modified>2024-07-15T21:48:21Z</version_modified>
88
<xml_checksum>03F02484</xml_checksum>
99
<class_name>BuildResidentialScheduleFile</class_name>
1010
<display_name>Schedule File Builder</display_name>
@@ -133,13 +133,13 @@
133133
<filename>measure.rb</filename>
134134
<filetype>rb</filetype>
135135
<usage_type>script</usage_type>
136-
<checksum>3ECB9FB5</checksum>
136+
<checksum>D2B0EB5F</checksum>
137137
</file>
138138
<file>
139139
<filename>README.md</filename>
140140
<filetype>md</filetype>
141141
<usage_type>resource</usage_type>
142-
<checksum>C8528AAA</checksum>
142+
<checksum>08194138</checksum>
143143
</file>
144144
<file>
145145
<filename>clothes_dryer_consumption_dist.csv</filename>
@@ -223,7 +223,7 @@
223223
<filename>schedules.rb</filename>
224224
<filetype>rb</filetype>
225225
<usage_type>resource</usage_type>
226-
<checksum>BBF55F85</checksum>
226+
<checksum>A0CC250C</checksum>
227227
</file>
228228
<file>
229229
<filename>schedules_config.md</filename>

Diff for: BuildResidentialScheduleFile/resources/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ The schedule CSV file contains the following columns:
1818
* `hot_water_dishwasher`
1919
* `hot_water_clothes_washer`
2020
* `hot_water_fixtures`
21-
* `sleep` (exported only when "debug" mode is enabled)
21+
* `sleeping` (exported only when "debug" mode is enabled)
2222

2323
Each of the columns, except `occupants`, represent schedule values (kW for power schedules, and gallons per minute for water schedules) normalized using universal maximum values found in `constants.rb`.
2424

2525
The `occupants` column represents the fractional percent of occupants present out of the total number of occupants assigned to the unit.
26-
The `sleep` column represents the fractional percent of the total number of occupants who are sleeping.
26+
The `sleeping` column represents the fractional percent of the total number of occupants who are sleeping.
2727

2828
There are the same number of rows as the total simulation time-step (e.g., 35040 if 15-min, 8760 if hourly [8784, if leap year]).
2929

Diff for: BuildResidentialScheduleFile/resources/schedules.rb

+22-22
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
require 'csv'
44
require 'matrix'
55

6-
# TODO
6+
# Collection of methods related to the generation of stochastic occupancy schedules.
77
class ScheduleGenerator
8-
# @param runner [OpenStudio::Measure::OSRunner] OpenStudio Runner object
9-
# @param state [TODO] TODO
10-
# @param column_names [TODO] TODO
11-
# @param random_seed [TODO] TODO
12-
# @param minutes_per_step [TODO] TODO
13-
# @param steps_in_day [TODO] TODO
14-
# @param mkc_ts_per_day [TODO] TODO
15-
# @param mkc_ts_per_hour [TODO] TODO
16-
# @param total_days_in_year [TODO] TODO
17-
# @param sim_year [TODO] TODO
18-
# @param sim_start_day [TODO] TODO
19-
# @param debug [TODO] TODO
20-
# @param append_output [TODO] TODO
8+
# @param runner [OpenStudio::Measure::OSRunner] Object typically used to display warnings
9+
# @param state [String] State code from the HPXML file
10+
# @param column_names [Array<String>] list of the schedule column names to generate
11+
# @param random_seed [Integer] the seed for the random number generator
12+
# @param minutes_per_step [Integer] the simulation timestep (minutes)
13+
# @param steps_in_day [Integer] the number of steps in a 24-hour day
14+
# @param mkc_ts_per_day [Integer] Markov chain timesteps per day
15+
# @param mkc_ts_per_hour [Integer] Markov chain timesteps per hour
16+
# @param total_days_in_year [Integer] number of days in the calendar year
17+
# @param sim_year [Integer] the calendar year
18+
# @param sim_start_day [DateTime] the DateTime object corresponding to Jan 1 of the calendar year
19+
# @param debug [Boolean] If true, writes extra column(s) (e.g., sleeping) for informational purposes.
20+
# @param append_output [Boolean] If true and the output CSV file already exists, appends columns to the file rather than overwriting it. The existing output CSV file must have the same number of rows (i.e., timeseries frequency) as the new columns being appended.
2121
def initialize(runner:,
2222
state:,
2323
column_names: nil,
@@ -49,18 +49,18 @@ def initialize(runner:,
4949

5050
attr_accessor(:schedules)
5151

52-
# TODO
52+
# Get the subset of schedule column names that the stochastic schedule generator supports.
5353
#
54-
# @return [TODO] TODO
54+
# @return [Array<String>] list of all schedule column names whose schedules can be stochastically generated
5555
def self.export_columns
5656
return SchedulesFile::Columns.values.select { |c| c.can_be_stochastic }.map { |c| c.name }
5757
end
5858

59-
# TODO
59+
# The top-level method for initializing the schedules hash just before calling the main stochastic schedules method.
6060
#
61-
# @param args [TODO] TODO
61+
# @param args [Hash] Map of :argument_name => value
6262
# @param weather [WeatherFile] Weather object containing EPW information
63-
# @return [TODO] TODO
63+
# @return [Boolean] true if successful
6464
def create(args:,
6565
weather:)
6666
@schedules = {}
@@ -85,11 +85,11 @@ def create(args:,
8585
return true
8686
end
8787

88-
# TODO
88+
# The main method for creating stochastic schedules.
8989
#
90-
# @param args [TODO] TODO
90+
# @param args [Hash] Map of :argument_name => value
9191
# @param weather [WeatherFile] Weather object containing EPW information
92-
# @return [TODO] TODO
92+
# @return [Boolean] true if successful
9393
def create_stochastic_schedules(args:,
9494
weather:)
9595
# initialize a random number generator

0 commit comments

Comments
 (0)