Ejemplo n.º 1
0
def test_branchlist2branches():
    """py.test branchlist2branches"""
    thedata = (("""BranchList,
        Hot_Water_Loop_HW_Supply_Side_Branches,  !- Name
        Hot_Water_Loop_HW_Supply_Inlet_Branch,  !- Branch 1 Name
        Main_Boiler_HW_Branch,   !- Branch 2 Name
        Hot_Water_Loop_HW_Supply_Bypass_Branch,  !- Branch 3 Name
        Hot_Water_Loop_HW_Supply_Outlet_Branch;  !- Branch 4 Name

    BranchList,
        Hot_Water_Loop_HW_Demand_Side_Branches,  !- Name
        Hot_Water_Loop_HW_Demand_Inlet_Branch,  !- Branch 1 Name
        SPACE1__1_Heating_Coil_HW_Branch,  !- Branch 2 Name
        SPACE2__1_Heating_Coil_HW_Branch,  !- Branch 3 Name
        SPACE3__1_Heating_Coil_HW_Branch,  !- Branch 4 Name
        SPACE4__1_Heating_Coil_HW_Branch,  !- Branch 5 Name
        SPACE5__1_Heating_Coil_HW_Branch,  !- Branch 6 Name
        Hot_Water_Loop_HW_Demand_Bypass_Branch,  !- Branch 7 Name
        Hot_Water_Loop_HW_Demand_Outlet_Branch;  !- Branch 8 Name
    """,'Hot_Water_Loop_HW_Supply_Side_Branches', 
    ['Hot_Water_Loop_HW_Supply_Inlet_Branch',
    'Main_Boiler_HW_Branch',
    'Hot_Water_Loop_HW_Supply_Bypass_Branch',
    'Hot_Water_Loop_HW_Supply_Outlet_Branch']), # idftxt, branchlist, branches
    )
    for idftxt, branchlist, branches in thedata:
        fname = StringIO(idftxt)
        data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd,
                                                            iddV6_0.commdct)
        result = loops.branchlist2branches(data, commdct, branchlist)
        assert result == branches
Ejemplo n.º 2
0
# in plantloop get:
#     demand inlet, outlet, branchlist
#     supply inlet, outlet, branchlist
plantloops = loops.plantloopfields(data, commdct)
plantloop = plantloops[0]
anode = "epnode"
endnode = "EndNode"
#     
# supply barnchlist
#     branch1 -> inlet, outlet
#     branch2 -> inlet, outlet
#     branch3 -> inlet, outlet
sbranchlist = plantloop[3]
if sbranchlist.strip() != "":
    sbranches = loops.branchlist2branches(data, commdct, sbranchlist)
    s_in_out = [loops.branch_inlet_outlet(data, commdct, 
                                    sbranch) for sbranch in sbranches]
    sbranchinout = dict(zip(sbranches, (s_in_out, anode)))                            

dbranchlist = plantloop[6]
if dbranchlist.strip() != "":
    dbranches = loops.branchlist2branches(data, commdct, dbranchlist)
    d_in_out = [loops.branch_inlet_outlet(data, commdct, 
                                    dbranch) for dbranch in dbranches]
    dbranchinout = dict(zip(dbranches, (d_in_out, anode)))                            
#     
# splitters
#     inlet
#     outlet1
#     outlet2
Ejemplo n.º 3
0
def makeplantloop(iddfile, fname):
    """make the plant loop"""
    data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile)


    # in plantloop get:
    #     demand inlet, outlet, branchlist
    #     supply inlet, outlet, branchlist
    plantloops = loops.plantloopfields(data, commdct)
    plantloop = plantloops[0]
    #     
    # supply barnchlist
    #     branch1 -> inlet, outlet
    #     branch2 -> inlet, outlet
    #     branch3 -> inlet, outlet
    sbranchlist = plantloop[3]
    if sbranchlist.strip() != "":
        sbranches = loops.branchlist2branches(data, commdct, sbranchlist)
        s_in_out = [loops.branch_inlet_outlet(data, commdct, 
                                        sbranch) for sbranch in sbranches]
        sbranchinout = dict(zip(sbranches, s_in_out))                            

    dbranchlist = plantloop[6]
    if dbranchlist.strip() != "":
        dbranches = loops.branchlist2branches(data, commdct, dbranchlist)
        d_in_out = [loops.branch_inlet_outlet(data, commdct, 
                                        dbranch) for dbranch in dbranches]
        dbranchinout = dict(zip(dbranches, d_in_out))                            
    #     
    # splitters
    #     inlet
    #     outlet1
    #     outlet2
    splitters = loops.splitterfields(data, commdct)
    #     
    # mixer
    #     outlet
    #     inlet1
    #     inlet2

    mixers = loops.mixerfields(data, commdct)
    #     
    # supply barnchlist
    #     branch1 -> inlet, outlet
    #     branch2 -> inlet, outlet
    #     branch3 -> inlet, outlet
    #         
    # CONNET INLET OUTLETS
    edges = []
    # get all branches
    branchkey = "branch".upper()
    branches = data.dt[branchkey]
    branch_i_o = {}
    for br in branches:
        br_name = br[1]
        in_out = loops.branch_inlet_outlet(data, commdct, br_name)
        branch_i_o[br_name] = dict(zip(["inlet", "outlet"], in_out))
    for br_name, in_out in branch_i_o.items():
        edges.append((in_out["inlet"], br_name))
        edges.append((br_name, in_out["outlet"]))



    # connect splitter to nodes
    for splitter in splitters:
        # splitter_inlet = inletbranch.node
        splittername = splitter[0]
        inletbranchname = splitter[1] 
        splitter_inlet = branch_i_o[inletbranchname]["outlet"]
        # edges = splitter_inlet -> splittername
        edges.append((splitter_inlet, splittername))
        # splitter_outlets = ouletbranches.nodes
        outletbranchnames = [br for br in splitter[2:]]
        splitter_outlets = [branch_i_o[br]["inlet"] for br in outletbranchnames]
        # edges = [splittername -> outlet for outlet in splitter_outlets]
        moreedges = [(splittername, outlet) for outlet in splitter_outlets]
        edges = edges + moreedges

    for mixer in mixers:
        # mixer_outlet = outletbranch.node
        mixername = mixer[0]
        outletbranchname = mixer[1] 
        mixer_outlet = branch_i_o[outletbranchname]["inlet"]
        # edges = mixername -> mixer_outlet
        edges.append((mixername, mixer_outlet))
        # mixer_inlets = inletbranches.nodes
        inletbranchnames = [br for br in mixer[2:]]
        mixer_inlets = [branch_i_o[br]["outlet"] for br in inletbranchnames]
        # edges = [mixername -> inlet for inlet in mixer_inlets]
        moreedges = [(inlet, mixername) for inlet in mixer_inlets]
        edges = edges + moreedges

    # connect demand and supply side
    for plantloop in plantloops:
        supplyinlet = plantloop[1]
        supplyoutlet = plantloop[2]
        demandinlet = plantloop[4]
        demandoutlet = plantloop[5]
        # edges = [supplyoutlet -> demandinlet, demandoutlet -> supplyinlet]
        moreedges = [(supplyoutlet, demandinlet), (demandoutlet, supplyinlet)]
        edges = edges + moreedges
    
    g=pydot.graph_from_edges(edges, directed=True) 
    return g