Class: BTAP::EQuest::DOESurface
- Inherits:
-
DOECommand
- Object
- DOECommand
- BTAP::EQuest::DOESurface
- Defined in:
- lib/openstudio-standards/btap/equest.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#construction ⇒ Object
Returns the value of attribute construction.
-
#polygon ⇒ Object
Returns the value of attribute polygon.
Attributes inherited from DOECommand
#building, #children, #commandName, #commandType, #comments, #exempt, #keywordPairs, #non_utype_commands, #one_line_commands, #parents, #utype, #uvalue
Instance Method Summary collapse
-
#convert_to_openstudio(model, runner = nil) ⇒ Object
This method will try to convert a DOE inp file to an openstudio file..
-
#determine_user_defined_construction ⇒ Object
This method finds all the commands within the building that are “Construction” and if the utype matches, it gets the construction.
- #get_3d_polygon ⇒ Object
- #get_azimuth ⇒ Object
- #get_doors ⇒ Object
- #get_origin ⇒ Object
- #get_sub_surface_origin ⇒ Object
- #get_tilt ⇒ Object
- #get_transformation_matrix ⇒ Object
- #get_windows ⇒ Object
-
#initialize ⇒ DOESurface
constructor
A new instance of DOESurface.
Methods inherited from DOECommand
#basic_output, #check_keyword?, #depth, #doe_scope, #get_children, #get_children_of_command, #get_command_from_string, #get_keyword_value, #get_name, #get_parent, #get_parents, #name, #output, #remove, #remove_keyword_pair, #set_keyword_value, #set_parent
Constructor Details
#initialize ⇒ DOESurface
Returns a new instance of DOESurface.
475 476 477 478 |
# File 'lib/openstudio-standards/btap/equest.rb', line 475 def initialize super() @polygon = nil end |
Instance Attribute Details
#construction ⇒ Object
Returns the value of attribute construction.
472 473 474 |
# File 'lib/openstudio-standards/btap/equest.rb', line 472 def construction @construction end |
#polygon ⇒ Object
Returns the value of attribute polygon.
473 474 475 |
# File 'lib/openstudio-standards/btap/equest.rb', line 473 def polygon @polygon end |
Instance Method Details
#convert_to_openstudio(model, runner = nil) ⇒ Object
This method will try to convert a DOE inp file to an openstudio file..
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 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 |
# File 'lib/openstudio-standards/btap/equest.rb', line 815 def convert_to_openstudio(model,runner = nil) #Get 3d polygon of surface and tranform the points based on space origin and the floor origin since they each may use their own co-ordinate base system. total_transform = "" if self.check_keyword?("AZIMUTH") or self.check_keyword?("TILT") total_transform = get_parent("FLOOR").get_transformation_matrix() * get_parent("SPACE").get_transformation_matrix() * get_transformation_matrix() else total_transform = get_parent("FLOOR").get_transformation_matrix() * get_parent("SPACE").get_transformation_matrix() end surface_points = total_transform * self.get_3d_polygon() #Add the surface to the new openstudio model. os_surface = OpenStudio::Model::Surface.new(surface_points, model) #set the name of the surface. os_surface.setName(self.name) case self.commandName #Set the surface boundary condition if it is a ground surface. when "UNDERGROUND-WALL" BTAP::Geometry::Surfaces::set_surfaces_boundary_condition(model,os_surface, "Ground") when "EXTERIOR-WALL","ROOF" #this is needed since the surface constructor defaults to a Ground boundary and Floor Surface type #when a horizontal surface is initialized. if os_surface.outsideBoundaryCondition == "Ground" and os_surface.surfaceType == "Floor" os_surface.setSurfaceType("RoofCeiling") end BTAP::Geometry::Surfaces::set_surfaces_boundary_condition(model,os_surface, "Outdoors") when "INTERIOR-WALL" BTAP::Geometry::Surfaces::set_surfaces_boundary_condition(model,os_surface, "Surface") end #Add to parent space that was already created. os_surface.setSpace(OpenStudio::Model::getSpaceByName( model,get_parent("SPACE").name).get ) #output to console for debugging. BTAP::runner_register("Info", "\tSurface: " + self.name + " created",runner) #check if we need to create a mirror surface in another space. if self.check_keyword?("NEXT-TO") #reverse the points. new_array = surface_points.dup first = new_array.pop new_array.insert(0,first).reverse! #...then add the reverse surface to the model and assign the name with a mirror suffix. os_surface_mirror = OpenStudio::Model::Surface.new(new_array, model) os_surface_mirror.setName(self.name + "-mirror" ) #Assign the mirror surface to the parent space that is NEXT-TO os_surface_mirror.setSpace(OpenStudio::Model::getSpaceByName(model,get_keyword_value("NEXT-TO")).get) #output to console for debugging. BTAP::runner_register("Info", "\tSurface: " + self.name + "-mirror" + " created",runner) end #if statement #Some switches for debugging. convert_sub_surfaces = true convert_sub_surfaces_as_surfaces = false # if convert_sub_surfaces #convert subsurfaces self.get_children().each do |child| #Get height and width of subsurface height = child.get_keyword_value("HEIGHT").to_f width = child.get_keyword_value("WIDTH").to_f #Sum the origin of the surface and the translation of the window x = os_surface.vertices.first().x + ( child.check_keyword?("X")? child.get_keyword_value("X").to_f : 0.0 ) y = os_surface.vertices.first().y + ( child.check_keyword?("Y")? child.get_keyword_value("Y").to_f : 0.0 ) z = os_surface.vertices.first().z #counter clockwise origin = OpenStudio::Point3d.new( x, y , z ) p2 = OpenStudio::Point3d.new(x + width , y, z ) p3 = OpenStudio::Point3d.new(x + width , y + height , z ) p4 = OpenStudio::Point3d.new(x, y + height, z ) polygon = [origin,p2,p3,p4] #get floot and space rotations space_azi = 360.0 - get_parent("SPACE").get_azimuth() floor_azi = 360.0 - get_parent("FLOOR").get_azimuth() tilt_trans = OpenStudio::Transformation::rotation(os_surface.vertices.first(), OpenStudio::Vector3d.new(1.0,0.0,0.0), OpenStudio::degToRad( self.get_tilt )) azi_trans = OpenStudio::Transformation::rotation(os_surface.vertices.first(), OpenStudio::Vector3d.new(0.0,0.0,1.0), OpenStudio::degToRad( 360.0 - self.get_azimuth + space_azi + floor_azi )) surface_points = azi_trans * tilt_trans * polygon if convert_sub_surfaces_as_surfaces #Debug subsurface os_sub_surface = OpenStudio::Model::Surface.new(surface_points, model) #set the name of the surface. os_sub_surface.setName(child.name) #Add to parent space that was already created. os_sub_surface.setSpace(OpenStudio::Model::getSpaceByName( model,self.get_parent("SPACE").name).get ) else #Add the subsurface to the new openstudio model. os_sub_surface = OpenStudio::Model::SubSurface.new(surface_points, model) #set the name of the surface. os_sub_surface.setName(child.name) #Add to parent space that was already created. os_sub_surface.setSurface(os_surface) #output to console for debugging. BTAP::runner_register("Info", "\tSubSurface: " + child.name + " created",runner) case child.commandName when "WINDOW" #By default it is a window. when "DOOR" os_sub_surface.setSubSurfaceType( "Door" ) end #end case. # Add overhang for subsurface if required. Note this only supports overhangs of width the same as the window. if child.check_keyword?("OVERHANG-D") == true offset = 0.0 offset = child.get_keyword_value("OVERHANG-O").to_f if child.check_keyword?("OVERHANG-O") depth = 0.0 depth = child.get_keyword_value("OVERHANG-D").to_f os_sub_surface.addOverhang( depth , offset ) end end end end end |
#determine_user_defined_construction ⇒ Object
This method finds all the commands within the building that are “Construction” and if the utype matches, it gets the construction
804 805 806 807 808 809 810 811 812 |
# File 'lib/openstudio-standards/btap/equest.rb', line 804 def determine_user_defined_construction() constructions = @building.find_all_commands("CONSTRUCTION") constructions.each do |construction| if ( construction.utype == get_keyword_value("CONSTRUCTION") ) @construction = construction end end return @construction end |
#get_3d_polygon ⇒ Object
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 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 |
# File 'lib/openstudio-standards/btap/equest.rb', line 643 def get_3d_polygon() array = Array.new() origin = "" floor = get_parent("FLOOR") space = get_parent("SPACE") case space.get_keyword_value("ZONE-TYPE") when "PLENUM" height = floor.get_keyword_value("FLOOR-HEIGHT").to_f - floor.get_keyword_value("SPACE-HEIGHT").to_f when "CONDITIONED","UNCONDITIONED" height = space.check_keyword?("HEIGHT") ? space.get_keyword_value("HEIGHT").to_f : floor.get_keyword_value("SPACE-HEIGHT").to_f end #if the surface has been given a polygon. Then use it. if check_keyword?("POLYGON") # puts "Polygon Surface Detected...Doing a local transform.." # # puts "Point List" # puts self.polygon.point_list # puts "Origin" # puts self.get_origin # puts "azimuth" # puts self.get_azimuth # puts "tilt" # puts self.get_tilt #all other methods below create points relative to the space. This method however, need to be transformed. array = self.polygon.point_list #if surfaces are defined by shape of space. else case space.get_shape when "BOX" BTAP::runner_register("Info", "Box Space Detected....",runner) #get height, width and depth of box. height = space.check_keyword?("HEIGHT").to_f ? space.check_keyword?("HEIGHT") : height width = space.get_keyword_value("WIDTH").to_f depth = space.get_keyword_value("DEPTH").to_f case get_keyword_value("LOCATION") when "TOP" #puts "Top of Box...." #counter clockwise origin = OpenStudio::Point3d.new(0.0,0.0,height) p2 = OpenStudio::Point3d.new(width,0.0,height) p3 = OpenStudio::Point3d.new(width,depth,height) p4 = OpenStudio::Point3d.new(0.0,depth,height) array = [origin,p2,p3,p4] when "BOTTOM" #puts "Bottom of Box...." #counter clockwise origin = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 ) p2 = OpenStudio::Point3d.new( 0.0, depth, 0.0) p3 = OpenStudio::Point3d.new( width, depth, 0.0) p4 = OpenStudio::Point3d.new( width,0.0 ,0.0 ) array = [origin,p2,p3,p4] when "FRONT" #puts "Front of Box...." #counter clockwise origin = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 ) p2 = OpenStudio::Point3d.new( width,0.0 ,0.0 ) p3 = OpenStudio::Point3d.new( width, 0.0, height) p4 = OpenStudio::Point3d.new( 0.0, 0.0, height) array = [origin,p2,p3,p4] when "RIGHT" #puts "Right of Box...." #counter clockwise origin = OpenStudio::Point3d.new(width, 0.0, 0.0) p2 = OpenStudio::Point3d.new(width,depth, 0.0) p3 = OpenStudio::Point3d.new(width,depth,height) p4 = OpenStudio::Point3d.new(width,0.0,height) array = [origin,p2,p3,p4] when "BACK" #puts "Back of Box...." #counter clockwise origin = OpenStudio::Point3d.new(width,depth,0.0) p2 = OpenStudio::Point3d.new(0.0,depth,0.0) p3 = OpenStudio::Point3d.new(0.0,depth,height) p4 = OpenStudio::Point3d.new(width,depth,height) array = [origin,p2,p3,p4] when "LEFT" #puts "Left of Box...." #counter clockwise origin = OpenStudio::Point3d.new(0.0,depth,0.0) p2 = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 ) p3 = OpenStudio::Point3d.new(0.0, 0.0,height) p4 = OpenStudio::Point3d.new(0.0,depth,height) array = [origin,p2,p3,p4] end when "POLYGON" #puts "Polygon Space definition detected..." if check_keyword?("LOCATION") #puts "LOCATION surface definition detected..." case get_keyword_value("LOCATION") when "BOTTOM" #puts "BOTTOM surface definition detected..." #reverse array array = space.polygon.point_list.dup first = array.pop array.insert(0,first).reverse! when "TOP" #puts "TOP surface definition detected..." #need to move floor polygon up to space height for top. Using Transformation.translation matrix for this. array = OpenStudio::createTranslation(OpenStudio::Vector3d.new(0.0,0.0, height )) * space.polygon.point_list when /SPACE-\s*V\s*(.*)/ #puts "SPACE-V#{$1} surface definition detected..." index = $1.strip.to_i - 1 point0 = space.polygon.point_list[index] point1 = space.polygon.point_list[index + 1] ? space.polygon.point_list[index + 1] : space.polygon.point_list[0] #counter clockwise origin = OpenStudio::Point3d.new( point0.x, point0.y, 0.0) p2 = OpenStudio::Point3d.new( point1.x, point1.y, 0.0) p3 = OpenStudio::Point3d.new( point1.x, point1.y, height ) p4 = OpenStudio::Point3d.new( point0.x, point0.y, height ) array = [origin,p2,p3,p4] end else #puts "CATCH-ALL for surface definition.." #nasty. The height is NOT defined if the height is the same as the space height...so gotta get it from it's parent space. space_height = space.check_keyword?("HEIGHT") ? space.get_keyword_value("HEIGHT").to_f : floor.get_keyword_value("SPACE-HEIGHT").to_f height = self.check_keyword?("HEIGHT") ? self.get_keyword_value("HEIGHT").to_f : space_height width = self.get_keyword_value("WIDTH").to_f #counter clockwise origin = OpenStudio::Point3d.new(width,0.0,0.0) p2 = OpenStudio::Point3d.new( 0.0,0.0,0.0 ) p3 = OpenStudio::Point3d.new(0.0,0.0,height) p4 = OpenStudio::Point3d.new(width,0.0,height) array = [p4, p3, p2, origin] end when "NO-SHAPE" raise("Using SHAPE = NO-SHAPE deifnition for space is not supported...yet") end end # if self.check_keyword?("AZIMUTH") or self.check_keyword?("TILT") # puts "Did a transform" # return get_transformation_matrix * array # else # return array # end return array end |
#get_azimuth ⇒ Object
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/openstudio-standards/btap/equest.rb', line 480 def get_azimuth() #puts OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 0.0, 0.0), OpenStudio::Vector3d.new(1.0, 0.0, 0.0) ) ) if check_keyword?("LOCATION") case get_keyword_value("LOCATION") when /SPACE-\s*V\s*(.*)/ index = $1.strip.to_i - 1 point0 = self.get_parent("SPACE").polygon.point_list[index] point1 = self.get_parent("SPACE").polygon.point_list[index + 1] ? get_parent("SPACE").polygon.point_list[index + 1] : get_parent("SPACE").polygon.point_list[0] edge = point1-point0 sign = OpenStudio::Vector3d.new(1.0, 0.0, 0.0).dot(( edge )) > 0 ? 1 :-1 angle = OpenStudio::radToDeg( sign * OpenStudio::getAngle(OpenStudio::Vector3d.new(1.0, 0.0, 0.0), ( point1 - point0 ) ) ) #since get angle only get acute angles we need to get sign and completment for reflex angle angle = angle + 180 if edge.y < 0 return angle when "FRONT" return OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("SPACE").polygon.point_list[1] - get_parent("SPACE").polygon.point_list[0] ) ) ) when "RIGHT" return OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("SPACE").polygon.point_list[2] - get_parent("SPACE").polygon.point_list[1] ) ) ) when "BACK" return OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("SPACE").polygon.point_list[3] - get_parent("SPACE").polygon.point_list[2] ) ) ) when "LEFT" return OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 1.0, 0.0), ( get_parent("SPACE").polygon.point_list[0] - get_parent("SPACE").polygon.point_list[3] ) ) ) end end return self.check_keyword?("AZIMUTH")? self.get_keyword_value("AZIMUTH").to_f : 0.0 end |
#get_doors ⇒ Object
796 797 798 |
# File 'lib/openstudio-standards/btap/equest.rb', line 796 def get_doors() return self.get_children_of_command("DOOR") end |
#get_origin ⇒ Object
527 528 529 530 531 532 |
# File 'lib/openstudio-standards/btap/equest.rb', line 527 def get_origin() space_xref = self.check_keyword?("X")? self.get_keyword_value("X").to_f : 0.0 space_yref = self.check_keyword?("Y")? self.get_keyword_value("Y").to_f : 0.0 space_zref = self.check_keyword?("Z")? self.get_keyword_value("Z").to_f : 0.0 return OpenStudio::Vector3d.new(space_xref,space_yref,space_zref) end |
#get_sub_surface_origin ⇒ Object
534 535 536 537 538 539 540 541 542 543 544 545 546 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 585 586 587 588 589 590 591 592 593 594 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 |
# File 'lib/openstudio-standards/btap/equest.rb', line 534 def get_sub_surface_origin() height = "" BTAP::runner_register("Info", "geting origin",runner) origin = "" if self.check_keyword?("X") and self.check_keyword?("Y") and self.check_keyword?("Z") BTAP::runner_register("Info", "XYZ definition",runner) space_xref = self.get_keyword_value("X").to_f space_yref = self.get_keyword_value("Y").to_f space_zref = self.get_keyword_value("Z").to_f return OpenStudio::Vector3d.new(space_xref,space_yref,space_zref) end BTAP::runner_register("Info", get_name(),runner) array = Array.new() origin = "" floor = get_parent("FLOOR") space = get_parent("SPACE") case space.get_keyword_value("ZONE-TYPE") when "PLENUM" height = floor.get_keyword_value("FLOOR-HEIGHT").to_f - floor.get_keyword_value("SPACE-HEIGHT").to_f when "CONDITIONED","UNCONDITIONED" height = space.check_keyword?("HEIGHT") ? space.get_keyword_value("HEIGHT").to_f : floor.get_keyword_value("SPACE-HEIGHT").to_f end BTAP::runner_register("Info", "Space is #{space.get_shape}",runner) case space.get_shape when "BOX" BTAP::runner_register("Info", "Box Space Detected....",runner) #get height, width and depth of box. height = space.check_keyword?("HEIGHT").to_f ? space.check_keyword?("HEIGHT") : height width = space.get_keyword_value("WIDTH").to_f depth = space.get_keyword_value("DEPTH").to_f case get_keyword_value("LOCATION") when "TOP" BTAP::runner_register("Info", "Top of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new(0.0,0.0,height) when "BOTTOM" BTAP::runner_register("Info", "Bottom of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 ) when "FRONT" BTAP::runner_register("Info", "Front of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new( 0.0, 0.0, 0.0 ) when "RIGHT" BTAP::runner_register("Info", "Right of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new(width, 0.0, 0.0) when "BACK" BTAP::runner_register("Info", "Back of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new(width,depth,0.0) when "LEFT" BTAP::runner_register("Info", "Left of Box....",runner) #counter clockwise origin = OpenStudio::Point3d.new(0.0,depth,0.0) end when "POLYGON" #puts "Polygon Space definition detected..." if check_keyword?("LOCATION") #puts "LOCATION surface definition detected..." case get_keyword_value("LOCATION") when "BOTTOM" origin = OpenStudio::Vector3d.new(0.0,0.0, 0.0 ) when "TOP" #puts "TOP surface definition detected..." #need to move floor polygon up to space height for top. Using Transformation.translation matrix for this. origin = OpenStudio::Vector3d.new(0.0,0.0, height ) #to-do!!!!!!!!!!! when /SPACE-\s*V\s*(.*)/ #puts "SPACE-V#{$1} surface definition detected..." index = $1.strip.to_i - 1 point0 = space.polygon.point_list[index] #counter clockwise origin = OpenStudio::Point3d.new( point0.x, point0.y, 0.0) end else #puts "CATCH-ALL for surface definition.." #nasty. The height is NOT defined if the height is the same as the space height...so gotta get it from it's parent space. space_height = space.check_keyword?("HEIGHT") ? space.get_keyword_value("HEIGHT").to_f : floor.get_keyword_value("SPACE-HEIGHT").to_f height = self.check_keyword?("HEIGHT") ? self.get_keyword_value("HEIGHT").to_f : space_height width = self.get_keyword_value("WIDTH").to_f #origin origin = OpenStudio::Point3d.new(width,0.0,0.0) end when "NO-SHAPE" raise("Using SHAPE = NO-SHAPE deifnition for space is not supported by open Studio") end origin = OpenStudio::Vector3d.new(origin.x,origin.y,origin.z) #puts "Surface origin vector is #{origin}" return origin end |
#get_tilt ⇒ Object
509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
# File 'lib/openstudio-standards/btap/equest.rb', line 509 def get_tilt() #puts OpenStudio::radToDeg( OpenStudio::getAngle(OpenStudio::Vector3d.new(0.0, 0.0, 0.0), OpenStudio::Vector3d.new(1.0, 0.0, 0.0) ) ) if check_keyword?("LOCATION") case get_keyword_value("LOCATION") when "FRONT","BACK","LEFT","RIGHT",/SPACE-\s*V\s*(.*)/ return 90.0 when "TOP" return 0.0 when "BOTTOM" return 180.0 end end return self.check_keyword?("TILT")? self.get_keyword_value("TILT").to_f : 0.0 end |
#get_transformation_matrix ⇒ Object
635 636 637 638 639 640 641 |
# File 'lib/openstudio-standards/btap/equest.rb', line 635 def get_transformation_matrix #Rotate points around z (azimuth) and x (Tilt) translation = OpenStudio::createTranslation(self.get_origin) e_a = OpenStudio::EulerAngles.new( OpenStudio::degToRad( self.get_tilt ), 0.0, OpenStudio::degToRad( 180.0 - self.get_azimuth ) ) rotations = OpenStudio::Transformation::rotation(e_a) return translation * rotations end |
#get_windows ⇒ Object
792 793 794 |
# File 'lib/openstudio-standards/btap/equest.rb', line 792 def get_windows() return self.get_children_of_command("WINDOW") end |