From 2a108e33c19a9757af54d155b27b38681298f925 Mon Sep 17 00:00:00 2001 From: Matthew Dahlhausen Date: Sun, 12 Mar 2023 12:34:10 -0600 Subject: [PATCH 1/3] fix type and delete extra methods change methods to use find_and_set_insulation_layer instead of find_and_set_insulaton_layer (misspelled), and delete all instances of find_and_set_insulaton_layer (misspelled) --- lib/openstudio-standards/btap/btap.model.rb | 41 +----------- lib/openstudio-standards/btap/envelope.rb | 62 +------------------ .../standards/Standards.Construction.rb | 2 +- 3 files changed, 3 insertions(+), 102 deletions(-) diff --git a/lib/openstudio-standards/btap/btap.model.rb b/lib/openstudio-standards/btap/btap.model.rb index 3e5dd84f3d..ae8b98071f 100644 --- a/lib/openstudio-standards/btap/btap.model.rb +++ b/lib/openstudio-standards/btap/btap.model.rb @@ -2,45 +2,6 @@ class OpenStudio::Model::Construction - #This method will search through the layers and find the layer with the - #lowest conductance and set that as the insulation layer. Note: Concrete walls - #or slabs with no insulation layer but with a carper will see the carpet as the - #insulation layer. - #@author Phylroy A. Lopez - #@return OpenStudio::Model::Material insulation_material_layer - def self.find_and_set_insulaton_layer() - insulation_material_layer = nil - #return if there is already a defined insulation layer. - return self.insulation unless self.insulation.empty? - #set minimum conductance to 100.0 - min_conductance = 100.0 - #loop through Layers - self.layers.each do |layer| - #try casting the layer to an OpaqueMaterial. - material = nil - material = layer.to_OpaqueMaterial.get unless layer.to_OpaqueMaterial.empty? - material = layer.to_FenestrationMaterial.get unless layer.to_FenestrationMaterial.empty? - #check if the cast was successful, then find the insulation layer. - unless nil == material - if BTAP::Resources::Envelope::Materials::get_conductance(material) < min_conductance - #Keep track of the highest thermal resistance value. - min_conductance = BTAP::Resources::Envelope::Materials::get_conductance(material) - insulation_material_layer = material - unless material.to_OpaqueMaterial.empty? - self.setInsulation(material) - end - end - end - end - if self.insulation.empty? and self.isOpaque - raise ("construction #{self.name.get.to_s} insulation layer could not be set!. This occurs when a insulation layer is duplicated in the construction.") - end - return insulation_material_layer - end - - - - #This method will create a new construction based on self and a new conductance value. #It will check to see if a similar construction has already been created by this method #if so it will return the existing construction. If you wish to keep some of the properties, enter the @@ -77,7 +38,7 @@ def customize(model, if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulaton_layer(self.model,new_construction) + find_and_set_insulation_layer(self.model,new_construction) #Determine how low the resistance can be set. Subtract existing insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/btap/envelope.rb b/lib/openstudio-standards/btap/envelope.rb index b1521958f8..45cbbec32f 100644 --- a/lib/openstudio-standards/btap/envelope.rb +++ b/lib/openstudio-standards/btap/envelope.rb @@ -502,19 +502,6 @@ def test_create_opaque_construction() assert(construction.insulation().get == @insulation) end - #This method will test find and set insulation layer. - # @author Phylroy A. Lopez - def test_find_and_set_insulaton_layer() - construction = BTAP::Resources::Envelope::Constructions::create_construction(@model, "test construction", [@opaque, @air_gap, @insulation, @massless, @opaque]) - - #check insulation was not set. - assert((construction.insulation().empty?)) - #now set it. - BTAP::Resources::Envelope::Constructions::find_and_set_insulaton_layer(@model, [construction]) - #Now check that it found the insulation value. - assert(construction.insulation().get == @insulation) - end - #This method will test creation of fenestration construction. #@author Phylroy A. Lopez def test_create_fenestration_construction() @@ -536,53 +523,6 @@ def test_create_new_construction_based_on_exisiting() end end # End Test Constructions - #This method will search through the layers and find the layer with the - #lowest conductance and set that as the insulation layer. Note: Concrete walls - #or slabs with no insulation layer but with a carper will see the carpet as the - #insulation layer. - #@author Phylroy A. Lopez - #@param model [OpenStudio::Model::Model] - #@param constructions_array [BTAP::Common::validate_array] - #@return insulating_layers - def self.find_and_set_insulaton_layer(model, constructions_array) - constructions_array = BTAP::Common::validate_array(model, constructions_array, "Construction") - insulating_layers = Array.new() - constructions_array.each do |construction| - return_material = "" - #skip if already has an insulation layer set. - next unless construction.insulation.empty? - #set insulation layer. - #find insulation layer - min_conductance = 100.0 - #loop through Layers - construction.layers.each do |layer| - #try casting the layer to an OpaqueMaterial. - material = nil - material = layer.to_OpaqueMaterial.get unless layer.to_OpaqueMaterial.empty? - material = layer.to_FenestrationMaterial.get unless layer.to_FenestrationMaterial.empty? - #check if the cast was successful, then find the insulation layer. - unless nil == material - - if BTAP::Resources::Envelope::Materials::get_conductance(material) < min_conductance - #Keep track of the highest thermal resistance value. - min_conductance = BTAP::Resources::Envelope::Materials::get_conductance(material) - return_material = material - unless material.to_OpaqueMaterial.empty? - construction.setInsulation(material) - end - end - end - end - if construction.insulation.empty? and construction.isOpaque - raise ("construction #{construction.name.get.to_s} insulation layer could not be set!. This occurs when a insulation layer is duplicated in the construction.") - end - - insulating_layers << return_material - end - - return insulating_layers - end - #This method will create a new construction based on self and a new conductance value. #It will check to see if a similar construction has already been created by this method #if so it will return the existing construction. If you wish to keep some of the properties, enter the @@ -619,7 +559,7 @@ def self.customize_opaque_construction(model, construction, conductance) if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulaton_layer(model, new_construction) + find_and_set_insulation_layer(model, new_construction) #Determine how low the resistance can be set. Subtract exisiting insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/standards/Standards.Construction.rb b/lib/openstudio-standards/standards/Standards.Construction.rb index b5725a7fd2..8aa3374d38 100644 --- a/lib/openstudio-standards/standards/Standards.Construction.rb +++ b/lib/openstudio-standards/standards/Standards.Construction.rb @@ -31,7 +31,7 @@ def construction_set_u_value(construction, target_u_value_ip, insulation_layer_n if insulation_layer_name.nil? && target_u_value_ip == 0.0 # Do nothing if the construction already doesn't have an insulation layer elsif insulation_layer_name.nil? - insulation_layer_name = find_and_set_insulaton_layer(construction).name + insulation_layer_name = find_and_set_insulation_layer(construction).name end # Remove the insulation layer if the specified U-value is zero. From e1d05c5ded81567cbd73643ed4315a0e771fd3dd Mon Sep 17 00:00:00 2001 From: Matthew Dahlhausen Date: Sun, 12 Mar 2023 17:56:08 -0600 Subject: [PATCH 2/3] Revert "fix type and delete extra methods" This reverts commit 2a108e33c19a9757af54d155b27b38681298f925. --- lib/openstudio-standards/btap/btap.model.rb | 41 +++++++++++- lib/openstudio-standards/btap/envelope.rb | 62 ++++++++++++++++++- .../standards/Standards.Construction.rb | 2 +- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/lib/openstudio-standards/btap/btap.model.rb b/lib/openstudio-standards/btap/btap.model.rb index ae8b98071f..3e5dd84f3d 100644 --- a/lib/openstudio-standards/btap/btap.model.rb +++ b/lib/openstudio-standards/btap/btap.model.rb @@ -2,6 +2,45 @@ class OpenStudio::Model::Construction + #This method will search through the layers and find the layer with the + #lowest conductance and set that as the insulation layer. Note: Concrete walls + #or slabs with no insulation layer but with a carper will see the carpet as the + #insulation layer. + #@author Phylroy A. Lopez + #@return OpenStudio::Model::Material insulation_material_layer + def self.find_and_set_insulaton_layer() + insulation_material_layer = nil + #return if there is already a defined insulation layer. + return self.insulation unless self.insulation.empty? + #set minimum conductance to 100.0 + min_conductance = 100.0 + #loop through Layers + self.layers.each do |layer| + #try casting the layer to an OpaqueMaterial. + material = nil + material = layer.to_OpaqueMaterial.get unless layer.to_OpaqueMaterial.empty? + material = layer.to_FenestrationMaterial.get unless layer.to_FenestrationMaterial.empty? + #check if the cast was successful, then find the insulation layer. + unless nil == material + if BTAP::Resources::Envelope::Materials::get_conductance(material) < min_conductance + #Keep track of the highest thermal resistance value. + min_conductance = BTAP::Resources::Envelope::Materials::get_conductance(material) + insulation_material_layer = material + unless material.to_OpaqueMaterial.empty? + self.setInsulation(material) + end + end + end + end + if self.insulation.empty? and self.isOpaque + raise ("construction #{self.name.get.to_s} insulation layer could not be set!. This occurs when a insulation layer is duplicated in the construction.") + end + return insulation_material_layer + end + + + + #This method will create a new construction based on self and a new conductance value. #It will check to see if a similar construction has already been created by this method #if so it will return the existing construction. If you wish to keep some of the properties, enter the @@ -38,7 +77,7 @@ def customize(model, if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulation_layer(self.model,new_construction) + find_and_set_insulaton_layer(self.model,new_construction) #Determine how low the resistance can be set. Subtract existing insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/btap/envelope.rb b/lib/openstudio-standards/btap/envelope.rb index 45cbbec32f..b1521958f8 100644 --- a/lib/openstudio-standards/btap/envelope.rb +++ b/lib/openstudio-standards/btap/envelope.rb @@ -502,6 +502,19 @@ def test_create_opaque_construction() assert(construction.insulation().get == @insulation) end + #This method will test find and set insulation layer. + # @author Phylroy A. Lopez + def test_find_and_set_insulaton_layer() + construction = BTAP::Resources::Envelope::Constructions::create_construction(@model, "test construction", [@opaque, @air_gap, @insulation, @massless, @opaque]) + + #check insulation was not set. + assert((construction.insulation().empty?)) + #now set it. + BTAP::Resources::Envelope::Constructions::find_and_set_insulaton_layer(@model, [construction]) + #Now check that it found the insulation value. + assert(construction.insulation().get == @insulation) + end + #This method will test creation of fenestration construction. #@author Phylroy A. Lopez def test_create_fenestration_construction() @@ -523,6 +536,53 @@ def test_create_new_construction_based_on_exisiting() end end # End Test Constructions + #This method will search through the layers and find the layer with the + #lowest conductance and set that as the insulation layer. Note: Concrete walls + #or slabs with no insulation layer but with a carper will see the carpet as the + #insulation layer. + #@author Phylroy A. Lopez + #@param model [OpenStudio::Model::Model] + #@param constructions_array [BTAP::Common::validate_array] + #@return insulating_layers + def self.find_and_set_insulaton_layer(model, constructions_array) + constructions_array = BTAP::Common::validate_array(model, constructions_array, "Construction") + insulating_layers = Array.new() + constructions_array.each do |construction| + return_material = "" + #skip if already has an insulation layer set. + next unless construction.insulation.empty? + #set insulation layer. + #find insulation layer + min_conductance = 100.0 + #loop through Layers + construction.layers.each do |layer| + #try casting the layer to an OpaqueMaterial. + material = nil + material = layer.to_OpaqueMaterial.get unless layer.to_OpaqueMaterial.empty? + material = layer.to_FenestrationMaterial.get unless layer.to_FenestrationMaterial.empty? + #check if the cast was successful, then find the insulation layer. + unless nil == material + + if BTAP::Resources::Envelope::Materials::get_conductance(material) < min_conductance + #Keep track of the highest thermal resistance value. + min_conductance = BTAP::Resources::Envelope::Materials::get_conductance(material) + return_material = material + unless material.to_OpaqueMaterial.empty? + construction.setInsulation(material) + end + end + end + end + if construction.insulation.empty? and construction.isOpaque + raise ("construction #{construction.name.get.to_s} insulation layer could not be set!. This occurs when a insulation layer is duplicated in the construction.") + end + + insulating_layers << return_material + end + + return insulating_layers + end + #This method will create a new construction based on self and a new conductance value. #It will check to see if a similar construction has already been created by this method #if so it will return the existing construction. If you wish to keep some of the properties, enter the @@ -559,7 +619,7 @@ def self.customize_opaque_construction(model, construction, conductance) if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulation_layer(model, new_construction) + find_and_set_insulaton_layer(model, new_construction) #Determine how low the resistance can be set. Subtract exisiting insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/standards/Standards.Construction.rb b/lib/openstudio-standards/standards/Standards.Construction.rb index 8aa3374d38..b5725a7fd2 100644 --- a/lib/openstudio-standards/standards/Standards.Construction.rb +++ b/lib/openstudio-standards/standards/Standards.Construction.rb @@ -31,7 +31,7 @@ def construction_set_u_value(construction, target_u_value_ip, insulation_layer_n if insulation_layer_name.nil? && target_u_value_ip == 0.0 # Do nothing if the construction already doesn't have an insulation layer elsif insulation_layer_name.nil? - insulation_layer_name = find_and_set_insulation_layer(construction).name + insulation_layer_name = find_and_set_insulaton_layer(construction).name end # Remove the insulation layer if the specified U-value is zero. From b2a7ed12a63e25e03db28c4284bdbd415672c69c Mon Sep 17 00:00:00 2001 From: Matthew Dahlhausen Date: Sun, 12 Mar 2023 17:58:25 -0600 Subject: [PATCH 3/3] fix typo in find_and_set_insulation_layer --- lib/openstudio-standards/btap/btap.model.rb | 4 ++-- lib/openstudio-standards/btap/envelope.rb | 8 ++++---- .../standards/Standards.Construction.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/openstudio-standards/btap/btap.model.rb b/lib/openstudio-standards/btap/btap.model.rb index 3e5dd84f3d..fe9e006d98 100644 --- a/lib/openstudio-standards/btap/btap.model.rb +++ b/lib/openstudio-standards/btap/btap.model.rb @@ -8,7 +8,7 @@ class OpenStudio::Model::Construction #insulation layer. #@author Phylroy A. Lopez #@return OpenStudio::Model::Material insulation_material_layer - def self.find_and_set_insulaton_layer() + def self.find_and_set_insulation_layer() insulation_material_layer = nil #return if there is already a defined insulation layer. return self.insulation unless self.insulation.empty? @@ -77,7 +77,7 @@ def customize(model, if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulaton_layer(self.model,new_construction) + find_and_set_insulation_layer(self.model,new_construction) #Determine how low the resistance can be set. Subtract existing insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/btap/envelope.rb b/lib/openstudio-standards/btap/envelope.rb index b1521958f8..3690de4681 100644 --- a/lib/openstudio-standards/btap/envelope.rb +++ b/lib/openstudio-standards/btap/envelope.rb @@ -504,13 +504,13 @@ def test_create_opaque_construction() #This method will test find and set insulation layer. # @author Phylroy A. Lopez - def test_find_and_set_insulaton_layer() + def test_find_and_set_insulation_layer() construction = BTAP::Resources::Envelope::Constructions::create_construction(@model, "test construction", [@opaque, @air_gap, @insulation, @massless, @opaque]) #check insulation was not set. assert((construction.insulation().empty?)) #now set it. - BTAP::Resources::Envelope::Constructions::find_and_set_insulaton_layer(@model, [construction]) + BTAP::Resources::Envelope::Constructions::find_and_set_insulation_layer(@model, [construction]) #Now check that it found the insulation value. assert(construction.insulation().get == @insulation) end @@ -544,7 +544,7 @@ def test_create_new_construction_based_on_exisiting() #@param model [OpenStudio::Model::Model] #@param constructions_array [BTAP::Common::validate_array] #@return insulating_layers - def self.find_and_set_insulaton_layer(model, constructions_array) + def self.find_and_set_insulation_layer(model, constructions_array) constructions_array = BTAP::Common::validate_array(model, constructions_array, "Construction") insulating_layers = Array.new() constructions_array.each do |construction| @@ -619,7 +619,7 @@ def self.customize_opaque_construction(model, construction, conductance) if conductance.kind_of?(Float) #re-find insulation layer - find_and_set_insulaton_layer(model, new_construction) + find_and_set_insulation_layer(model, new_construction) #Determine how low the resistance can be set. Subtract exisiting insulation #Values from the total resistance to see how low we can go. diff --git a/lib/openstudio-standards/standards/Standards.Construction.rb b/lib/openstudio-standards/standards/Standards.Construction.rb index b5725a7fd2..8aa3374d38 100644 --- a/lib/openstudio-standards/standards/Standards.Construction.rb +++ b/lib/openstudio-standards/standards/Standards.Construction.rb @@ -31,7 +31,7 @@ def construction_set_u_value(construction, target_u_value_ip, insulation_layer_n if insulation_layer_name.nil? && target_u_value_ip == 0.0 # Do nothing if the construction already doesn't have an insulation layer elsif insulation_layer_name.nil? - insulation_layer_name = find_and_set_insulaton_layer(construction).name + insulation_layer_name = find_and_set_insulation_layer(construction).name end # Remove the insulation layer if the specified U-value is zero.