Module: BTAP::Resources::Envelope::Constructions

Defined in:
lib/openstudio-standards/btap/envelope.rb

Overview

This module contains methods dealing with the creation and modification of constructions.

Defined Under Namespace

Classes: ConstructionsTests

Class Method Summary collapse

Class Method Details

.create_construction(model, name, materials, insulationLayer = nil) ⇒ String

This will create construction model

Parameters:

Returns:

Author:



736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# File 'lib/openstudio-standards/btap/envelope.rb', line 736

def self.create_construction(model, name, materials, insulationLayer = nil)
  construction = OpenStudio::Model::Construction.new(model)
  construction.setName(name)
  #check to see if they are all Fenestation or Opaque. Can't mix and match.
  is_fenestration = false
  is_opaque = false
  #check to see if materials are all the same type.
  materials.each do |material|
    is_fenestration = true unless material.to_FenestrationMaterial.empty?
    is_opaque = true unless material.to_OpaqueMaterial.empty?
  end
  raise ("Materials Passed are not valid. Either they are mixed Opaque/Fenestration or invalid materials") if (is_fenestration and is_opaque) or (not is_fenestration and not is_opaque)
  construction.setLayers(materials)
  construction.setInsulation(insulationLayer) unless nil == insulationLayer or is_fenestration
  return construction
end

.create_default_construction(model, rsi) ⇒ Object



843
844
845
# File 'lib/openstudio-standards/btap/envelope.rb', line 843

def self.create_default_construction(model, rsi)

end

.create_default_fenestration(model, rsi) ⇒ Object



847
848
849
# File 'lib/openstudio-standards/btap/envelope.rb', line 847

def self.create_default_fenestration(model, rsi)

end

.customize_fenestration_construction(model, construction, conductance = nil, solarTransmittanceatNormalIncidence = nil, visibleTransmittance = nil, at_temperature_c = 0.0) ⇒ String

This will customize fenestration construction

Parameters:

  • model (OpenStudio::Model::Model)
  • construction (String)
  • conductance (String) (defaults to: nil)

    nil

  • solarTransmittanceatNormalIncidence (Float) (defaults to: nil)

    nil

  • visibleTransmittance (Float) (defaults to: nil)

    nil

  • at_temperature_c (Float) (defaults to: 0.0)

    0.0

Returns:

  • (String)

    create_construction

Author:



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
# File 'lib/openstudio-standards/btap/envelope.rb', line 762

def self.customize_fenestration_construction(
        model,
        construction,
        conductance = nil,
        solarTransmittanceatNormalIncidence = nil,
        visibleTransmittance = nil,
        at_temperature_c = 0.0)
  construction = OpenStudio::Model::getConstructionByName(model, construction.name.to_s).get
  raise ("This is not a fenestration!") unless construction.isFenestration
  #get equivilant values for tsol, tvis, and conductances.
  #TSol in this case is SHGC
  solarTransmittanceatNormalIncidence = self.get_shgc(model, construction) if solarTransmittanceatNormalIncidence == nil
  visibleTransmittance = self.get_tvis(model, construction) if visibleTransmittance == nil
  conductance = self.get_conductance(construction) if conductance == nil
  frontSideSolarReflectanceatNormalIncidence = 1.0 - solarTransmittanceatNormalIncidence
  backSideSolarReflectanceatNormalIncidence = 1.0 - solarTransmittanceatNormalIncidence
  frontSideVisibleReflectanceatNormalIncidence = 0.081000
  backSideVisibleReflectanceatNormalIncidence = 0.081000
  infraredTransmittanceatNormalIncidence = 0.0
  frontSideInfraredHemisphericalEmissivity = 0.84
  backSideInfraredHemisphericalEmissivity = 0.84
  #store part of fenestation in array bins.
  glazing_array = Array.new()
  shading_material_array = Array.new()
  gas_array = Array.new()
  construction.layers.each do |material|
    glazing_array << material unless material.to_Glazing.empty?
    shading_material_array << material unless material.to_ShadingMaterial.empty?
    gas_array << material unless material.to_GasLayer.empty?
  end

  #set value of fictious glazing based on the fenestrations front and back if available
  unless glazing_array.first.to_StandardGlazing.empty?
    frontSideSolarReflectanceatNormalIncidence = glazing_array.first.to_StandardGlazing.get.frontSideSolarReflectanceatNormalIncidence
    frontSideVisibleReflectanceatNormalIncidence = glazing_array.first.to_StandardGlazing.get.frontSideVisibleReflectanceatNormalIncidence
    frontSideInfraredHemisphericalEmissivity = glazing_array.first.to_StandardGlazing.get.frontSideInfraredHemisphericalEmissivity
  end

  unless glazing_array.last.to_StandardGlazing.empty?
    backSideSolarReflectanceatNormalIncidence = glazing_array.last.to_StandardGlazing.get.backSideSolarReflectanceatNormalIncidence
    backSideVisibleReflectanceatNormalIncidence = glazing_array.last.to_StandardGlazing.get.backSideVisibleReflectanceatNormalIncidence
    backSideInfraredHemisphericalEmissivity = glazing_array.last.to_StandardGlazing.get.backSideInfraredHemisphericalEmissivity
  end
  #create fictious glazing.
  #assume a thickness of 0.10m
  thickness = 0.10
  #calculate conductivity
  conductivity = conductance * thickness
  data_name_suffix = "U=#{("%.3f" % conductivity).to_s} SHGC=#{("%.3f" % solarTransmittanceatNormalIncidence).to_s}"
  base_cons_name = construction.name.to_s
  if match = construction.name.to_s.match(/(.*)?:(.*)?/)
    base_cons_name = match.captures[0]
  end
  cons_name = "#{base_cons_name}:" + data_name_suffix
  glazing_name = "SimpleGlazing:" + data_name_suffix
  #Search to prevent the massive duplication that may ensue.
  return model.getConstructionByName(cons_name).get unless model.getConstructionByName(cons_name).empty?

  #fix for Simple glazing
  glazing_name = "SimpleGlazing:" + data_name_suffix
  glazing = nil
  if model.getSimpleGlazingByName(glazing_name).empty?
    glazing_name = "SimpleGlazing:" + data_name_suffix
    glazing = OpenStudio::Model::SimpleGlazing.new(construction.model)
    glazing.setSolarHeatGainCoefficient(solarTransmittanceatNormalIncidence)
    glazing.setUFactor(conductance)
    glazing.setThickness(0.21)
    glazing.setVisibleTransmittance(visibleTransmittance)
    glazing.setName(glazing_name)
  else
    glazing = model.getSimpleGlazingByName(glazing_name).get
  end

  #add the glazing and any shading materials to the array and create construction based on this.
  new_materials_array = Array.new()
  new_materials_array << glazing
  new_materials_array.concat(shading_material_array) unless shading_material_array.empty?
  #puts new_materials_array.size
  return self.create_construction(construction.model, cons_name, new_materials_array)
end

.customize_opaque_construction(model, construction, conductance) ⇒ <String]OpenStudio::Model::getConstructionByName

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 string “default” instead of a numerical value.

Parameters:

Returns:

  • (<String]OpenStudio::Model::getConstructionByName)

    new_construction

Author:



595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# File 'lib/openstudio-standards/btap/envelope.rb', line 595

def self.customize_opaque_construction(model, construction, conductance)
  #Will convert from a string identifier to an object if required.
  construction = BTAP::Common::validate_array(model, construction, "Construction").first
  #If it is Opaque
  raise ("This construction is not opaque :#{construction.name}") unless (construction.isOpaque)
  minimum_resistance = 0
  base_cons_name = construction.name.to_s
  if match = construction.name.to_s.match(/(.*)?:(.*)?/)
    base_cons_name = match.captures[0]
  end
  name_prefix = "#{base_cons_name}:U-#{conductance}"

  #Check to see if we already made one like this.
  existing_construction = OpenStudio::Model::getConstructionByName(construction.model, name_prefix)
  if not existing_construction.empty?
    # if so, return existing construction
    return existing_construction.get
  end

  #create a copy
  new_construction = self.deep_copy(model, construction)

  #Change Construction name in clone
  new_construction.setName(name_prefix)

  if conductance.kind_of?(Float)
    #re-find insulation layer
    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.
    minimum_resistance = (1 / new_construction.thermalConductance.to_f) - (1.0 / new_construction.insulation.get.thermalConductance.to_f)

    #Check if the requested resistance is smaller than the minimum
    # resistance. If so, use the minimum resistance instead.
    if minimum_resistance > (1 / conductance)
      #tell user why we are defaulting and set the conductance of the
      # construction.
      raise ("could not set conductance of construction #{new_construction.name.to_s} to because existing layers make this impossible. Change the construction to allow for this conductance to be set." + (conductance).to_s + "setting to closest value possible value:" + (1.0 / minimum_resistance).to_s)
      # new_construction.setConductance((1.0/minimum_resistance))
    else
      unless new_construction.setConductance(conductance)
        raise("could not set conductance of construction #{new_construction.name.to_s}")
      end
    end
  end
  return new_construction
end

.deep_copy(model, construction) ⇒ String

This will create a deep copy of the construction

Parameters:

Returns:

  • (String)

    new_construction

Author:



716
717
718
719
720
721
722
723
724
725
726
727
# File 'lib/openstudio-standards/btap/envelope.rb', line 716

def self.deep_copy(model, construction)
  construction = BTAP::Common::validate_array(model, construction, "Construction").first
  new_construction = construction.clone.to_Construction.get
  #interating through layers."
  (0..new_construction.layers.length-1).each do |layernumber|
    #cloning material"
    cloned_layer = new_construction.getLayer(layernumber).clone.to_Material.get
    #"setting material to new construction."
    new_construction.setLayer(layernumber, cloned_layer)
  end
  return new_construction
end

.find_and_set_insulaton_layer(model, constructions_array) ⇒ String

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.

Parameters:

Returns:

  • (String)

    insulating_layers

Author:



547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/openstudio-standards/btap/envelope.rb', line 547

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

.get_conductance(construction, at_temperature_c = 0.0) ⇒ Double

this method will get the conductance (metric) of the construction.

Parameters:

  • construction (String)
  • at_temperature_c (Float) (defaults to: 0.0)

    0.0

Returns:

  • (Double)

    1.0

Author:



690
691
692
693
694
695
696
697
698
699
# File 'lib/openstudio-standards/btap/envelope.rb', line 690

def self.get_conductance(construction, at_temperature_c = 0.0)
  #if , by accidnet a construction base was passed...convert it to a construction object.
  construction = OpenStudio::Model::getConstructionByName(construction.model, construction.name.to_s).get unless construction.to_ConstructionBase.empty?
  total = 0.0
  construction.layers.each do |material|

    total = total + 1.0 / BTAP::Resources::Envelope::Materials::get_conductance(material, at_temperature_c)
  end
  return 1.0 / total
end

.get_rsi(construction, at_temperature_c = 0.0) ⇒ Double

this method will get the rsi (metric) of the construction.

Parameters:

  • construction (String)
  • at_temperature_c (Float) (defaults to: 0.0)

    0.0

Returns:

  • (Double)

    1.0 / self.get_conductance(construction, at_temperature_c

Author:



706
707
708
# File 'lib/openstudio-standards/btap/envelope.rb', line 706

def self.get_rsi(construction, at_temperature_c = 0.0)
  return 1.0 / self.get_conductance(construction, at_temperature_c)
end

.get_shgc(model, construction) ⇒ Float

This model gets tsol

Parameters:

Returns:

  • (Float)

    tsol

Author:



649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
# File 'lib/openstudio-standards/btap/envelope.rb', line 649

def self.get_shgc(model, construction)
  construction = BTAP::Common::validate_array(model, construction, "Construction").first
  construction = OpenStudio::Model::getConstructionByName(model, construction.name.to_s).get
  tsol = 1.0
  if construction.isFenestration

    construction.layers.each do |layer|
      #check to see if it is a simple glazing. If so use the SHGC method.
      tsol = tsol * layer.to_SimpleGlazing.get.solarHeatGainCoefficient unless layer.to_SimpleGlazing.empty?
      #check to see if it is a standard glazing. If so use the solar transmittance method.
      tsol = tsol * layer.to_StandardGlazing.get.solarTransmittance unless layer.to_StandardGlazing.empty?
    end
  end
  return tsol
end

.get_tvis(model, construction) ⇒ Float

This model gets tvis

Parameters:

Returns:

  • (Float)

    tvis

Author:



670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/openstudio-standards/btap/envelope.rb', line 670

def self.get_tvis(model, construction)
  construction = BTAP::Common::validate_array(model, construction, "Construction").first
  construction = OpenStudio::Model::getConstructionByName(model, construction.name.to_s).get
  tvis = 1.0
  if construction.isFenestration
    construction.layers.each do |layer|
      #check to see if it is a simple glazing. If so use the SHGC method.
      tvis = tvis * layer.to_SimpleGlazing.get.visibleTransmittance.get unless layer.to_SimpleGlazing.empty?
      #check to see if it is a standard glazing. If so use the solar transmittance method.
      tvis = tvis * layer.to_StandardGlazing.get.visibleTransmittanceatNormalIncidence.get unless layer.to_StandardGlazing.empty?
    end
  end
  return tvis
end