Esempio n. 1
0
def test_initinletoutlet():
    """py.test for initinletoutlet"""
    tdata = (
        ('PIPE:ADIABATIC', 'apipe', None, True, ["apipe_Inlet_Node_Name"],
         ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ('PIPE:ADIABATIC', 'apipe', None, False, ["Gumby"],
         ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ('Coil:Cooling:Water'.upper(), 'acoil', 'Water_', True,
         ["acoil_Water_Inlet_Node_Name",
          ""], ["acoil_Water_Outlet_Node_Name", ""]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
    )
    fhandle = StringIO("")
    idf = IDF(fhandle)
    for idfobjectkey, idfobjname, thisnode, force, inlets, outlets in tdata:
        idfobject = idf.newidfobject(idfobjectkey, idfobjname)
        inodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Inlet_Node_Name")
        idfobject[inodefields[0]] = "Gumby"
        hvacbuilder.initinletoutlet(idf, idfobject, thisnode, force=force)
        inodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Inlet_Node_Name")
        for nodefield, inlet in zip(inodefields, inlets):
            result = idfobject[nodefield]
            assert result == inlet
        onodefields = hvacbuilder.getfieldnamesendswith(
            idfobject, "Outlet_Node_Name")
        for nodefield, outlet in zip(onodefields, outlets):
            result = idfobject[nodefield]
            assert result == outlet
Esempio n. 2
0
def test_initinletoutlet():
    """py.test for initinletoutlet"""
    tdata = (
        ("PIPE:ADIABATIC", "apipe", None, True, ["apipe_Inlet_Node_Name"], ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        ("PIPE:ADIABATIC", "apipe", None, False, ["Gumby"], ["apipe_Outlet_Node_Name"]),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
        (
            "Coil:Cooling:Water".upper(),
            "acoil",
            "Water_",
            True,
            ["acoil_Water_Inlet_Node_Name", ""],
            ["acoil_Water_Outlet_Node_Name", ""],
        ),
        # idfobjectkey, idfobjname, thisnode, force, inlets, outlets
    )
    fhandle = StringIO("")
    idf = IDF(fhandle)
    for idfobjectkey, idfobjname, thisnode, force, inlets, outlets in tdata:
        idfobject = idf.newidfobject(idfobjectkey, idfobjname)
        inodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Inlet_Node_Name")
        idfobject[inodefields[0]] = "Gumby"
        hvacbuilder.initinletoutlet(idf, idfobject, thisnode, force=force)
        inodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Inlet_Node_Name")
        for nodefield, inlet in zip(inodefields, inlets):
            result = idfobject[nodefield]
            assert result == inlet
        onodefields = hvacbuilder.getfieldnamesendswith(idfobject, "Outlet_Node_Name")
        for nodefield, outlet in zip(onodefields, outlets):
            result = idfobject[nodefield]
            assert result == outlet
Esempio n. 3
0
def test_connectcomponents():
    """py.test for connectcomponents"""
    fhandle = StringIO("")
    idf = IDF(fhandle)

    tdata = (
        (
            [(idf.newidfobject("PIPE:ADIABATIC", "pipe1"), None),
             (idf.newidfobject("PIPE:ADIABATIC", "pipe2"), None)],
            ["pipe1_Inlet_Node_Name", ["pipe2_Inlet_Node_Name",
                                       "pipe1_pipe2_node"]],
            [["pipe1_Outlet_Node_Name", "pipe1_pipe2_node"],
             "pipe2_Outlet_Node_Name"], '',
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("Coil:Cooling:Water".upper(), "pipe1"),
              'Water_'),
             (idf.newidfobject("Coil:Cooling:Water".upper(), "pipe2"),
              'Water_')],
            ['pipe1_Water_Inlet_Node_Name', '',
             'pipe2_Water_Inlet_Node_Name',
             ['', 'pipe1_pipe2_node']],
            [['pipe1_Water_Outlet_Node_Name', 'pipe1_pipe2_node'], '',
             'pipe2_Water_Outlet_Node_Name', ''],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("PIPE:ADIABATIC".upper(), "pipe1"), None),
             (idf.newidfobject("Coil:Cooling:Water".upper(), "pipe2"),
              'Water_')],
            ["pipe1_Inlet_Node_Name", "pipe2_Water_Inlet_Node_Name",
             ['pipe2_Air_Inlet_Node_Name', 'pipe1_pipe2_node']],
            [['pipe1_Outlet_Node_Name', 'pipe1_pipe2_node'],
             "pipe2_Water_Outlet_Node_Name", ""],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
    )
    for components_thisnodes, inlets, outlets, fluid in tdata:
        # init the nodes in the new components
        for component, thisnode in components_thisnodes:
            hvacbuilder.initinletoutlet(idf, component, thisnode)
        hvacbuilder.connectcomponents(idf, components_thisnodes, fluid)
        inresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Inlet_Node_Name")
            for name in fldnames:
                inresult.append(component[name])
        assert inresult == inresult
        outresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Outlet_Node_Name")
            for name in fldnames:
                outresult.append(component[name])
        assert outresult == outlets
Esempio n. 4
0
def test_connectcomponents():
    """py.test for connectcomponents"""
    fhandle = StringIO("")
    idf = IDF(fhandle)

    tdata = (
        (
            [(idf.newidfobject("PIPE:ADIABATIC", Name="pipe1"), None),
             (idf.newidfobject("PIPE:ADIABATIC", Name="pipe2"), None)],
            ["pipe1_Inlet_Node_Name", ["pipe2_Inlet_Node_Name",
                                       "pipe1_pipe2_node"]],
            [["pipe1_Outlet_Node_Name", "pipe1_pipe2_node"],
             "pipe2_Outlet_Node_Name"], '',
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("Coil:Cooling:Water", Name="pipe1"),
              'Water_'),
             (idf.newidfobject("Coil:Cooling:Water", Name="pipe2"),
              'Water_')],
            ['pipe1_Water_Inlet_Node_Name', '',
             'pipe2_Water_Inlet_Node_Name',
             ['', 'pipe1_pipe2_node']],
            [['pipe1_Water_Outlet_Node_Name', 'pipe1_pipe2_node'], '',
             'pipe2_Water_Outlet_Node_Name', ''],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
        (
            [(idf.newidfobject("PIPE:ADIABATIC", Name="pipe1"), None),
             (idf.newidfobject("Coil:Cooling:Water", Name="pipe2"),
              'Water_')],
            ["pipe1_Inlet_Node_Name", "pipe2_Water_Inlet_Node_Name",
             ['pipe2_Air_Inlet_Node_Name', 'pipe1_pipe2_node']],
            [['pipe1_Outlet_Node_Name', 'pipe1_pipe2_node'],
             "pipe2_Water_Outlet_Node_Name", ""],
            'Air'
        ),
        # components_thisnodes, inlets, outlets, fluid
    )
    for components_thisnodes, inlets, outlets, fluid in tdata:
        # init the nodes in the new components
        for component, thisnode in components_thisnodes:
            hvacbuilder.initinletoutlet(idf, component, thisnode)
        hvacbuilder.connectcomponents(idf, components_thisnodes, fluid)
        inresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Inlet_Node_Name")
            for name in fldnames:
                inresult.append(component[name])
        assert inresult == inresult
        outresult = []
        for component, thisnode in components_thisnodes:
            fldnames = hvacbuilder.getfieldnamesendswith(component,
                                                         "Outlet_Node_Name")
            for name in fldnames:
                outresult.append(component[name])
        assert outresult == outlets
Esempio n. 5
0
def test_getfieldnamesendswith():
    """py.test for getfieldnamesendswith"""
    idftxt = """PIPE:ADIABATIC,
        np2,                      !- Name
        np1_np2_node,             !- Inlet Node Name
        np2_outlet;               !- Outlet Node Name

    """
    tdata = (
        ("Inlet_Node_Name", ["Inlet_Node_Name"]
        ), # endswith, fieldnames
        (
            "Node_Name",
            ["Inlet_Node_Name",
             "Outlet_Node_Name"]), # endswith, fieldnames
        (
            "Name",
            [
                "Name",
                "Inlet_Node_Name",
                "Outlet_Node_Name"]), # endswith, fieldnames
    )
    fhandle = StringIO(idftxt)
    idf = IDF(fhandle)
    idfobject = idf.idfobjects["PIPE:ADIABATIC"][0]
    for endswith, fieldnames in tdata:
        result = hvacbuilder.getfieldnamesendswith(idfobject, endswith)
        assert result == fieldnames
Esempio n. 6
0
def test_getfieldnamesendswith():
    """py.test for getfieldnamesendswith"""
    idftxt = """PIPE:ADIABATIC,
        np2,                      !- Name
        np1_np2_node,             !- Inlet Node Name
        np2_outlet;               !- Outlet Node Name

    """
    tdata = (
        ("Inlet_Node_Name", ["Inlet_Node_Name"]
        ),  # endswith, fieldnames
        (
            "Node_Name",
            ["Inlet_Node_Name",
             "Outlet_Node_Name"]),  # endswith, fieldnames
        (
            "Name",
            [
                "Name",
                "Inlet_Node_Name",
                "Outlet_Node_Name"]),  # endswith, fieldnames
    )
    fhandle = StringIO(idftxt)
    idf = IDF(fhandle)
    idfobject = idf.idfobjects["PIPE:ADIABATIC"][0]
    for endswith, fieldnames in tdata:
        result = hvacbuilder.getfieldnamesendswith(idfobject, endswith)
        assert result == fieldnames