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
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
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
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