Example #1
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew("test.idf")
        idf.newidfobject("VERSION")  # does not have a field "Name"

        # construction material
        construction = idf.newidfobject("CONSTRUCTION", Name="construction")
        construction.Outside_Layer = "TestMaterial"

        expected = idf.newidfobject("MATERIAL", Name="TestMaterial")

        fetched = idf.getobject("MATERIAL", "TestMaterial")
        assert fetched == expected

        material = construction.get_referenced_object("Outside_Layer")
        assert material == expected

        # window material
        glazing_group = idf.newidfobject(
            "WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC", Name="glazing_group"
        )
        glazing_group.Window_Material_Glazing_Name_1 = "TestWindowMaterial"

        expected = idf.newidfobject(
            "WINDOWMATERIAL:GLAZING", Name="TestWindowMaterial"
        )  # has several \references

        fetched = idf.getobject("WINDOWMATERIAL:GLAZING", "TestWindowMaterial")
        assert fetched == expected

        material = glazing_group.get_referenced_object("Window_Material_Glazing_Name_1")
        assert material == expected
Example #2
0
def test_initread():
    """Test for IDF.initread() with filename in unicode and as python str.
    """
    # setup
    idf = IDF()
    idf.initreadtxt(idfsnippet)
    idf.saveas('tmp.idf')

    # test fname as unicode
    fname = 'tmp.idf'
    assert isinstance(fname, string_types)
    idf = IDF()
    idf.initread(fname)
    assert idf.getobject('BUILDING', 'Building')

    # test fname as str
    fname = str('tmp.idf')
    assert isinstance(fname, string_types)
    idf = IDF()
    idf.initread(fname)
    assert idf.getobject('BUILDING', 'Building')

    # test that a nonexistent file raises an IOError
    fname = "notarealfilename.notreal"
    idf = IDF()
    try:
        idf.initread(fname)
        assert False  # shouldn't reach here
    except IOError:
        pass

    # teardown
    os.remove('tmp.idf')
Example #3
0
def test_initread():
    """Test for IDF.initread() with filename in unicode and as python str."""
    # setup
    idf = IDF()
    idf.initreadtxt(idfsnippet)
    idf.saveas("tmp.idf")

    # test fname as unicode
    fname = "tmp.idf"
    assert isinstance(fname, string_types)
    idf = IDF()
    idf.initread(fname)
    assert idf.getobject("BUILDING", "Building")

    # test fname as str
    fname = str("tmp.idf")
    assert isinstance(fname, string_types)
    idf = IDF()
    idf.initread(fname)
    assert idf.getobject("BUILDING", "Building")

    # test that a nonexistent file raises an IOError
    fname = "notarealfilename.notreal"
    idf = IDF()
    try:
        idf.initread(fname)
        assert False  # shouldn't reach here
    except IOError:
        pass

    # teardown
    os.remove("tmp.idf")
Example #4
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew('test.idf')
        idf.newidfobject('VERSION')  # does not have a field "Name"

        # construction material
        construction = idf.newidfobject('CONSTRUCTION', Name='construction')
        construction.Outside_Layer = 'TestMaterial'

        expected = idf.newidfobject('MATERIAL', Name='TestMaterial')

        fetched = idf.getobject('MATERIAL', 'TestMaterial')
        assert fetched == expected

        material = construction.get_referenced_object('Outside_Layer')
        assert material == expected

        # window material
        glazing_group = idf.newidfobject(
            'WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC', Name='glazing_group')
        glazing_group.Window_Material_Glazing_Name_1 = 'TestWindowMaterial'

        expected = idf.newidfobject(
            'WINDOWMATERIAL:GLAZING', Name='TestWindowMaterial')  # has several \references

        fetched = idf.getobject('WINDOWMATERIAL:GLAZING', 'TestWindowMaterial')
        assert fetched == expected

        material = glazing_group.get_referenced_object(
            'Window_Material_Glazing_Name_1')
        assert material == expected
Example #5
0
    def test_get_referenced_object(self):
        """py.test for get_referenced_object"""
        idf = IDF()
        idf.initnew('test.idf')
        idf.newidfobject('VERSION') # does not have a field "Name"

        # construction material        
        construction = idf.newidfobject('CONSTRUCTION', 'construction')
        construction.Outside_Layer = 'TestMaterial'
        
        expected = idf.newidfobject('MATERIAL', 'TestMaterial')
        
        fetched = idf.getobject('MATERIAL', 'TestMaterial')
        assert fetched == expected
    
        material = construction.get_referenced_object('Outside_Layer')
        assert material == expected
        
        # window material
        glazing_group = idf.newidfobject(
            'WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC', 'glazing_group')
        glazing_group.Window_Material_Glazing_Name_1 = 'TestWindowMaterial'

        expected = idf.newidfobject(
            'WINDOWMATERIAL:GLAZING', 'TestWindowMaterial') # has several \references
        
        fetched = idf.getobject('WINDOWMATERIAL:GLAZING', 'TestWindowMaterial')
        assert fetched == expected
        
        material = glazing_group.get_referenced_object(
            'Window_Material_Glazing_Name_1')
        assert material == expected
Example #6
0
def test_zonearea_zonevolume():
    """py.test for zonearea and zonevolume"""
    idftxt = "Zone, 473222, 0.0, 0.0, 0.0, 0.0, , 1;  BuildingSurface:Detailed, F7289B, Floor, Exterior Floor, 473222, Ground, , NoSun, NoWind, , 4, 2.23, 2.56, 0.0, 2.23, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.56, 0.0;  BuildingSurface:Detailed, F3659B, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.56, 1.49, 2.23, 2.56, 0.0, 0.0, 2.56, 0.0, 0.0, 2.56, 1.49;  BuildingSurface:Detailed, 46C6C9, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 0.0, 1.49, 2.23, 0.0, 0.0, 2.23, 1.02548139464, 0.0, 2.23, 1.02548139464, 1.49;  BuildingSurface:Detailed, 4287DD, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 2.56, 1.49, 0.0, 2.56, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.49;  BuildingSurface:Detailed, 570C2E, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 0.0, 1.49, 0.0, 0.0, 0.0, 2.23, 0.0, 0.0, 2.23, 0.0, 1.49;  BuildingSurface:Detailed, BAEA99, Roof, Exterior Roof, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 2.56, 1.49, 0.0, 0.0, 1.49, 2.23, 0.0, 1.49, 2.23, 2.56, 1.49;  BuildingSurface:Detailed, C879FE, Floor, Exterior Floor, 473222, Ground, , NoSun, NoWind, , 4, 3.22, 2.52548139464, 0.0, 3.22, 1.02548139464, 0.0, 2.23, 1.02548139464, 0.0, 2.23, 2.52548139464, 0.0;  BuildingSurface:Detailed, 25B601, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 2.23, 2.52548139464, 0.0, 2.23, 2.52548139464, 1.49;  BuildingSurface:Detailed, F5EADC, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 3.22, 1.02548139464, 0.0, 3.22, 1.02548139464, 1.49;  BuildingSurface:Detailed, D0AABE, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 3.22, 1.02548139464, 1.49, 3.22, 1.02548139464, 0.0, 3.22, 2.52548139464, 0.0, 3.22, 2.52548139464, 1.49;  BuildingSurface:Detailed, B0EA02, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 3.22, 2.52548139464, 1.49, 3.22, 2.52548139464, 0.0, 2.23, 2.52548139464, 0.0, 2.23, 2.52548139464, 1.49;  BuildingSurface:Detailed, E6DF3B, Roof, Exterior Roof, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.52548139464, 1.49, 2.23, 1.02548139464, 1.49, 3.22, 1.02548139464, 1.49, 3.22, 2.52548139464, 1.49;  BuildingSurface:Detailed, 4F8681, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.52548139464, 1.49, 2.23, 2.52548139464, 0.0, 2.23, 2.56, 0.0, 2.23, 2.56, 1.49;  "
    idf = IDF(StringIO(idftxt))
    result = modeleditor.zonearea(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea_floor(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea_roofceiling(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zone_floor2roofheight(idf, '473222')
    assert almostequal(result, 1.49)
    result = modeleditor.zoneheight(idf, '473222')
    assert almostequal(result, 1.49)
    result = modeleditor.zone_floor2roofheight(idf, '473222')
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, '473222')
    assert almostequal(result, 10.718762)
    # remove floor
    zone = idf.getobject('ZONE', '473222')
    surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()]
    zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
    floors = [s for s in zone_surfs if s.Surface_Type.upper() == 'FLOOR']
    for floor in floors:
        idf.removeidfobject(floor)
    result = modeleditor.zonearea_floor(idf, '473222')
    assert almostequal(result, 0)
    result = modeleditor.zonearea_roofceiling(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zoneheight(idf, '473222')
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, '473222')
    assert almostequal(result, 10.718762)
    # reload idf and remove roof/ceiling
    idf = IDF(StringIO(idftxt))
    zone = idf.getobject('ZONE', '473222')
    surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()]
    zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
    roofs = [s for s in zone_surfs if s.Surface_Type.upper() == 'ROOF']
    ceilings = [s for s in zone_surfs if s.Surface_Type.upper() == 'CEILING']
    topsurfaces = roofs + ceilings
    for surf in topsurfaces:
        idf.removeidfobject(surf)
    result = modeleditor.zonearea_roofceiling(idf, '473222')
    assert almostequal(result, 0)
    result = modeleditor.zonearea(idf, '473222')
    assert almostequal(result, 7.1938)
    result = modeleditor.zoneheight(idf, '473222')
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, '473222')
    assert almostequal(result, 10.718762)
        
Example #7
0
def test_makepipebranch():
    """py.test for makepipebranch"""
    tdata = (
        (
            "p_branch",
            [
                "BRANCH",
                "p_branch",
                "0",
                "",
                "Pipe:Adiabatic",
                "p_branch_pipe",
                "p_branch_pipe_inlet",
                "p_branch_pipe_outlet",
                "Bypass",
            ],
            ["PIPE:ADIABATIC", "p_branch_pipe", "p_branch_pipe_inlet", "p_branch_pipe_outlet"],
        ),  # pb_name, branch_obj, pipe_obj
    )
    for pb_name, branch_obj, pipe_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makepipebranch(idf, pb_name)
        assert result.obj == branch_obj
        thepipe = idf.getobject("PIPE:ADIABATIC", result.Component_1_Name)
        assert thepipe.obj == pipe_obj
Example #8
0
def test_makepipebranch():
    """py.test for makepipebranch"""
    tdata = ((
        "p_branch",
        ['BRANCH',
         'p_branch',
         '0',
         '',
         'Pipe:Adiabatic',
         'p_branch_pipe',
         'p_branch_pipe_inlet',
         'p_branch_pipe_outlet',
         'Bypass'],
        [
            'PIPE:ADIABATIC',
            'p_branch_pipe',
            'p_branch_pipe_inlet',
            'p_branch_pipe_outlet']
        ), # pb_name, branch_obj, pipe_obj
            )
    for pb_name, branch_obj, pipe_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makepipebranch(idf, pb_name)
        assert result.obj == branch_obj
        thepipe = idf.getobject('PIPE:ADIABATIC', result.Component_1_Name)
        assert thepipe.obj == pipe_obj
Example #9
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        (
            "p_loop", ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'],
            ['db0', ['db1', 'db2', 'db3'], 'db4'],
            'sb0',
            [
                ("Chiller:Electric".upper(), 'Central_Chiller',
                 'Chilled_Water_'),
                ("PIPE:ADIABATIC", 'np1', None),
                ("PIPE:ADIABATIC", 'np2', None)
            ],
            'Water',
            [
                'BRANCH', 'sb0', '0', '', 'CHILLER:ELECTRIC', 'Central_Chiller',
                'p_loop Supply Inlet', 'Central_Chiller_np1_node', '',
                'PIPE:ADIABATIC',
                'np1', 'Central_Chiller_np1_node', 'np1_np2_node', '',
                'PIPE:ADIABATIC',
                'np2', 'np1_np2_node', 'np2_Outlet_Node_Name', ''
            ]
        ), # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname,
         componenttuple, fluid, outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode)
                                for key, nm, thisnode in componenttuple]
        branch = idf.getobject('BRANCH', branchname)
        newbr = hvacbuilder.replacebranch(idf, loop, branch,
                                          components_thisnodes, fluid=fluid)
        assert newbr.obj == outbranch
Example #10
0
def test_makeductbranch():
    """py.test for makeductbranch"""
    tdata = ((
        'd_branch',
        [
            'BRANCH',
            'd_branch',
            0.0,
            '',
            'duct',
            'd_branch_duct',
            'd_branch_duct_inlet',
            'd_branch_duct_outlet',
            'Bypass'],
        [
            'DUCT',
            'd_branch_duct',
            'd_branch_duct_inlet',
            'd_branch_duct_outlet']),  # db_name, branch_obj, duct_obj
            )
    for db_name, branch_obj, duct_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makeductbranch(idf, db_name)
        assert result.obj == branch_obj
        theduct = idf.getobject('DUCT', result.Component_1_Name)
        assert theduct.obj == duct_obj
Example #11
0
def test_makeductbranch():
    """py.test for makeductbranch"""
    tdata = (
        (
            "d_branch",
            [
                "BRANCH",
                "d_branch",
                0.0,
                "",
                "duct",
                "d_branch_duct",
                "d_branch_duct_inlet",
                "d_branch_duct_outlet",
                "Bypass",
            ],
            [
                "DUCT", "d_branch_duct", "d_branch_duct_inlet",
                "d_branch_duct_outlet"
            ],
        ),  # db_name, branch_obj, duct_obj
    )
    for db_name, branch_obj, duct_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makeductbranch(idf, db_name)
        assert result.obj == branch_obj
        theduct = idf.getobject("DUCT", result.Component_1_Name)
        assert theduct.obj == duct_obj
Example #12
0
def test_makepipebranch():
    """py.test for makepipebranch"""
    tdata = (
        (
            "p_branch",
            [
                "BRANCH",
                "p_branch",
                0.0,
                "",
                "Pipe:Adiabatic",
                "p_branch_pipe",
                "p_branch_pipe_inlet",
                "p_branch_pipe_outlet",
                "Bypass",
            ],
            [
                "PIPE:ADIABATIC",
                "p_branch_pipe",
                "p_branch_pipe_inlet",
                "p_branch_pipe_outlet",
            ],
        ),  # pb_name, branch_obj, pipe_obj
    )
    for pb_name, branch_obj, pipe_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makepipebranch(idf, pb_name)
        assert result.obj == branch_obj
        thepipe = idf.getobject("PIPE:ADIABATIC", result.Component_1_Name)
        assert thepipe.obj == pipe_obj
Example #13
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        ("p_loop", ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'], [
            'db0', ['db1', 'db2', 'db3'], 'db4'
        ], 'sb0', [
            ("Chiller:Electric".upper(), 'Central_Chiller', 'Chilled_Water_'),
            ("PIPE:ADIABATIC", 'np1', None), ("PIPE:ADIABATIC", 'np2', None)
        ], 'Water', [
            'BRANCH',
            'sb0', '0',
            '', 'CHILLER:ELECTRIC',
            'Central_Chiller', 'p_loop Supply Inlet',
            'Central_Chiller_np1_node', '', 'PIPE:ADIABATIC', 'np1',
            'Central_Chiller_np1_node', 'np1_np2_node', '', 'PIPE:ADIABATIC',
            'np2', 'np1_np2_node', 'np2_Outlet_Node_Name', ''
        ]),  # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname, componenttuple, fluid,
         outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode)
                                for key, nm, thisnode in componenttuple]
        branch = idf.getobject('BRANCH', branchname)
        newbr = hvacbuilder.replacebranch(idf,
                                          loop,
                                          branch,
                                          components_thisnodes,
                                          fluid=fluid)
        assert newbr.obj == outbranch
Example #14
0
def test_makeductbranch():
    """py.test for makeductbranch"""
    tdata = (
        (
            "d_branch",
            [
                "BRANCH",
                "d_branch",
                "0",
                "",
                "duct",
                "d_branch_duct",
                "d_branch_duct_inlet",
                "d_branch_duct_outlet",
                "Bypass",
            ],
            ["DUCT", "d_branch_duct", "d_branch_duct_inlet", "d_branch_duct_outlet"],
        ),  # db_name, branch_obj, duct_obj
    )
    for db_name, branch_obj, duct_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makeductbranch(idf, db_name)
        assert result.obj == branch_obj
        theduct = idf.getobject("DUCT", result.Component_1_Name)
        assert theduct.obj == duct_obj
Example #15
0
def test_makepipebranch():
    """py.test for makepipebranch"""
    tdata = ((
        "p_branch",
        ['BRANCH',
         'p_branch',
         0.0,
         '',
         'Pipe:Adiabatic',
         'p_branch_pipe',
         'p_branch_pipe_inlet',
         'p_branch_pipe_outlet',
         'Bypass'],
        [
            'PIPE:ADIABATIC',
            'p_branch_pipe',
            'p_branch_pipe_inlet',
            'p_branch_pipe_outlet']
        ),  # pb_name, branch_obj, pipe_obj
            )
    for pb_name, branch_obj, pipe_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makepipebranch(idf, pb_name)
        assert result.obj == branch_obj
        thepipe = idf.getobject('PIPE:ADIABATIC', result.Component_1_Name)
        assert thepipe.obj == pipe_obj
Example #16
0
def test_makeductbranch():
    """py.test for makeductbranch"""
    tdata = ((
        'd_branch',
        [
            'BRANCH',
            'd_branch',
            '0',
            '',
            'duct',
            'd_branch_duct',
            'd_branch_duct_inlet',
            'd_branch_duct_outlet',
            'Bypass'],
        [
            'DUCT',
            'd_branch_duct',
            'd_branch_duct_inlet',
            'd_branch_duct_outlet']), # db_name, branch_obj, duct_obj
            )
    for db_name, branch_obj, duct_obj in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        result = hvacbuilder.makeductbranch(idf, db_name)
        assert result.obj == branch_obj
        theduct = idf.getobject('DUCT', result.Component_1_Name)
        assert theduct.obj == duct_obj
Example #17
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        (
            "p_loop",
            ["sb0", ["sb1", "sb2", "sb3"], "sb4"],
            ["db0", ["db1", "db2", "db3"], "db4"],
            "sb0",
            [
                ("Chiller:Electric", "Central_Chiller", "Chilled_Water_"),
                ("PIPE:ADIABATIC", "np1", None),
                ("PIPE:ADIABATIC", "np2", None),
            ],
            "Water",
            [
                "BRANCH",
                "sb0",
                0.0,
                "",
                "CHILLER:ELECTRIC",
                "Central_Chiller",
                "p_loop Supply Inlet",
                "Central_Chiller_np1_node",
                "",
                "PIPE:ADIABATIC",
                "np1",
                "Central_Chiller_np1_node",
                "np1_np2_node",
                "",
                "PIPE:ADIABATIC",
                "np2",
                "np1_np2_node",
                "np2_Outlet_Node_Name",
                "",
            ],
        ),  # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname, componenttuple, fluid,
         outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, Name=nm), thisnode)
                                for key, nm, thisnode in componenttuple]
        branch = idf.getobject("BRANCH", branchname)
        newbr = hvacbuilder.replacebranch(idf,
                                          loop,
                                          branch,
                                          components_thisnodes,
                                          fluid=fluid)
        assert newbr.obj == outbranch
Example #18
0
def test_replacebranch():
    """py.test for replacebranch"""
    tdata = (
        (
            "p_loop",
            ["sb0", ["sb1", "sb2", "sb3"], "sb4"],
            ["db0", ["db1", "db2", "db3"], "db4"],
            "sb0",
            [
                ("Chiller:Electric".upper(), "Central_Chiller", "Chilled_Water_"),
                ("PIPE:ADIABATIC", "np1", None),
                ("PIPE:ADIABATIC", "np2", None),
            ],
            "Water",
            [
                "BRANCH",
                "sb0",
                "0",
                "",
                "CHILLER:ELECTRIC",
                "Central_Chiller",
                "p_loop Supply Inlet",
                "Central_Chiller_np1_node",
                "",
                "PIPE:ADIABATIC",
                "np1",
                "Central_Chiller_np1_node",
                "np1_np2_node",
                "",
                "PIPE:ADIABATIC",
                "np2",
                "np1_np2_node",
                "np2_Outlet_Node_Name",
                "",
            ],
        ),  # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
    )
    for (loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch) in tdata:
        fhandle = StringIO("")
        idf = IDF(fhandle)
        loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
        components_thisnodes = [(idf.newidfobject(key, nm), thisnode) for key, nm, thisnode in componenttuple]
        branch = idf.getobject("BRANCH", branchname)
        newbr = hvacbuilder.replacebranch(idf, loop, branch, components_thisnodes, fluid=fluid)
        assert newbr.obj == outbranch
Example #19
0
def test_initreadtxt():
    """Test for IDF.initreadtxt()."""
    idftxt = """
        Material,
          G01a 19mm gypsum board,  !- Name
          MediumSmooth,            !- Roughness
          0.019,                   !- Thickness {m}
          0.16,                    !- Conductivity {W/m-K}
          800,                     !- Density {kg/m3}
          1090;                    !- Specific Heat {J/kg-K}

        Construction,
          Interior Wall,           !- Name
          G01a 19mm gypsum board,  !- Outside Layer
          F04 Wall air space resistance,  !- Layer 2
          G01a 19mm gypsum board;  !- Layer 3
        """
    idf = IDF()
    idf.initreadtxt(idftxt)
    assert idf.getobject("MATERIAL", "G01a 19mm gypsum board")
Example #20
0
def test_initreadtxt():
    """Test for IDF.initreadtxt().
    """
    idftxt = """
        Material,
          G01a 19mm gypsum board,  !- Name
          MediumSmooth,            !- Roughness
          0.019,                   !- Thickness {m}
          0.16,                    !- Conductivity {W/m-K}
          800,                     !- Density {kg/m3}
          1090;                    !- Specific Heat {J/kg-K}

        Construction,
          Interior Wall,           !- Name
          G01a 19mm gypsum board,  !- Outside Layer
          F04 Wall air space resistance,  !- Layer 2
          G01a 19mm gypsum board;  !- Layer 3
        """
    idf = IDF()
    idf.initreadtxt(idftxt)
    assert idf.getobject('MATERIAL', 'G01a 19mm gypsum board')
Example #21
0
# <codecell>

# make a new branch chiller->pipe1-> pipe2

# make a new pipe component
pipe1 = idf.newidfobject("PIPE:ADIABATIC", 'np1')

# make a new chiller
chiller = idf.newidfobject("Chiller:Electric".upper(), 'Central_Chiller')

# make another pipe component
pipe2 = idf.newidfobject("PIPE:ADIABATIC", 'np2')

# get the loop we are trying to modify
loop = idf.getobject('PLANTLOOP', 'p_loop') # args are (key, name)
# get the branch we are trying to modify
branch = idf.getobject('BRANCH', 'sb0') # args are (key, name)
listofcomponents = [chiller, pipe1, pipe2] # the new components are connected in this order

newbr = hvacbuilder.replacebranch(idf, loop, branch, listofcomponents, fluid='Water')
# in "loop"
# this replaces the components in "branch" with the components in "listofcomponents"

idf.saveas("hhh_new.idf")

# <markdowncell>

# We have saved this as  file "hhh_new.idf".  
# Let us draw the diagram of this file.  (run this from eppy/eppy folder)
Example #22
0
# <codecell>

# make a new branch chiller->pipe1-> pipe2

# make a new pipe component
pipe1 = idf.newidfobject("PIPE:ADIABATIC", 'np1')

# make a new chiller
chiller = idf.newidfobject("Chiller:Electric".upper(), 'Central_Chiller')

# make another pipe component
pipe2 = idf.newidfobject("PIPE:ADIABATIC", 'np2')

# get the loop we are trying to modify
loop = idf.getobject('PLANTLOOP', 'p_loop') # args are (key, name)
# get the branch we are trying to modify
branch = idf.getobject('BRANCH', 'sb0') # args are (key, name)
listofcomponents = [chiller, pipe1, pipe2] # the new components are connected in this order

newbr = hvacbuilder.replacebranch(idf, loop, branch, listofcomponents, fluid='Water')
# in "loop"
# this replaces the components in "branch" with the components in "listofcomponents"

idf.saveas("hhh_new.idf")

# <markdowncell>

# We have saved this as  file "hhh_new.idf".  
# Let us draw the diagram of this file.  (run this from eppy/eppy folder)
Example #23
0
class Test_ThermalProperties(object):
    def setup_method(self, test_method):
        self.idf = IDF()

    def test_rvalue_1_layer_construction(self):
        self.idf.initreadtxt(single_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = INSIDE_FILM_R + m.Thickness / m.Conductivity + OUTSIDE_FILM_R
        assert c.rvalue == expected
        assert c.rvalue == 0.35

    def test_rvalue_fails(self):
        self.idf.initreadtxt(expected_failure)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        try:
            c.rvalue
            assert False
        except AttributeError as e:
            assert str(e) == "Skyhooks material not found in IDF"

    def test_rvalue_2_layer_construction(self):
        self.idf.initreadtxt(double_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                    m.Thickness / m.Conductivity + OUTSIDE_FILM_R)
        assert c.rvalue == expected
        assert c.rvalue == 0.55

    def test_rvalue_airgap_construction(self):
        self.idf.initreadtxt(air_gap)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        a = self.idf.getobject("MATERIAL:AIRGAP", "AirGap")
        expected = (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                    a.Thermal_Resistance + m.Thickness / m.Conductivity +
                    OUTSIDE_FILM_R)
        assert almostequal(c.rvalue, expected, places=2)
        assert almostequal(c.rvalue, 0.65, places=2)

    def test_rvalue_infraredtransparent_construction(self):
        self.idf.initreadtxt(infrared_transparent)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                    m.Thickness / m.Conductivity + OUTSIDE_FILM_R)
        assert almostequal(c.rvalue, expected, places=2)
        assert almostequal(c.rvalue, 0.55, places=2)

    def test_rvalue_nomass_construction(self):
        self.idf.initreadtxt(no_mass)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        n = self.idf.getobject("MATERIAL:NOMASS", "NoMass")
        expected = (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                    n.Thermal_Resistance + m.Thickness / m.Conductivity +
                    OUTSIDE_FILM_R)
        assert almostequal(c.rvalue, expected, places=2)
        assert almostequal(c.rvalue, 0.65, places=2)

    def test_rvalue_roofvegetation_construction(self):
        self.idf.initreadtxt(roof_vegetation)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL:ROOFVEGETATION", "RoofVegetation")
        expected = (INSIDE_FILM_R + m.Thickness / m.Conductivity_of_Dry_Soil +
                    OUTSIDE_FILM_R)
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            assert c.rvalue == expected
            assert c.rvalue == 0.35
            # check that a UserWarning is raised
            assert issubclass(w[-1].category, UserWarning)

    def test_rvalue_material(self):
        self.idf.initreadtxt(single_layer)
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness / m.Conductivity
        assert m.rvalue == expected
        assert m.rvalue == 0.2

    def test_ufactor_1_layer_construction(self):
        self.idf.initreadtxt(single_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = 1 / (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                        OUTSIDE_FILM_R)
        assert c.ufactor == expected
        assert c.ufactor == 1 / 0.35

    def test_ufactor_2_layer_construction(self):
        self.idf.initreadtxt(double_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = 1 / (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                        m.Thickness / m.Conductivity + OUTSIDE_FILM_R)
        assert c.ufactor == expected
        assert c.ufactor == 1 / 0.55

    def test_ufactor_airgap_construction(self):
        self.idf.initreadtxt(air_gap)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        a = self.idf.getobject("MATERIAL:AIRGAP", "AirGap")
        expected = 1 / (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                        a.Thermal_Resistance + m.Thickness / m.Conductivity +
                        OUTSIDE_FILM_R)
        assert almostequal(c.ufactor, expected, places=2)
        assert almostequal(c.ufactor, 1 / 0.65, places=2)

    def test_ufactor_infraredtransparent_construction(self):
        self.idf.initreadtxt(infrared_transparent)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = 1 / (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                        m.Thickness / m.Conductivity + OUTSIDE_FILM_R)
        assert almostequal(c.ufactor, expected, places=2)
        assert almostequal(c.ufactor, 1 / 0.55, places=2)

    def test_ufactor_nomass_construction(self):
        self.idf.initreadtxt(no_mass)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        n = self.idf.getobject("MATERIAL:NOMASS", "NoMass")
        expected = 1 / (INSIDE_FILM_R + m.Thickness / m.Conductivity +
                        n.Thermal_Resistance + m.Thickness / m.Conductivity +
                        OUTSIDE_FILM_R)
        assert almostequal(c.ufactor, expected, places=2)
        assert almostequal(c.ufactor, 1 / 0.65, places=2)

    def test_ufactor_roofvegetation_construction(self):
        self.idf.initreadtxt(roof_vegetation)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL:ROOFVEGETATION", "RoofVegetation")
        expected = 1 / (INSIDE_FILM_R + m.Thickness /
                        m.Conductivity_of_Dry_Soil + OUTSIDE_FILM_R)
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            assert c.ufactor == expected
            assert c.ufactor == 1 / 0.35
            # check that a UserWarning is raised
            assert issubclass(w[-1].category, UserWarning)

    def test_ufactor_material(self):
        self.idf.initreadtxt(single_layer)
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = 1 / (m.Thickness / m.Conductivity)
        assert m.ufactor == expected
        assert m.ufactor == 1 / 0.2

    def test_heatcapacity_1_layer_construction(self):
        self.idf.initreadtxt(single_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001
        assert c.heatcapacity == expected
        assert c.heatcapacity == 120

    def test_heatcapacity_2_layer_construction(self):
        self.idf.initreadtxt(double_layer)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001 * 2
        assert c.heatcapacity == expected
        assert c.heatcapacity == 240

    def test_heatcapacity_airgap_construction(self):
        self.idf.initreadtxt(air_gap)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001 * 2
        assert almostequal(c.heatcapacity, expected, places=2)
        assert almostequal(c.heatcapacity, 240, places=2)

    def test_heatcapacity_infraredtransparent_construction(self):
        self.idf.initreadtxt(infrared_transparent)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001 * 2
        assert almostequal(c.heatcapacity, expected, places=2)
        assert almostequal(c.heatcapacity, 240, places=2)

    def test_heatcapacity_nomass_construction(self):
        self.idf.initreadtxt(no_mass)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001 * 2
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            assert almostequal(c.heatcapacity, expected, places=2)
            assert almostequal(c.heatcapacity, 240, places=2)
            assert issubclass(w[-1].category, UserWarning)

    def test_heatcapacity_roofvegetation_construction(self):
        self.idf.initreadtxt(roof_vegetation)
        c = self.idf.getobject("CONSTRUCTION", "TestConstruction")
        m = self.idf.getobject("MATERIAL:ROOFVEGETATION", "RoofVegetation")
        expected = (m.Thickness * m.Specific_Heat_of_Dry_Soil *
                    m.Density_of_Dry_Soil * 0.001)
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            # check that a UserWarning is raised
            assert almostequal(c.heatcapacity, expected, places=2)
            assert almostequal(c.heatcapacity, 120, places=2)
            assert issubclass(w[-1].category, UserWarning)

    def test_heatcapacity_material(self):
        self.idf.initreadtxt(single_layer)
        m = self.idf.getobject("MATERIAL", "TestMaterial")
        expected = m.Thickness * m.Specific_Heat * m.Density * 0.001
        assert m.heatcapacity == expected
        assert m.heatcapacity == 120
Example #24
0
# <codecell>

# make a new branch chiller->pipe1-> pipe2

# make a new pipe component
pipe1 = idf.newidfobject("PIPE:ADIABATIC", "np1")

# make a new chiller
chiller = idf.newidfobject("Chiller:Electric".upper(), "Central_Chiller")

# make another pipe component
pipe2 = idf.newidfobject("PIPE:ADIABATIC", "np2")

# get the loop we are trying to modify
loop = idf.getobject("PLANTLOOP", "p_loop")  # args are (key, name)
# get the branch we are trying to modify
branch = idf.getobject("BRANCH", "sb0")  # args are (key, name)
listofcomponents = [
    chiller,
    pipe1,
    pipe2,
]  # the new components are connected in this order

newbr = hvacbuilder.replacebranch(idf, loop, branch, listofcomponents, fluid="Water")
# in "loop"
# this replaces the components in "branch" with the components in "listofcomponents"

idf.saveas("hhh_new.idf")

# <markdowncell>
Example #25
0
def test_zonearea_zonevolume():
    """py.test for zonearea and zonevolume"""
    idftxt = """Zone, 473222, 0.0, 0.0, 0.0, 0.0, , 1;
        BuildingSurface:Detailed, F7289B, Floor, Exterior Floor, 473222,
        Ground, ,
        NoSun, NoWind, , 4, 2.23, 2.56, 0.0, 2.23, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        2.56, 0.0;  BuildingSurface:Detailed, F3659B, Wall, Exterior Wall,
        473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.56, 1.49,
        2.23, 2.56, 0.0, 0.0, 2.56, 0.0, 0.0, 2.56, 1.49;
        BuildingSurface:Detailed, 46C6C9, Wall, Exterior Wall, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 2.23, 0.0, 1.49, 2.23,
        0.0, 0.0, 2.23, 1.02548139464, 0.0, 2.23, 1.02548139464, 1.49;
        BuildingSurface:Detailed, 4287DD, Wall, Exterior Wall, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 0.0, 2.56, 1.49, 0.0,
        2.56, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.49;
        BuildingSurface:Detailed, 570C2E, Wall, Exterior Wall, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 0.0, 0.0, 1.49, 0.0, 0.0,
        0.0, 2.23, 0.0, 0.0, 2.23, 0.0, 1.49;  BuildingSurface:Detailed,
        BAEA99, Roof, Exterior Roof, 473222, Outdoors, , SunExposed,
        WindExposed, , 4, 0.0, 2.56, 1.49, 0.0, 0.0, 1.49, 2.23, 0.0, 1.49,
        2.23, 2.56, 1.49;  BuildingSurface:Detailed, C879FE, Floor,
        Exterior Floor, 473222, Ground, , NoSun, NoWind, , 4, 3.22,
        2.52548139464, 0.0, 3.22, 1.02548139464, 0.0, 2.23,
        1.02548139464, 0.0, 2.23, 2.52548139464, 0.0;
        BuildingSurface:Detailed, 25B601, Wall, Exterior Wall, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 2.23,
        1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 2.23, 2.52548139464,
        0.0, 2.23, 2.52548139464, 1.49;  BuildingSurface:Detailed, F5EADC,
        Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, ,
        4, 2.23, 1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 3.22,
        1.02548139464, 0.0, 3.22, 1.02548139464, 1.49;
        BuildingSurface:Detailed, D0AABE, Wall, Exterior Wall, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 3.22, 1.02548139464,
        1.49, 3.22, 1.02548139464, 0.0, 3.22, 2.52548139464, 0.0, 3.22,
        2.52548139464, 1.49;  BuildingSurface:Detailed, B0EA02, Wall,
        Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, ,
        4, 3.22, 2.52548139464, 1.49, 3.22, 2.52548139464, 0.0, 2.23,
        2.52548139464, 0.0, 2.23, 2.52548139464, 1.49;
        BuildingSurface:Detailed, E6DF3B, Roof, Exterior Roof, 473222,
        Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.52548139464, 1.49,
        2.23, 1.02548139464, 1.49, 3.22, 1.02548139464, 1.49, 3.22,
        2.52548139464, 1.49;  BuildingSurface:Detailed, 4F8681, Wall,
        Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4,
        2.23, 2.52548139464, 1.49, 2.23, 2.52548139464, 0.0, 2.23, 2.56,
        0.0, 2.23, 2.56, 1.49;  """
    idf = IDF(StringIO(idftxt))
    result = modeleditor.zonearea(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea_floor(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea_roofceiling(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zone_floor2roofheight(idf, "473222")
    assert almostequal(result, 1.49)
    result = modeleditor.zoneheight(idf, "473222")
    assert almostequal(result, 1.49)
    result = modeleditor.zone_floor2roofheight(idf, "473222")
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, "473222")
    assert almostequal(result, 10.718762)
    # remove floor
    zone = idf.getobject("ZONE", "473222")
    surfs = idf.idfobjects["BuildingSurface:Detailed".upper()]
    zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
    floors = [s for s in zone_surfs if s.Surface_Type.upper() == "FLOOR"]
    for floor in floors:
        idf.removeidfobject(floor)
    result = modeleditor.zonearea_floor(idf, "473222")
    assert almostequal(result, 0)
    result = modeleditor.zonearea_roofceiling(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zonearea(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zoneheight(idf, "473222")
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, "473222")
    assert almostequal(result, 10.718762)
    # reload idf and remove roof/ceiling
    idf = IDF(StringIO(idftxt))
    zone = idf.getobject("ZONE", "473222")
    surfs = idf.idfobjects["BuildingSurface:Detailed".upper()]
    zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
    roofs = [s for s in zone_surfs if s.Surface_Type.upper() == "ROOF"]
    ceilings = [s for s in zone_surfs if s.Surface_Type.upper() == "CEILING"]
    topsurfaces = roofs + ceilings
    for surf in topsurfaces:
        idf.removeidfobject(surf)
    result = modeleditor.zonearea_roofceiling(idf, "473222")
    assert almostequal(result, 0)
    result = modeleditor.zonearea(idf, "473222")
    assert almostequal(result, 7.1938)
    result = modeleditor.zoneheight(idf, "473222")
    assert almostequal(result, 1.49)
    result = modeleditor.zonevolume(idf, "473222")
    assert almostequal(result, 10.718762)
Example #26
0
    def test_getreferingobjs(self):
        """py.test for getreferingobjs"""
        thedata = ((
        """  Zone,
        Box,  !- Name
        0.0,  !- Direction of Relative North {deg}
        0.288184,  !- X Origin {m}
        0.756604,  !- Y Origin {m}
        0.0,  !- Z Origin {m}
        ,  !- Type
        1;  !- Multiplier

      BuildingSurface:Detailed,
        N_Wall,  !- Name
        Wall,  !- Surface Type
        Exterior Wall,  !- Construction Name
        Box,  !- Zone Name
        Outdoors,  !- Outside Boundary Condition
        ,  !- Outside Boundary Condition Object
        SunExposed,  !- Sun Exposure
        WindExposed,  !- Wind Exposure
        ,  !- View Factor to Ground
        1,  !- Number of Vertices
        5.000000000000,  !- Vertex 1 X-coordinate {m}
        6.000000000000,  !- Vertex 1 Y-coordinate {m}
        3.000000000000;  !- Vertex 1 Z-coordinate {m}
    
      WALL:EXTERIOR,            
          WallExterior,                    !- Name
          ,                         !- Construction Name
          Box,                         !- Zone Name
          ,                         !- Azimuth Angle
          90;                       !- Tilt Angle

        BUILDINGSURFACE:DETAILED, 
            EWall,                    !- Name
            ,                         !- Surface Type
            ,                         !- Construction Name
            BOX,                         !- Zone Name
            OtherBox,                         !- Outside Boundary Condition
            ,                         !- Outside Boundary Condition Object
            SunExposed,               !- Sun Exposure
            WindExposed,              !- Wind Exposure
            autocalculate,            !- View Factor to Ground
            autocalculate;            !- Number of Vertices

        BUILDINGSURFACE:DETAILED, 
            EWall1,                    !- Name
            ,                         !- Surface Type
            ,                         !- Construction Name
            BOX_other,                         !- Zone Name
            OtherBox,                         !- Outside Boundary Condition
            ,                         !- Outside Boundary Condition Object
            SunExposed,               !- Sun Exposure
            WindExposed,              !- Wind Exposure
            autocalculate,            !- View Factor to Ground
            autocalculate;            !- Number of Vertices
      HVACTemplate:Thermostat,
        Constant Setpoint Thermostat,  !- Name
        ,                        !- Heating Setpoint Schedule Name
        20,                      !- Constant Heating Setpoint {C}
        ,                        !- Cooling Setpoint Schedule Name
        25;                      !- Constant Cooling Setpoint {C}

    FENESTRATIONSURFACE:DETAILED,
        Window1,                  !- Name
        ,                         !- Surface Type
        ,                         !- Construction Name
        EWall1,                         !- Building Surface Name
        ,                         !- Outside Boundary Condition Object
        autocalculate,            !- View Factor to Ground
        ,                         !- Shading Control Name
        ,                         !- Frame and Divider Name
        1.0,                      !- Multiplier
        autocalculate;            !- Number of Vertices
      """,
        'Box',
        ['N_Wall', 'EWall', 'WallExterior']), # idftxt, zname, surfnamelst
        )
        for idftxt, zname, surfnamelst in thedata:
            # import pdb; pdb.set_trace()
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject('zone'.upper(), zname)
            kwargs = {}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject('zone'.upper(), zname)
            kwargs = {'iddgroups':[u'Thermal Zones and Surfaces', ]}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject('zone'.upper(), zname)
            kwargs = {'fields':[u'Zone_Name', ],}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject('zone'.upper(), zname)
            kwargs = {'fields':[u'Zone_Name', ],
                'iddgroups':[u'Thermal Zones and Surfaces', ]}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        # use the above idftxt and try other to get other references.
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            wname = 'EWall1'
            windownamelist = ['Window1', ]
            wall = idf.getobject('BUILDINGSURFACE:DETAILED'.upper(), wname)
            kwargs = {'fields':[u'Building_Surface_Name', ],
                'iddgroups':[u'Thermal Zones and Surfaces', ]}
            result = wall.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == windownamelist
Example #27
0
    def test_getreferingobjs(self):
        """py.test for getreferingobjs"""
        thedata = (
            (
                """  Zone,
        Box,  !- Name
        0.0,  !- Direction of Relative North {deg}
        0.288184,  !- X Origin {m}
        0.756604,  !- Y Origin {m}
        0.0,  !- Z Origin {m}
        ,  !- Type
        1;  !- Multiplier

      BuildingSurface:Detailed,
        N_Wall,  !- Name
        Wall,  !- Surface Type
        Exterior Wall,  !- Construction Name
        Box,  !- Zone Name
        Outdoors,  !- Outside Boundary Condition
        ,  !- Outside Boundary Condition Object
        SunExposed,  !- Sun Exposure
        WindExposed,  !- Wind Exposure
        ,  !- View Factor to Ground
        1,  !- Number of Vertices
        5.000000000000,  !- Vertex 1 X-coordinate {m}
        6.000000000000,  !- Vertex 1 Y-coordinate {m}
        3.000000000000;  !- Vertex 1 Z-coordinate {m}

      WALL:EXTERIOR,
          WallExterior,                    !- Name
          ,                         !- Construction Name
          Box,                         !- Zone Name
          ,                         !- Azimuth Angle
          90;                       !- Tilt Angle

        BUILDINGSURFACE:DETAILED,
            EWall,                    !- Name
            ,                         !- Surface Type
            ,                         !- Construction Name
            BOX,                         !- Zone Name
            OtherBox,                         !- Outside Boundary Condition
            ,                         !- Outside Boundary Condition Object
            SunExposed,               !- Sun Exposure
            WindExposed,              !- Wind Exposure
            autocalculate,            !- View Factor to Ground
            autocalculate;            !- Number of Vertices

        BUILDINGSURFACE:DETAILED,
            EWall1,                    !- Name
            ,                         !- Surface Type
            ,                         !- Construction Name
            BOX_other,                         !- Zone Name
            OtherBox,                         !- Outside Boundary Condition
            ,                         !- Outside Boundary Condition Object
            SunExposed,               !- Sun Exposure
            WindExposed,              !- Wind Exposure
            autocalculate,            !- View Factor to Ground
            autocalculate;            !- Number of Vertices
      HVACTemplate:Thermostat,
        Constant Setpoint Thermostat,  !- Name
        ,                        !- Heating Setpoint Schedule Name
        20,                      !- Constant Heating Setpoint {C}
        ,                        !- Cooling Setpoint Schedule Name
        25;                      !- Constant Cooling Setpoint {C}

    FENESTRATIONSURFACE:DETAILED,
        Window1,                  !- Name
        ,                         !- Surface Type
        ,                         !- Construction Name
        EWall1,                         !- Building Surface Name
        ,                         !- Outside Boundary Condition Object
        autocalculate,            !- View Factor to Ground
        ,                         !- Shading Control Name
        ,                         !- Frame and Divider Name
        1.0,                      !- Multiplier
        autocalculate;            !- Number of Vertices
      """,
                "Box",
                ["N_Wall", "EWall", "WallExterior"],
            ),  # idftxt, zname, surfnamelst
        )
        for idftxt, zname, surfnamelst in thedata:
            # import pdb; pdb.set_trace()
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject("zone", zname)
            kwargs = {}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject("zone", zname)
            kwargs = {"iddgroups": ["Thermal Zones and Surfaces"]}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject("zone", zname)
            kwargs = {"fields": ["Zone_Name"]}
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            zone = idf.getobject("zone", zname)
            kwargs = {
                "fields": ["Zone_Name"],
                "iddgroups": ["Thermal Zones and Surfaces"],
            }
            result = zone.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == surfnamelst
        # use the above idftxt and try other to get other references.
        for idftxt, zname, surfnamelst in thedata:
            idf = IDF(StringIO(idftxt))
            wname = "EWall1"
            windownamelist = ["Window1"]
            wall = idf.getobject("BUILDINGSURFACE:DETAILED", wname)
            kwargs = {
                "fields": ["Building_Surface_Name"],
                "iddgroups": ["Thermal Zones and Surfaces"],
            }
            result = wall.getreferingobjs(**kwargs)
            rnames = [item.Name for item in result]
            rnames.sort()
            surfnamelst.sort()
            assert rnames == windownamelist