Example #1
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 #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 copy(self, idf):

        idf_txt = idf.idfstr()
        try:
            idf_copy = IDF(epw=getattr(idf, 'epw'))
        except AttributeError:
            idf_copy = IDF()
        idf_copy.initreadtxt(idf_txt)
        return idf_copy
Example #4
0
def test_glazeddoor():
    """py.test for glazeddoor"""
    fsdtxt = """FenestrationSurface:Detailed, DF-1, GLASSDOOR, Sgl Grey 3mm,
    FRONT-1, , 0.5, , , 1, 4, 21.3, 0.0, 2.1, 21.3, 0.0, 0.0, 23.8, 0.0, 0.0,
    23.8, 0.0, 2.1;"""
    simpleobjtxt = """GLAZEDDOOR, DF-1, Sgl Grey 3mm, FRONT-1, , , 1, 0, 0,
    2.5, 2.1;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.glazeddoor(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.glazeddoor(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #5
0
def test_roof():
    """py.test for roof"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, roof, WALL-1, PLENUM-1, , ,
    SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 30.5, 0.0,
    2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """ROOF, WALL-1PF, WALL-1, PLENUM-1, 180.0, 90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.roof(idf, bsd, deletebsd=False, setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.roof(idf, bsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #6
0
def test_window():
    """py.test for window"""
    fsdtxt = """FenestrationSurface:Detailed, WF-1, WINDOW, 
    Dbl Clr 3mm/13mm Air, FRONT-1, , 0.5, , , 1, 4, 3.0, 0.0, 2.1, 3.0, 0.0, 
    0.9, 16.8, 0.0,
    0.9, 16.8, 0.0, 2.1;"""
    simpleobjtxt = """WINDOW, WF-1, Dbl Clr 3mm/13mm Air, FRONT-1, , , 1, 0, 0,
    13.8, 1.2;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.window(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.window(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #7
0
def test_floorgroundcontact():
    """py.test for floorgroundcontact"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, floor, WALL-1, PLENUM-1,
    Ground, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """FLOOR:GROUNDCONTACT, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorgroundcontact(
        idf, bsd, deletebsd=False,
        setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorgroundcontact(
        idf, bsd, deletebsd=True,
        setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #8
0
def test_ceilingadiabatic():
    """py.test for ceilingadiabatic"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, ceiling, WALL-1, PLENUM-1,
    Adiabatic, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """CEILING:ADIABATIC, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.ceilingadiabatic(
        idf, bsd, deletebsd=False,
        setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.ceilingadiabatic(
        idf, bsd, deletebsd=True,
        setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #9
0
def test_wallunderground():
    """py.test for wallunderground"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, WALL, WALL-1, PLENUM-1,
    Ground, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """WALL:UNDERGROUND, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.wallunderground(idf,
                                          bsd,
                                          deletebsd=False,
                                          setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.wallunderground(idf,
                                          bsd,
                                          deletebsd=True,
                                          setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #10
0
def test_glazeddoor():
    """py.test for glazeddoor"""
    fsdtxt = """FenestrationSurface:Detailed, DF-1, GLASSDOOR, Sgl Grey 3mm,
    FRONT-1, , 0.5, , , 1, 4, 21.3, 0.0, 2.1, 21.3, 0.0, 0.0, 23.8, 0.0, 0.0,
    23.8, 0.0, 2.1;"""
    simpleobjtxt = """GLAZEDDOOR, DF-1, Sgl Grey 3mm, FRONT-1, , , 1, 0, 0,
    2.5, 2.1;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.glazeddoor(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.glazeddoor(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #11
0
def test_door():
    """py.test for window"""
    fsdtxt = """FenestrationSurface:Detailed, WR-1, door, Dbl Clr 3mm/13mm Air,
    RIGHT-1, , 0.5, , , 1, 4, 30.5, 3.8, 2.1, 30.5, 3.8, 0.9, 30.5, 11.4, 0.9,
    30.5, 11.4, 2.1;"""
    simpleobjtxt = """DOOR, WR-1, Dbl Clr 3mm/13mm Air, RIGHT-1, 1, 0, 0, 7.6,
    1.2;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.door(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.door(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #12
0
def test_window():
    """py.test for window"""
    fsdtxt = """FenestrationSurface:Detailed, WF-1, WINDOW, 
    Dbl Clr 3mm/13mm Air, FRONT-1, , 0.5, , , 1, 4, 3.0, 0.0, 2.1, 3.0, 0.0, 
    0.9, 16.8, 0.0,
    0.9, 16.8, 0.0, 2.1;"""
    simpleobjtxt = """WINDOW, WF-1, Dbl Clr 3mm/13mm Air, FRONT-1, , , 1, 0, 0,
    13.8, 1.2;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.window(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.window(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #13
0
def test_floorinterzone():
    """py.test for floorinterzone"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, floor, WALL-1, PLENUM-1,
    Zone, gumby, SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """FLOOR:INTERZONE, WALL-1PF, WALL-1, PLENUM-1, gumby,
    180.0, 90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorinterzone(idf,
                                         bsd,
                                         deletebsd=False,
                                         setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorinterzone(idf,
                                         bsd,
                                         deletebsd=True,
                                         setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #14
0
def test_floorgroundcontact():
    """py.test for floorgroundcontact"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, floor, WALL-1, PLENUM-1,
    Ground, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """FLOOR:GROUNDCONTACT, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorgroundcontact(idf,
                                             bsd,
                                             deletebsd=False,
                                             setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorgroundcontact(idf,
                                             bsd,
                                             deletebsd=True,
                                             setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #15
0
def test_ceilingadiabatic():
    """py.test for ceilingadiabatic"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, ceiling, WALL-1, PLENUM-1,
    Adiabatic, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """CEILING:ADIABATIC, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.ceilingadiabatic(idf,
                                           bsd,
                                           deletebsd=False,
                                           setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.ceilingadiabatic(idf,
                                           bsd,
                                           deletebsd=True,
                                           setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #16
0
def test_wallunderground():
    """py.test for wallunderground"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, WALL, WALL-1, PLENUM-1,
    Ground, , SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """WALL:UNDERGROUND, WALL-1PF, WALL-1, PLENUM-1, 180.0,
    90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.wallunderground(
        idf, bsd, deletebsd=False,
        setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.wallunderground(
        idf, bsd, deletebsd=True,
        setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #17
0
def test_roof():
    """py.test for roof"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, roof, WALL-1, PLENUM-1, , ,
    SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4, 30.5, 0.0,
    2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """ROOF, WALL-1PF, WALL-1, PLENUM-1, 180.0, 90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.roof(idf, bsd, deletebsd=False, setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.roof(idf, bsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #18
0
def test_floorinterzone():
    """py.test for floorinterzone"""
    bsdtxt = """BuildingSurface:Detailed, WALL-1PF, floor, WALL-1, PLENUM-1,
    Zone, gumby, SunExposed, WindExposed, 0.5, 4, 0.0, 0.0, 3.0, 0.0, 0.0, 2.4,
    30.5, 0.0, 2.4, 30.5, 0.0, 3.0;
"""
    simpleobjtxt = """FLOOR:INTERZONE, WALL-1PF, WALL-1, PLENUM-1, gumby,
    180.0, 90.0, 0, 0, 0, 30.5, 0.6;"""
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorinterzone(
        idf, bsd, deletebsd=False,
        setto000=True)
    newidttxt = bsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(bsdtxt)
    bsd = idf.idfobjects["BuildingSurface:Detailed".upper()][0]
    w_ext = simplesurface.floorinterzone(
        idf, bsd, deletebsd=True,
        setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #19
0
def test_door():
    """py.test for window"""
    fsdtxt = """FenestrationSurface:Detailed, WR-1, door, Dbl Clr 3mm/13mm Air,
    RIGHT-1, , 0.5, , , 1, 4, 30.5, 3.8, 2.1, 30.5, 3.8, 0.9, 30.5, 11.4, 0.9,
    30.5, 11.4, 2.1;"""
    simpleobjtxt = """DOOR, WR-1, Dbl Clr 3mm/13mm Air, RIGHT-1, 1, 0, 0, 7.6,
    1.2;"""
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.door(idf, fsd, deletebsd=False, setto000=True)
    newidttxt = fsdtxt + simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()

    # test  for deletebsd = True
    idf = IDF()
    idf.initreadtxt(fsdtxt)
    fsd = idf.idfobjects["FenestrationSurface:Detailed".upper()][0]
    w_ext = simplesurface.door(idf, fsd, deletebsd=True, setto000=True)
    newidttxt = simpleobjtxt
    newidf = IDF()
    newidf.initreadtxt(newidttxt)
    assert idf.idfstr() == newidf.idfstr()
Example #20
0
def test_idfstr():
    """Test all outputtype options in IDF.idfstr().
    """
    idf = IDF()
    idf.initreadtxt(idfsnippet)
    assert idf.outputtype == 'standard'  # start with the default
    original = idf.idfstr()
    assert "!-" in original  # has comment
    assert "\n" in original  # has line break
    assert "\n\n" in original  # has empty line

    idf.outputtype = 'standard'
    s = idf.idfstr()
    assert "!-" in s  # has comment
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty line
    assert s == original  # is unchanged

    idf.outputtype = 'nocomment'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty line
    assert s != original  # is changed

    idf.outputtype = 'nocomment1'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty lines
    assert s != original  # is changed

    idf.outputtype = 'nocomment2'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" not in s  # has no empty lines
    assert s != original  # is changed

    idf.outputtype = 'compressed'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" not in s  # has no line breaks
    assert "\n\n" not in s  # has no empty lines
    assert s != original  # is changed
Example #21
0
def test_idfstr():
    """Test all outputtype options in IDF.idfstr().
    """
    idf = IDF()
    idf.initreadtxt(idfsnippet)
    assert idf.outputtype == 'standard'  # start with the default
    original = idf.idfstr()
    assert "!-" in original  # has comment
    assert "\n" in original  # has line break
    assert "\n\n" in original  # has empty line

    idf.outputtype = 'standard'
    s = idf.idfstr()
    assert "!-" in s  # has comment
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty line
    assert s == original  # is unchanged

    idf.outputtype = 'nocomment'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty line
    assert s != original  # is changed

    idf.outputtype = 'nocomment1'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" in s  # has empty lines
    assert s != original  # is changed

    idf.outputtype = 'nocomment2'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" in s  # has line break
    assert "\n\n" not in s  # has no empty lines
    assert s != original  # is changed

    idf.outputtype = 'compressed'
    s = idf.idfstr()
    assert "!-" not in s  # has no comments
    assert "\n" not in s  # has no line breaks
    assert "\n\n" not in s  # has no empty lines
    assert s != original  # is changed
Example #22
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 #23
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 #24
0
def view_idf(fname=None, idf_txt=None, test=False):
    # type: (Optional[str], Optional[str], Optional[bool]) -> None
    """Display an IDF for inspection.

    :param fname: Path to the IDF.
    :param idf_txt: The string representation of an IDF.
    """
    try:
        plt.figure()
    except TclError:
        # this is as expected on the test server
        return
    if fname and idf_txt:
        raise ValueError('Pass either fname or idf_txt, not both.')
    # set the IDD for the version of EnergyPlus
    iddfhandle = StringIO(iddcurrent.iddtxt)
    if IDF.getiddname() is None:
        IDF.setiddname(iddfhandle)

    if fname:
        # import the IDF
        idf = IDF(fname)
    elif idf_txt:
        idf = IDF()
        idf.initreadtxt(idf_txt)
    # create the figure and add the surfaces
    ax = plt.axes(projection='3d')
    collections = _get_collections(idf, opacity=0.5)
    for c in collections:
        ax.add_collection3d(c)

    # calculate and set the axis limits
    limits = _get_limits(idf=idf)
    ax.set_xlim(limits['x'])
    ax.set_ylim(limits['y'])
    ax.set_zlim(limits['z'])

    if not test:
        plt.show()
Example #25
0
def view_idf(fname=None, idf_txt=None):
    """Display an IDF for inspection.
    
    Parameters
    ----------
    fname : str
        Path to the IDF.
    idf_txt : str
        The string representation of an IDF.

    """
    # set the IDD for the version of EnergyPlus
    iddfhandle = StringIO(iddcurrent.iddtxt)
    if IDF.getiddname() == None:
        IDF.setiddname(iddfhandle)

    if fname:
        # import the IDF
        idf = IDF(fname)
    elif idf_txt:
        idf = IDF()
        idf.initreadtxt(idf_txt)
    # create the figure and add the surfaces
    fig = plt.figure()
    ax = plt.axes(projection='3d')
    collections = _get_collections(idf, opacity=0.5)
    for c in collections:
        ax.add_collection3d(c)

    # calculate and set the axis limits
    limits = _get_limits(idf=idf)
    ax.set_xlim(limits['x'])
    ax.set_ylim(limits['y'])
    ax.set_zlim(limits['z'])

    plt.show()
Example #26
0
BuildingSurface:Detailed, 
    z2 Roof 0001,             !- Name
    Roof,                     !- Surface Type
    ,                         !- Construction Name
    Thermal Zone 2,           !- Zone Name
    Outdoors,                 !- Outside Boundary Condition
    ,                         !- Outside Boundary Condition Object
    SunExposed,               !- Sun Exposure
    WindExposed,              !- Wind Exposure
    ,                         !- View Factor to Ground
    ,                         !- Number of Vertices
    0.0,                      !- Vertex 1 Xcoordinate
    0.0,                      !- Vertex 1 Ycoordinate
    1.458,                   !- Vertex 1 Zcoordinate
    0.0,                      !- Vertex 2 Xcoordinate
    2.9,                      !- Vertex 2 Ycoordinate
    1.458,                   !- Vertex 2 Zcoordinate
    -2.14,                    !- Vertex 3 Xcoordinate
    2.9,                      !- Vertex 3 Ycoordinate
    1.458,                   !- Vertex 3 Zcoordinate
    -2.14,                    !- Vertex 4 Xcoordinate
    0.0,                      !- Vertex 4 Ycoordinate
    1.458;                   !- Vertex 4 Zcoordinate

"""
idf = IDF()
idf.initreadtxt(idftxt)

idf.outputtype = "compressed"
idf.printidf()
Example #27
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 #28
0
BuildingSurface:Detailed, 
    z2 Roof 0001,             !- Name
    Roof,                     !- Surface Type
    ,                         !- Construction Name
    Thermal Zone 2,           !- Zone Name
    Outdoors,                 !- Outside Boundary Condition
    ,                         !- Outside Boundary Condition Object
    SunExposed,               !- Sun Exposure
    WindExposed,              !- Wind Exposure
    ,                         !- View Factor to Ground
    ,                         !- Number of Vertices
    0.0,                      !- Vertex 1 Xcoordinate
    0.0,                      !- Vertex 1 Ycoordinate
    1.458,                   !- Vertex 1 Zcoordinate
    0.0,                      !- Vertex 2 Xcoordinate
    2.9,                      !- Vertex 2 Ycoordinate
    1.458,                   !- Vertex 2 Zcoordinate
    -2.14,                    !- Vertex 3 Xcoordinate
    2.9,                      !- Vertex 3 Ycoordinate
    1.458,                   !- Vertex 3 Zcoordinate
    -2.14,                    !- Vertex 4 Xcoordinate
    0.0,                      !- Vertex 4 Ycoordinate
    1.458;                   !- Vertex 4 Zcoordinate

"""
idf = IDF()
idf.initreadtxt(idftxt)

idf.outputtype = 'compressed'
idf.printidf()