openstudio-analysis 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +2 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -5
- data/LICENSE.md +1 -1
- data/Rakefile +1 -1
- data/lib/openstudio-analysis.rb +1 -1
- data/lib/openstudio/analysis.rb +23 -27
- data/lib/openstudio/analysis/algorithm_attributes.rb +1 -1
- data/lib/openstudio/analysis/formulation.rb +1 -1
- data/lib/openstudio/analysis/server_api.rb +8 -14
- data/lib/openstudio/analysis/support_files.rb +1 -1
- data/lib/openstudio/analysis/translator/datapoints.rb +1 -1
- data/lib/openstudio/analysis/translator/excel.rb +2 -2
- data/lib/openstudio/analysis/translator/workflow.rb +8 -12
- data/lib/openstudio/analysis/version.rb +2 -2
- data/lib/openstudio/analysis/workflow.rb +1 -1
- data/lib/openstudio/analysis/workflow_step.rb +63 -71
- data/lib/openstudio/helpers/hash.rb +1 -1
- data/lib/openstudio/helpers/string.rb +1 -1
- data/lib/openstudio/weather/epw.rb +1 -1
- data/openstudio-analysis.gemspec +17 -13
- data/update_license.rb +3 -3
- metadata +57 -181
- data/spec/files/0_1_09_no_variables.xlsx +0 -0
- data/spec/files/0_1_09_outputvars.xlsx +0 -0
- data/spec/files/0_1_09_setup_version_2.xlsx +0 -0
- data/spec/files/0_1_09_small_list.xlsx +0 -0
- data/spec/files/0_1_09_small_list_incomplete.xlsx +0 -0
- data/spec/files/0_1_09_small_list_repeat_vars.xlsx +0 -0
- data/spec/files/0_1_09_small_list_validation_errors.xlsx +0 -0
- data/spec/files/0_1_10_proxy.xlsx +0 -0
- data/spec/files/0_1_10_proxy_user.xlsx +0 -0
- data/spec/files/0_1_10_template_input.xlsx +0 -0
- data/spec/files/0_1_11_discrete_variables.xlsx +0 -0
- data/spec/files/0_1_12_discrete_dynamic_columns.xlsx +0 -0
- data/spec/files/0_2_0_template.xlsx +0 -0
- data/spec/files/0_2_0_template_simpletest.xlsx +0 -0
- data/spec/files/0_3_0_dynamic_uuids.xlsx +0 -0
- data/spec/files/0_3_0_measure_existence.xlsx +0 -0
- data/spec/files/0_3_0_outputs.xlsx +0 -0
- data/spec/files/0_3_3_short_names.xlsx +0 -0
- data/spec/files/0_3_5_multiple_measure_paths.xlsx +0 -0
- data/spec/files/0_3_7_unique_measure_names.xlsx +0 -0
- data/spec/files/0_3_7_worker_init_final.xlsx +0 -0
- data/spec/files/0_4_0_lhs_discrete_continuous.xlsx +0 -0
- data/spec/files/0_4_0_multiple_seeds.xlsx +0 -0
- data/spec/files/0_4_0_pivot_test.xlsx +0 -0
- data/spec/files/analysis/examples/discrete_lhs_example.json +0 -809
- data/spec/files/analysis/examples/medium_office_example.json +0 -1674
- data/spec/files/analysis/examples/medium_office_workflow.json +0 -1298
- data/spec/files/measures/ActualMeasureNoJson/measure.rb +0 -80
- data/spec/files/measures/ActualMeasureNoJson/measure.xml +0 -2
- data/spec/files/measures/ExampleMeasure/measure.json +0 -3
- data/spec/files/measures/ExampleMeasure/measure.rb +0 -5
- data/spec/files/measures/ExampleMeasure/measure.xml +0 -1
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.json +0 -36
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.rb +0 -22
- data/spec/files/measures/IncreaseInsulationRValueForRoofs/measure.xml +0 -5
- data/spec/files/measures/NoMeasureRbFile/.gitkeep +0 -0
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.json +0 -3
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.rb +0 -5
- data/spec/files/measures/ReduceLightingLoadsByPercentage/measure.xml +0 -1
- data/spec/files/measures/SetThermostatSchedules/measure.json +0 -63
- data/spec/files/measures/SetThermostatSchedules/measure.rb +0 -254
- data/spec/files/measures/SetThermostatSchedules/measure.xml +0 -2
- data/spec/files/measures/example_measure_auto_directory_name/measure.json +0 -3
- data/spec/files/measures/example_measure_auto_directory_name/measure.rb +0 -5
- data/spec/files/measures/example_measure_auto_directory_name/measure.xml +0 -1
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.json +0 -3
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_lighting_loads_by_percentage/measure.xml +0 -1
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.rb +0 -5
- data/spec/files/measures/reduce_space_infiltration_by_percentage/measure.xml +0 -1
- data/spec/files/measures/rotate_building/measure.rb +0 -5
- data/spec/files/measures/rotate_building/measure.xml +0 -1
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.rb +0 -5
- data/spec/files/measures/set_window_to_wall_ratio_by_facade/measure.xml +0 -1
- data/spec/files/measures_second_path/measure_in_another_dir/measure.json +0 -3
- data/spec/files/measures_second_path/measure_in_another_dir/measure.rb +0 -5
- data/spec/files/measures_second_path/measure_in_another_dir/measure.xml +0 -1
- data/spec/files/partial_weather.epw +0 -32
- data/spec/files/partial_weather_2.epw +0 -32
- data/spec/files/small_seed.osm +0 -4622
- data/spec/files/worker_init/first_file.rb +0 -15
- data/spec/files/worker_init/second_file.sh +0 -4
- data/spec/files/workflow/analysis.osa +0 -1334
- data/spec/files/workflow/datapoint_0.osd +0 -65
- data/spec/files/workflow/datapoint_1.osd +0 -65
- data/spec/files/workflow/datapoint_2.osd +0 -65
- data/spec/files/workflow/datapoint_wrong_osa_id.osd +0 -65
- data/spec/integration/server_api_spec.rb +0 -83
- data/spec/openstudio/excel_spec.rb +0 -606
- data/spec/openstudio/formulation_spec.rb +0 -200
- data/spec/openstudio/hash_spec.rb +0 -56
- data/spec/openstudio/osw_spec.rb +0 -129
- data/spec/openstudio/server_api_spec.rb +0 -68
- data/spec/openstudio/string_spec.rb +0 -34
- data/spec/openstudio/support_files_spec.rb +0 -89
- data/spec/openstudio/weather_spec.rb +0 -80
- data/spec/openstudio/workflow_spec.rb +0 -126
- data/spec/openstudio/workflow_step_spec.rb +0 -158
- data/spec/schema/osa.json +0 -613
- data/spec/schema/osa.png +0 -0
- data/spec/schema/osd.json +0 -110
- data/spec/schema/osd.png +0 -0
- data/spec/spec_helper.rb +0 -56
@@ -1,80 +0,0 @@
|
|
1
|
-
#start the measure
|
2
|
-
class RotateBuilding < OpenStudio::Ruleset::ModelUserScript
|
3
|
-
|
4
|
-
#define the name that a user will see
|
5
|
-
def name
|
6
|
-
return "Rotate Building"
|
7
|
-
end
|
8
|
-
|
9
|
-
#define the arguments that the user will input
|
10
|
-
def arguments(model)
|
11
|
-
args = OpenStudio::Ruleset::OSArgumentVector.new
|
12
|
-
|
13
|
-
#make an argument for your name
|
14
|
-
relative_building_rotation = OpenStudio::Ruleset::OSArgument::makeDoubleArgument("relative_building_rotation",true)
|
15
|
-
relative_building_rotation.setDisplayName("Number of Degrees to Rotate Building (positive value is clockwise).")
|
16
|
-
relative_building_rotation.setDefaultValue(90.0)
|
17
|
-
args << relative_building_rotation
|
18
|
-
|
19
|
-
return args
|
20
|
-
end #end the arguments method
|
21
|
-
|
22
|
-
#define what happens when the measure is run
|
23
|
-
def run(model, runner, user_arguments)
|
24
|
-
super(model, runner, user_arguments)
|
25
|
-
|
26
|
-
#use the built-in error checking
|
27
|
-
if not runner.validateUserArguments(arguments(model), user_arguments)
|
28
|
-
return false
|
29
|
-
end
|
30
|
-
|
31
|
-
#assign the user inputs to variables
|
32
|
-
relative_building_rotation = runner.getDoubleArgumentValue("relative_building_rotation",user_arguments)
|
33
|
-
|
34
|
-
#check the relative_building_rotation for reasonableness
|
35
|
-
if relative_building_rotation > 360 or relative_building_rotation < -360
|
36
|
-
relative_building_rotation = relative_building_rotation -360.0*(relative_building_rotation/360.0).truncate
|
37
|
-
runner.registerWarning("Requested rotation was not between -360 and 360. Effective relative rotation is #{relative_building_rotation} degrees.")
|
38
|
-
end
|
39
|
-
|
40
|
-
#reporting initial condition of model
|
41
|
-
building = model.getBuilding
|
42
|
-
runner.registerValue("orientation_initial",building.northAxis)
|
43
|
-
runner.registerInitialCondition("The building's initial rotation was #{building.northAxis} degrees.")
|
44
|
-
|
45
|
-
#report as not applicable if effective relative rotation is 0
|
46
|
-
if relative_building_rotation == 0
|
47
|
-
runner.registerAsNotApplicable("The requested rotation was 0 degrees. The model was not altered.")
|
48
|
-
else
|
49
|
-
#rotate the building
|
50
|
-
final_building_angle = building.setNorthAxis(building.northAxis + relative_building_rotation)
|
51
|
-
runner.registerInfo("The building has been rotated by #{relative_building_rotation} degrees.")
|
52
|
-
end
|
53
|
-
|
54
|
-
#check for site shading
|
55
|
-
model_contains_site_shading = false
|
56
|
-
shading_surface_groups = model.getShadingSurfaceGroups
|
57
|
-
shading_surface_groups.each do |shading_surface_group|
|
58
|
-
if shading_surface_group.shadingSurfaceType == "Site"
|
59
|
-
model_contains_site_shading = true
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
#issue warning if site shading surfaces exist
|
64
|
-
if model_contains_site_shading
|
65
|
-
runner.registerWarning("The model contains one or more site shading groups. They were not rotated with the building.")
|
66
|
-
end
|
67
|
-
|
68
|
-
#reporting final condition of model
|
69
|
-
runner.registerValue("orientation_final",building.northAxis)
|
70
|
-
runner.registerFinalCondition("The building's final rotation is #{building.northAxis} degrees.")
|
71
|
-
|
72
|
-
return true
|
73
|
-
|
74
|
-
end #end the run method
|
75
|
-
|
76
|
-
|
77
|
-
end #end the measure
|
78
|
-
|
79
|
-
#this allows the measure to be used by the application
|
80
|
-
RotateBuilding.new.registerWithApplication
|
@@ -1,2 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<measure xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://bcl.nrel.gov/xsd/measures/version/1.0.xsd"><name>Rotate Building Relative to Current Orientation</name><uid>a5be6c96-4ecc-47fa-8d32-f4216ebc2e7d</uid><version_id>aeb20d61-b773-4d20-a2ef-fe948cdc2858</version_id><description>Rotate your building relative to its current orientation. This will not rotate site shading objects.</description><modeler_description>Get the North Axis field for the OS:Building object and adjusted it based on the user specified value. If the starting value is 20 degrees and the user value is 5 degrees, then the resulting value is 25 degrees.</modeler_description><tags><tag>Envelope.Form</tag></tags><attributes><attribute><name>Measure Type</name><value>ModelMeasure</value><datatype>string</datatype></attribute><attribute><name>Measure Function</name><value>Measure</value><datatype>string</datatype></attribute><attribute><name>Requires EnergyPlus Results</name><value>false</value><datatype>boolean</datatype></attribute><attribute><name>Uses SketchUp API</name><value>false</value><datatype>boolean</datatype></attribute></attributes><files><file><filename>RotateBuilding_TestModel_01.osm</filename><filetype>osm</filetype><usage_type>test</usage_type><checksum>E5C7E0B6</checksum></file><file><filename>RotateBuilding_Test.rb</filename><filetype>rb</filetype><usage_type>test</usage_type><checksum>D9410036</checksum></file><file><version><software_program>OpenStudio</software_program><identifier>1.3.0</identifier></version><filename>measure.rb</filename><filetype>rb</filetype><usage_type>script</usage_type><checksum>FEC15373</checksum></file></files></measure>
|
@@ -1 +0,0 @@
|
|
1
|
-
<name>Not a real XML file</name>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"classname": "IncreaseInsulationRValueForRoofs",
|
3
|
-
"path": "./measures/IncreaseInsulationRValueForRoofs",
|
4
|
-
"name": "Set R-value of Insulation for Roofs to a Specific Value",
|
5
|
-
"measure_type": "RubyMeasure",
|
6
|
-
"arguments": [
|
7
|
-
{
|
8
|
-
"local_variable": "r_value",
|
9
|
-
"variable_type": "Double",
|
10
|
-
"name": "r_value",
|
11
|
-
"display_name": "Insulation R-value (ft^2*h*R/Btu).",
|
12
|
-
"default_value": 30.0
|
13
|
-
},
|
14
|
-
{
|
15
|
-
"local_variable": "material_cost_increase_ip",
|
16
|
-
"variable_type": "Double",
|
17
|
-
"name": "material_cost_increase_ip",
|
18
|
-
"display_name": "Increase in Material and Installation Costs for Construction per Area Used ($/ft^2).",
|
19
|
-
"default_value": 0.0
|
20
|
-
},
|
21
|
-
{
|
22
|
-
"local_variable": "one_time_retrofit_cost_ip",
|
23
|
-
"variable_type": "Double",
|
24
|
-
"name": "one_time_retrofit_cost_ip",
|
25
|
-
"display_name": "One Time Retrofit Cost to Add Insulation to Construction ($/ft^2).",
|
26
|
-
"default_value": 0.0
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"local_variable": "years_until_retrofit_cost",
|
30
|
-
"variable_type": "Integer",
|
31
|
-
"name": "years_until_retrofit_cost",
|
32
|
-
"display_name": "Year to Incur One Time Retrofit Cost (whole years).",
|
33
|
-
"default_value": 0
|
34
|
-
}
|
35
|
-
]
|
36
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# start the measure
|
2
|
-
class IncreaseInsulationRValueForRoofs < OpenStudio::Ruleset::ModelUserScript
|
3
|
-
# define the name that a user will see
|
4
|
-
def name
|
5
|
-
'Increase R-value of Insulation for Roofs to a Specific Value'
|
6
|
-
end
|
7
|
-
|
8
|
-
# define the arguments that the user will input
|
9
|
-
def arguments(_model)
|
10
|
-
args = OpenStudio::Ruleset::OSArgumentVector.new
|
11
|
-
end # end the arguments method
|
12
|
-
|
13
|
-
# define what happens when the measure is run
|
14
|
-
def run(model, runner, user_arguments)
|
15
|
-
super(model, runner, user_arguments)
|
16
|
-
|
17
|
-
true
|
18
|
-
end # end the run method
|
19
|
-
end # end the measure
|
20
|
-
|
21
|
-
# this allows the measure to be used by the application
|
22
|
-
IncreaseInsulationRValueForRoofs.new.registerWithApplication
|
@@ -1,5 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<measure xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://bcl.nrel.gov/xsd/measures/version/1.0.xsd"><name>Set R-value of Insulation for Roofs to a Specific Value</name><uid>c6b78646-be8e-425b-af79-fdbbcd0d58d5</uid><version_id>8c8bd127-d07b-4ae3-ab5f-c15af5dedef2</version_id><description>Set the R-Value of roof insulation to a specified value. Higher R-Values provide better insulation, lowering heat loss and heat gain through the roof.</description><modeler_description>Set the R-Value (ft^2*h*R/Btu) of the insulation material layer in all roofs in the model to a specified value. Find constructions used for roofs, make copies of these and assign them to the appropriate construction sets or surfaces. Identify which layer of the construction is the insulation layer. This could be a Material, No Mass Material, or Air Gap Material. If the Insulation layer is "Material? the thickness will be changed to attain the desired R-Value. If the insulation layer is "No Mass Material? or "Air Gap Material? the Thermal Resistance will be directly entered. If the construction doesn't appear to have an insulation layer, it will not be altered. Surfaces with "Adiabatic" boundary conditions are not specifically assumed to be interior or exterior. As a result constructions used on "Adiabatic" surfaces will not be altered. Constructions used on attic floors will not be altered.
|
3
|
-
|
4
|
-
The resulting construction will retain the cost data from the source construction, however material and installation cost can be increased which will affect replacement cost if it happens during the analysis period. Additionally a one-time cost can be added to reflect any retrofit costs that occur at some point prior to replacement.
|
5
|
-
</modeler_description><tags><tag>Envelope.Opaque</tag></tags><attributes><attribute><name>Measure Type</name><value>ModelMeasure</value><datatype>string</datatype></attribute><attribute><name>Measure Function</name><value>Measure</value><datatype>string</datatype></attribute><attribute><name>Requires EnergyPlus Results</name><value>false</value><datatype>boolean</datatype></attribute><attribute><name>Uses SketchUp API</name><value>false</value><datatype>boolean</datatype></attribute></attributes><files><file><filename>EnvelopeAndLoadTestModel_01.osm</filename><filetype>osm</filetype><usage_type>test</usage_type><checksum>938A1BB0</checksum></file><file><filename>ReverseTranslatedModel.osm</filename><filetype>osm</filetype><usage_type>test</usage_type><checksum>20C95654</checksum></file><file><filename>IncreaseInsulationRValueForRoofs_Test.rb</filename><filetype>rb</filetype><usage_type>test</usage_type><checksum>FA410C73</checksum></file><file><version><software_program>OpenStudio</software_program><identifier>0.11.5</identifier></version><filename>measure.rb</filename><filetype>rb</filetype><usage_type>script</usage_type><checksum>E720BF68</checksum></file></files></measure>
|
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
<name>Not a real XML file</name>
|
@@ -1,63 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"classname": "SetThermostatSchedules",
|
3
|
-
"name": "set_thermostat_schedules",
|
4
|
-
"display_name": "Set Thermostat Schedules",
|
5
|
-
"measure_type": "RubyMeasure",
|
6
|
-
"arguments": [
|
7
|
-
{
|
8
|
-
"local_variable": "zones",
|
9
|
-
"variable_type": "Choice",
|
10
|
-
"name": "zones",
|
11
|
-
"display_name": "Choose Thermal Zones to change thermostat schedules on",
|
12
|
-
"units": null,
|
13
|
-
"description": null,
|
14
|
-
"default_value": "*All Thermal Zones*",
|
15
|
-
"choices": [
|
16
|
-
"*All Thermal Zones*"
|
17
|
-
]
|
18
|
-
},
|
19
|
-
{
|
20
|
-
"local_variable": "cooling_sch",
|
21
|
-
"variable_type": "Choice",
|
22
|
-
"name": "cooling_sch",
|
23
|
-
"display_name": "Choose Cooling Schedule",
|
24
|
-
"units": null,
|
25
|
-
"description": null,
|
26
|
-
"default_value": "*No Change*",
|
27
|
-
"choices": [
|
28
|
-
"",
|
29
|
-
"*No Change*"
|
30
|
-
]
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"local_variable": "heating_sch",
|
34
|
-
"variable_type": "Choice",
|
35
|
-
"name": "heating_sch",
|
36
|
-
"display_name": "Choose Heating Schedule",
|
37
|
-
"units": null,
|
38
|
-
"description": null,
|
39
|
-
"default_value": "*No Change*",
|
40
|
-
"choices": [
|
41
|
-
"",
|
42
|
-
"*No Change*"
|
43
|
-
]
|
44
|
-
},
|
45
|
-
{
|
46
|
-
"local_variable": "material_cost",
|
47
|
-
"variable_type": "Double",
|
48
|
-
"name": "material_cost",
|
49
|
-
"display_name": "Material and Installation Costs per Thermal Zone",
|
50
|
-
"units": "$/thermal zone",
|
51
|
-
"description": null,
|
52
|
-
"default_value": 0.0
|
53
|
-
}
|
54
|
-
],
|
55
|
-
"name_xml": "Set Thermostat Schedules",
|
56
|
-
"uid": "d241d623-d596-4b26-9b67-fe390be1e839",
|
57
|
-
"version_id": "699b90d0-1b73-4208-869a-c6987afda0da",
|
58
|
-
"modeler_description": "Sets zone thermostat schedules to schedules in the same file. If a zone does not have a thermostat this measure will add one.",
|
59
|
-
"description": "Sets zone thermostat schedules to schedules in the same file. If a zone does not have a thermostat this measure will add one",
|
60
|
-
"tags": [
|
61
|
-
"HVAC.HVAC Controls"
|
62
|
-
]
|
63
|
-
}
|
@@ -1,254 +0,0 @@
|
|
1
|
-
#see the URL below for information on how to write OpenStuido measures
|
2
|
-
# http://openstudio.nrel.gov/openstudio-measure-writing-guide
|
3
|
-
|
4
|
-
#start the measure
|
5
|
-
class SetThermostatSchedules < OpenStudio::Ruleset::ModelUserScript
|
6
|
-
|
7
|
-
#define the name that a user will see, this method may be deprecated as
|
8
|
-
#the display name in PAT comes from the name field in measure.xml
|
9
|
-
def name
|
10
|
-
return "Set Thermostat Schedules"
|
11
|
-
end
|
12
|
-
|
13
|
-
#define the arguments that the user will input
|
14
|
-
def arguments(model)
|
15
|
-
args = OpenStudio::Ruleset::OSArgumentVector.new
|
16
|
-
|
17
|
-
#populate choice argument for thermal zones in the model
|
18
|
-
zone_handles = OpenStudio::StringVector.new
|
19
|
-
zone_display_names = OpenStudio::StringVector.new
|
20
|
-
|
21
|
-
#putting zone names into hash
|
22
|
-
zone_hash = {}
|
23
|
-
model.getThermalZones.each do |zone|
|
24
|
-
zone_hash[zone.name.to_s] = zone
|
25
|
-
end
|
26
|
-
|
27
|
-
#looping through sorted hash of zones
|
28
|
-
zone_hash.sort.map do |zone_name, zone|
|
29
|
-
if zone.thermostatSetpointDualSetpoint.is_initialized
|
30
|
-
zone_handles << zone.handle.to_s
|
31
|
-
zone_display_names << zone_name
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
#add building to string vector with zones
|
36
|
-
building = model.getBuilding
|
37
|
-
zone_handles << building.handle.to_s
|
38
|
-
zone_display_names << "*All Thermal Zones*"
|
39
|
-
|
40
|
-
#make an argument for zones
|
41
|
-
zones = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("zones", zone_handles, zone_display_names, true)
|
42
|
-
zones.setDisplayName("Choose Thermal Zones to change thermostat schedules on.")
|
43
|
-
zones.setDefaultValue("*All Thermal Zones*") #if no zone is chosen this will run on all zones
|
44
|
-
args << zones
|
45
|
-
|
46
|
-
#populate choice argument for schedules in the model
|
47
|
-
sch_handles = OpenStudio::StringVector.new
|
48
|
-
sch_display_names = OpenStudio::StringVector.new
|
49
|
-
|
50
|
-
#putting schedule names into hash
|
51
|
-
sch_hash = {}
|
52
|
-
model.getSchedules.each do |sch|
|
53
|
-
sch_hash[sch.name.to_s] = sch
|
54
|
-
end
|
55
|
-
|
56
|
-
#looping through sorted hash of schedules
|
57
|
-
sch_hash.sort.map do |sch_name, sch|
|
58
|
-
if not sch.scheduleTypeLimits.empty?
|
59
|
-
unitType = sch.scheduleTypeLimits.get.unitType
|
60
|
-
#puts "#{sch.name}, #{unitType}"
|
61
|
-
if unitType == "Temperature"
|
62
|
-
sch_handles << sch.handle.to_s
|
63
|
-
sch_display_names << sch_name
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
#add empty handle to string vector with schedules
|
69
|
-
sch_handles << OpenStudio::toUUID("").to_s
|
70
|
-
sch_display_names << "*No Change*"
|
71
|
-
|
72
|
-
#make an argument for cooling schedule
|
73
|
-
cooling_sch = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("cooling_sch", sch_handles, sch_display_names, true)
|
74
|
-
cooling_sch.setDisplayName("Choose Cooling Schedule.")
|
75
|
-
cooling_sch.setDefaultValue("*No Change*") #if no change is chosen then cooling schedules will not be changed
|
76
|
-
args << cooling_sch
|
77
|
-
|
78
|
-
#make an argument for heating schedule
|
79
|
-
heating_sch = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("heating_sch", sch_handles, sch_display_names, true)
|
80
|
-
heating_sch.setDisplayName("Choose Heating Schedule.")
|
81
|
-
heating_sch.setDefaultValue("*No Change*") #if no change is chosen then heating schedules will not be changed
|
82
|
-
args << heating_sch
|
83
|
-
|
84
|
-
#make an argument for material and installation cost
|
85
|
-
material_cost = OpenStudio::Ruleset::OSArgument::makeDoubleArgument("material_cost",true)
|
86
|
-
material_cost.setDisplayName("Material and Installation Costs per Thermal Zone ($/thermal zone).")
|
87
|
-
material_cost.setDefaultValue(0.0)
|
88
|
-
args << material_cost
|
89
|
-
|
90
|
-
return args
|
91
|
-
end #end the arguments method
|
92
|
-
|
93
|
-
#define what happens when the measure is run
|
94
|
-
def run(model, runner, user_arguments)
|
95
|
-
super(model, runner, user_arguments)
|
96
|
-
|
97
|
-
#use the built-in error checking
|
98
|
-
if not runner.validateUserArguments(arguments(model), user_arguments)
|
99
|
-
return false
|
100
|
-
end
|
101
|
-
|
102
|
-
#assign the user inputs to variables
|
103
|
-
zones = runner.getOptionalWorkspaceObjectChoiceValue("zones",user_arguments,model) #model is passed in because of argument type
|
104
|
-
cooling_sch = runner.getOptionalWorkspaceObjectChoiceValue("cooling_sch",user_arguments,model) #model is passed in because of argument type
|
105
|
-
heating_sch = runner.getOptionalWorkspaceObjectChoiceValue("heating_sch",user_arguments,model) #model is passed in because of argument type
|
106
|
-
material_cost = runner.getDoubleArgumentValue("material_cost",user_arguments)
|
107
|
-
|
108
|
-
#check the zone selection for reasonableness
|
109
|
-
apply_to_all_zones = false
|
110
|
-
selected_zone = nil
|
111
|
-
if zones.empty?
|
112
|
-
handle = runner.getStringArgumentValue("zones",user_arguments)
|
113
|
-
if handle.empty?
|
114
|
-
runner.registerError("No thermal zone was chosen.")
|
115
|
-
return false
|
116
|
-
else
|
117
|
-
runner.registerError("The selected thermal zone with handle '#{handle}' was not found in the model. It may have been removed by another measure.")
|
118
|
-
return false
|
119
|
-
end
|
120
|
-
else
|
121
|
-
if not zones.get.to_ThermalZone.empty?
|
122
|
-
selected_zone = zones.get.to_ThermalZone.get
|
123
|
-
elsif not zones.get.to_Building.empty?
|
124
|
-
apply_to_all_zones = true
|
125
|
-
else
|
126
|
-
runner.registerError("Script Error - argument not showing up as thermal zone.")
|
127
|
-
return false
|
128
|
-
end
|
129
|
-
end #end of if zones.empty?
|
130
|
-
|
131
|
-
#depending on user input, add selected zones to an array
|
132
|
-
selected_zones = []
|
133
|
-
if apply_to_all_zones == true
|
134
|
-
selected_zones = model.getThermalZones
|
135
|
-
else
|
136
|
-
selected_zones << selected_zone
|
137
|
-
end
|
138
|
-
|
139
|
-
#check the cooling_sch for reasonableness
|
140
|
-
if cooling_sch.empty?
|
141
|
-
handle = runner.getStringArgumentValue("cooling_sch",user_arguments)
|
142
|
-
if handle == OpenStudio::toUUID("").to_s
|
143
|
-
# no change
|
144
|
-
cooling_sch = nil
|
145
|
-
else
|
146
|
-
runner.registerError("The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.")
|
147
|
-
return false
|
148
|
-
end
|
149
|
-
else
|
150
|
-
if not cooling_sch.get.to_Schedule.empty?
|
151
|
-
cooling_sch = cooling_sch.get.to_Schedule.get
|
152
|
-
else
|
153
|
-
runner.registerError("Script Error - argument not showing up as schedule.")
|
154
|
-
return false
|
155
|
-
end
|
156
|
-
end #end of if cooling_sch.empty?
|
157
|
-
|
158
|
-
#check the heating_sch for reasonableness
|
159
|
-
if heating_sch.empty?
|
160
|
-
handle = runner.getStringArgumentValue("heating_sch",user_arguments)
|
161
|
-
if handle == OpenStudio::toUUID("").to_s
|
162
|
-
# no change
|
163
|
-
heating_sch = nil
|
164
|
-
else
|
165
|
-
runner.registerError("The selected schedule with handle '#{handle}' was not found in the model. It may have been removed by another measure.")
|
166
|
-
return false
|
167
|
-
end
|
168
|
-
else
|
169
|
-
if not heating_sch.get.to_Schedule.empty?
|
170
|
-
heating_sch = heating_sch.get.to_Schedule.get
|
171
|
-
else
|
172
|
-
runner.registerError("Script Error - argument not showing up as schedule.")
|
173
|
-
return false
|
174
|
-
end
|
175
|
-
end #end of if heating_sch.empty?
|
176
|
-
|
177
|
-
number_zones_modified = 0
|
178
|
-
total_cost = 0
|
179
|
-
if heating_sch or cooling_sch
|
180
|
-
|
181
|
-
selected_zones.each do |zone|
|
182
|
-
|
183
|
-
thermostatSetpointDualSetpoint = zone.thermostatSetpointDualSetpoint
|
184
|
-
if thermostatSetpointDualSetpoint.empty?
|
185
|
-
runner.registerInfo("Creating thermostat for thermal zone '#{zone.name}'.")
|
186
|
-
|
187
|
-
thermostatSetpointDualSetpoint = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(model)
|
188
|
-
zone.setThermostatSetpointDualSetpoint(thermostatSetpointDualSetpoint)
|
189
|
-
else
|
190
|
-
thermostatSetpointDualSetpoint = thermostatSetpointDualSetpoint.get
|
191
|
-
|
192
|
-
# make sure this thermostat is unique to this zone
|
193
|
-
if thermostatSetpointDualSetpoint.getSources("OS_ThermalZone".to_IddObjectType).size > 1
|
194
|
-
# if not create a new copy
|
195
|
-
runner.registerInfo("Copying thermostat for thermal zone '#{zone.name}'.")
|
196
|
-
|
197
|
-
oldThermostat = thermostatSetpointDualSetpoint
|
198
|
-
thermostatSetpointDualSetpoint = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(model)
|
199
|
-
if not oldThermostat.heatingSetpointTemperatureSchedule.empty?
|
200
|
-
thermostatSetpointDualSetpoint.setHeatingSetpointTemperatureSchedule(oldThermostat.heatingSetpointTemperatureSchedule.get)
|
201
|
-
end
|
202
|
-
if not oldThermostat.coolingSetpointTemperatureSchedule.empty?
|
203
|
-
thermostatSetpointDualSetpoint.setCoolingSetpointTemperatureSchedule(oldThermostat.coolingSetpointTemperatureSchedule.get)
|
204
|
-
end
|
205
|
-
zone.setThermostatSetpointDualSetpoint(thermostatSetpointDualSetpoint)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
if heating_sch
|
210
|
-
if not thermostatSetpointDualSetpoint.setHeatingSetpointTemperatureSchedule(heating_sch)
|
211
|
-
runner.registerError("Script Error - cannot set heating schedule for thermal zone '#{zone.name}'.")
|
212
|
-
return false
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
if cooling_sch
|
217
|
-
if not thermostatSetpointDualSetpoint.setCoolingSetpointTemperatureSchedule(cooling_sch)
|
218
|
-
runner.registerError("Script Error - cannot set cooling schedule for thermal zone '#{zone.name}'.")
|
219
|
-
return false
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
if material_cost.abs != 0
|
224
|
-
total_cost += material_cost
|
225
|
-
OpenStudio::Model::LifeCycleCost::createLifeCycleCost("LCC_Mat - #{zone.name} Thermostats", zone, material_cost, "CostPerEach", "Construction")
|
226
|
-
end
|
227
|
-
|
228
|
-
number_zones_modified += 1
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
runner.registerFinalCondition("Replaced thermostats for #{number_zones_modified} thermal zones, capital cost #{total_cost}")
|
233
|
-
|
234
|
-
if number_zones_modified == 0
|
235
|
-
runner.registerAsNotApplicable("No thermostats altered")
|
236
|
-
end
|
237
|
-
|
238
|
-
return true
|
239
|
-
|
240
|
-
end #end the run method
|
241
|
-
|
242
|
-
end #end the measure
|
243
|
-
|
244
|
-
#this allows the measure to be use by the application
|
245
|
-
SetThermostatSchedules.new.registerWithApplication
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|