def test_createobject(): """py.test for createobject""" thedata = (("", "SimulationControl", None, """SIMULATIONCONTROL, , , , , ; """),# idftxt, objkey, objname, outtxt ("", "RunPeriodControl:SpecialDays", 'Christmas', """RUNPERIODCONTROL:SPECIALDAYS, Christmas, , , ; """),# idftxt, objkey, objname, outtxt ) for idftxt, objkey, objname, outtxt in thedata: objkey = objkey.upper() fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) result = eplus_functions.createobject(idfw, objkey, objname) data = idfw.idf fname = StringIO(outtxt) newdata, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) assert newdata.dt[objkey] == data.dt[objkey]
def test_splittermixerfieldlists(): """py.test for splittermixerfieldlists""" thedata = (("""Connector:Splitter, Hot_Water_Loop_HW_Supply_Splitter, Hot_Water_Loop_HW_Supply_Inlet_Branch, Hot_Water_Loop_HW_Supply_Bypass_Branch, Main_Boiler_HW_Branch; Connector:Splitter, Hot_Water_Loop_HW_Demand_Splitter, Hot_Water_Loop_HW_Demand_Inlet_Branch, SPACE1__1_Heating_Coil_HW_Branch, SPACE2__1_Heating_Coil_HW_Branch, SPACE3__1_Heating_Coil_HW_Branch, SPACE4__1_Heating_Coil_HW_Branch, SPACE5__1_Heating_Coil_HW_Branch, Hot_Water_Loop_HW_Demand_Bypass_Branch; """, 'Connector:Splitter', [[1,2,3,4],[1,2,3,4,5,6,7,8]]), # idftxt, objkey, fieldlists ) for idftxt, objkey, fieldlists in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) result = loops.splittermixerfieldlists(data, commdct, objkey) assert result == fieldlists
def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value iddfile = "../iddfiles/Energy+V6_0.idd" fname = args[0] iddfile = "../iddfiles/Energy+V6_0.idd" print "readingfile" data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile) print "constructing the loops" edges = makeairplantloop(data, commdct) edges = diagram.cleanedges(edges) print "making the diagram" g = diagram.makediagram(edges) dotname = '%s_c.dot' % (os.path.splitext(fname)[0]) pngname = '%s_c.png' % (os.path.splitext(fname)[0]) g.write(dotname) g.write_png(pngname)
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
def test_newname2references(): """py.test for newname2references""" # a zone name is changed. It is refered by lights and people. # test if the reference in lights and people also change fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) # - zonekey = 'zone'.upper() lightkey = 'lights'.upper() peoplekey = 'people'.upper() keys = [zonekey, lightkey, peoplekey] keys = keys + keys names = ['z1', 'l1', 'p1', 'z2', 'l2', 'p2'] for key, name in zip(keys, names): anobject = eplus_functions.makeanobject(data, theidd, commdct, key, objname="name") data.dt[key].append(anobject) data.dt[lightkey][0][2] = 'z1' data.dt[peoplekey][0][2] = 'z1' data.dt[lightkey][1][2] = 'z2' data.dt[peoplekey][1][2] = 'z2' oldname, newname = 'z1', 'zz1' # = data.dt[zonekey][0][1] = newname fieldid = 1 eplus_functions.newname2references(idfw, zonekey, fieldid, oldname, newname) assert data.dt[lightkey][0][2] == newname assert data.dt[peoplekey][0][2] == newname assert data.dt[lightkey][1][2] == 'z2' assert data.dt[peoplekey][1][2] == 'z2'
def test_getreferences(): """py.test for getreferences""" thedata = (("zone".upper(), 1, ['ZoneNames', 'OutFaceEnvNames', 'ZoneAndZoneListNames', 'AirflowNetworkNodeAndZoneNames'] ), # key, fieldid, refs ("FenestrationSurface:Detailed".upper(), 1, ['SubSurfNames', 'SurfAndSubSurfNames', 'AllHeatTranSurfNames', 'OutFaceEnvNames', 'AllHeatTranAngFacNames', 'RadGroupAndSurfNames', 'SurfGroupAndHTSurfNames', 'AllShadingAndHTSurfNames'] ), # key, fieldid, refs ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) for key, fieldid, refs in thedata: anobject = eplus_functions.makeanobject(data, theidd, commdct, key, objname="azone") data.dt[key].append(anobject) result = eplus_functions.getreferences(idfw, key, fieldid) assert result == refs
def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value print args fname, objkey, oldname, newname, newfname = args objkey = objkey.upper() iddfile = "../iddfiles/Energy+V6_0.idd" block,commlst,commdct=parse_idd.extractidddata(iddfile) theidd=eplusdata.idd(block,2) data, commdct = readidf.readdatacommdct(fname, iddfile=theidd, commdct=commdct) idd = eplus_functions.Idd(commdct, commlst, theidd, block) idfw = eplus_functions.IdfWrapper(data, idd) # --- eplus_functions.rename_name(idfw, key, oldname, newname) txt = `data` open(newfname, 'w').write(txt)
def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value iddfile = "../iddfiles/Energy+V6_0.idd" fname = args[0] newname = '%s_clean.idf' % (os.path.splitext(fname)[0]) block,commlst,commdct=parse_idd.extractidddata(iddfile) theidd=eplusdata.idd(block,2) data, commdct = readidf.readdatacommdct(fname, iddfile=theidd, commdct=commdct) txt = `data` open(newname, 'w').write(txt)
def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="]) except getopt.error, msg: raise Usage(msg) # option processing for option, value in opts: if option == "-v": verbose = True if option in ("-h", "--help"): raise Usage(help_message) if option in ("-o", "--output"): output = value infile, zonename, aduname, uunitname, outfile = args iddfile = "../iddfiles/Energy+V6_0.idd" block,commlst,commdct=parse_idd.extractidddata(iddfile) theidd=eplusdata.idd(block,2) data, commdct = readidf.readdatacommdct(infile, iddfile=theidd, commdct=commdct) idd = eplus_functions.Idd(commdct, commlst, theidd, block) idfw = eplus_functions.IdfWrapper(data, idd) print "%s | %s | %s" % (zonename, aduname, uunitname) adu2unctr(idfw, zonename, aduname, uunitname) data = idfw.idf txt = `data` open(outfile, 'w').write(txt)
def test_makeentireplantloop(): """py.test for makeentireplantloop""" thedata = ((""" branchname0 -> splitter -> branchname1, branchname2, branchname3 branchname1, branchname2, branchname3 -> mixer -> branchname4 """, """ dbranchname0 -> dsplitter -> dbranchname1, dbranchname2, dbranchname3 dbranchname1, dbranchname2, dbranchname3 -> dmixer -> dbranchname4 """, {'BRANCH': [['BRANCH', 'branchname0', '0', '', 'Pipe:Adiabatic', 'branchname0_pipe', 'plantloop_supply_inlet', 'branchname0_pipe_outlet', 'Bypass'], ['BRANCH', 'branchname1', '0', '', 'Pipe:Adiabatic', 'branchname1_pipe', 'branchname1_pipe_inlet', 'branchname1_pipe_outlet', 'Bypass'], ['BRANCH', 'branchname2', '0', '', 'Pipe:Adiabatic', 'branchname2_pipe', 'branchname2_pipe_inlet', 'branchname2_pipe_outlet', 'Bypass'], ['BRANCH', 'branchname3', '0', '', 'Pipe:Adiabatic', 'branchname3_pipe', 'branchname3_pipe_inlet', 'branchname3_pipe_outlet', 'Bypass'], ['BRANCH', 'branchname4', '0', '', 'Pipe:Adiabatic', 'branchname4_pipe', 'branchname4_pipe_inlet', 'plantloop_supply_outlet', 'Bypass'], ['BRANCH', 'dbranchname0', '0', '', 'Pipe:Adiabatic', 'dbranchname0_pipe', 'plantloop_demand_inlet', 'dbranchname0_pipe_outlet', 'Bypass'], ['BRANCH', 'dbranchname1', '0', '', 'Pipe:Adiabatic', 'dbranchname1_pipe', 'dbranchname1_pipe_inlet', 'dbranchname1_pipe_outlet', 'Bypass'], ['BRANCH', 'dbranchname2', '0', '', 'Pipe:Adiabatic', 'dbranchname2_pipe', 'dbranchname2_pipe_inlet', 'dbranchname2_pipe_outlet', 'Bypass'], ['BRANCH', 'dbranchname3', '0', '', 'Pipe:Adiabatic', 'dbranchname3_pipe', 'dbranchname3_pipe_inlet', 'dbranchname3_pipe_outlet', 'Bypass'], ['BRANCH', 'dbranchname4', '0', '', 'Pipe:Adiabatic', 'dbranchname4_pipe', 'dbranchname4_pipe_inlet', 'plantloop_demand_outlet', 'Bypass']], 'CONNECTORLIST': [['CONNECTORLIST', 'plantloop_supply_Clist', 'Connector:Splitter', 'splitter', 'Connector:Mixer', 'mixer'], ['CONNECTORLIST', 'plantloop_demand_Clist', 'Connector:Splitter', 'dsplitter', 'Connector:Mixer', 'dmixer']], 'CONNECTOR:MIXER': [['CONNECTOR:MIXER', 'mixer', 'branchname4', 'branchname1', 'branchname2', 'branchname3'], ['CONNECTOR:MIXER', 'dmixer', 'dbranchname4', 'dbranchname1', 'dbranchname2', 'dbranchname3']], 'PLANTLOOP': [['PLANTLOOP', 'plantloop', 'Water', '', '', '', '', '', '0.0', 'Autocalculate', 'plantloop_supply_inlet', 'plantloop_supply_outlet', 'plantloop_supply_Blist', 'plantloop_supply_Clist', 'plantloop_demand_inlet', 'plantloop_demand_outlet', 'plantloop_demand_Blist', 'plantloop_demand_Clist', 'Sequential', '', 'SingleSetpoint', 'None', 'None']], 'BRANCHLIST': [['BRANCHLIST', 'plantloop_supply_Blist', 'branchname1', 'branchname2', 'branchname3'], ['BRANCHLIST', 'plantloop_demand_Blist', 'dbranchname1', 'dbranchname2', 'dbranchname3']], 'CONNECTOR:SPLITTER': [['CONNECTOR:SPLITTER', 'splitter', 'branchname0', 'branchname1', 'branchname2', 'branchname3'], ['CONNECTOR:SPLITTER', 'dsplitter', 'dbranchname0', 'dbranchname1', 'dbranchname2', 'dbranchname3']]}), # supplystr, demandstr, loopdata ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) for supplystr, demandstr, loopdata in thedata: sloop = s_entireplantloop.HalfLoop(supplystr, "supply","plantloop") dloop = s_entireplantloop.HalfLoop(demandstr, "demand",'plantloop') # plantloop = loopdata[0] # branch = loopdata[1] s_entireplantloop.makeentireplantloop(data, commdct, sloop, dloop, 'plantloop') # objkey = 'plantloop'.upper() # rplantloop = data.dt[objkey] akeys = [k for k in data.dt.keys() if len(data.dt[k]) > 0] result = {} for akey in akeys: result[akey] = data.dt[akey] assert result == loopdata
def test_getReferenceObjectList(): """py.test for getReferenceObjectList""" thedata = (("zone".upper(), ['ZoneNames', 'OutFaceEnvNames', 'ZoneAndZoneListNames', 'AirflowNetworkNodeAndZoneNames'], [('SIZING:ZONE', 1), ('ZONEHVAC:EQUIPMENTCONNECTIONS', 1), ('BUILDINGSURFACE:DETAILED', 4), ('FENESTRATIONSURFACE:DETAILED', 5), ('BUILDINGSURFACE:DETAILED', 6), ('LIGHTS', 2), ('PEOPLE', 2), ('ZONEINFILTRATION:DESIGNFLOWRATE', 2), ('ELECTRICEQUIPMENT', 2), ('ZONECONTROL:THERMOSTAT', 2)] ), # key, refs, reflist ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) for key, refs, reflist in thedata: anobject = eplus_functions.makeanobject(data, theidd, commdct, key, objname="azone") data.dt[key].append(anobject) for akey, fieldid, in reflist: anobject = eplus_functions.makeanobject(data, theidd, commdct, akey, objname="azone") data.dt[akey].append(anobject) result = eplus_functions.getReferenceObjectList(idfw, refs) assert result == reflist
def test_extractfields(): """py.test for extractfields""" thedata = (("""PlantLoop, Hot_Water_Loop_Hot_Water_Loop, Water, Hot_Water_Loop_Operation, Hot Water Loop HW Supply Outlet, 100, 10, autosize, 0, autosize, Hot Water Loop HW Supply Inlet, Hot Water Loop HW Supply Outlet, Hot_Water_Loop_HW_Supply_Side_Branches, Hot_Water_Loop_HW_Supply_Side_Connectors, Hot Water Loop HW Demand Inlet, Hot Water Loop HW Demand Outlet, Hot_Water_Loop_HW_Demand_Side_Branches, Hot_Water_Loop_HW_Demand_Side_Connectors, Sequential, , SingleSetpoint; PlantLoop, Hot_Water_Loop_Hot_Water_Loop1, Water, Hot_Water_Loop_Operation, Hot Water Loop HW Supply Outlet, 100, 10, autosize, 0, autosize, Hot Water Loop HW Supply Inlet, Hot Water Loop HW Supply Outlet, Hot_Water_Loop_HW_Supply_Side_Branches, Hot_Water_Loop_HW_Supply_Side_Connectors, Hot Water Loop HW Demand Inlet, Hot Water Loop HW Demand Outlet, Hot_Water_Loop_HW_Demand_Side_Branches, Hot_Water_Loop_HW_Demand_Side_Connectors, Sequential, , SingleSetpoint; """, 'plantloop'.upper(), [['Name', 'Plant Side Inlet Node Name', 'Plant Side Outlet Node Name', 'Plant Side Branch List Name', 'Demand Side Inlet Node Name', 'Demand Side Outlet Node Name', 'Demand Side Branch List Name', ]] * 2, [[ 1, 'Plant Side Inlet Node Name', 11, 'Plant Side Branch List Name', 'Demand Side Inlet Node Name', 'Demand Side Outlet Node Name', 'Demand Side Branch List Name', ]] * 2, [['Hot_Water_Loop_Hot_Water_Loop', 'Hot Water Loop HW Supply Inlet', 'Hot Water Loop HW Supply Outlet', 'Hot_Water_Loop_HW_Supply_Side_Branches', 'Hot Water Loop HW Demand Inlet', 'Hot Water Loop HW Demand Outlet', 'Hot_Water_Loop_HW_Demand_Side_Branches'], ['Hot_Water_Loop_Hot_Water_Loop1', 'Hot Water Loop HW Supply Inlet', 'Hot Water Loop HW Supply Outlet', 'Hot_Water_Loop_HW_Supply_Side_Branches', 'Hot Water Loop HW Demand Inlet', 'Hot Water Loop HW Demand Outlet', 'Hot_Water_Loop_HW_Demand_Side_Branches']] ), # idftxt, objkey, fieldlist1, fieldlist2, fieldcontents ) for idftxt, objkey, fieldlist1, fieldlist2, fieldcontents in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) result = loops.extractfields(data, commdct, objkey, fieldlist1) assert result == fieldcontents # test with fieldlist2 result = loops.extractfields(data, commdct, objkey, fieldlist2) assert result == fieldcontents # also test plantloopfields, since the test data is for plantloop result = loops.plantloopfields(data, commdct) assert result == fieldcontents
def test_makeadistu_inlets(): """py.test for makeadistu_inlets""" adistuinlets = {'AirTerminal:SingleDuct:VAV:HeatAndCool:NoReheat': ['Air Inlet Node Name'], 'AirTerminal:DualDuct:VAV': ['Hot Air Inlet Node Name', 'Cold Air Inlet Node Name'], 'AirTerminal:SingleDuct:ParallelPIU:Reheat': ['Supply Air Inlet Node Name', 'Secondary Air Inlet Node Name', 'Reheat Coil Air Inlet Node Name'], 'AirTerminal:SingleDuct:VAV:Reheat:VariableSpeedFan': ['Air Inlet Node Name', 'Heating Coil Air Inlet Node Name'], 'AirTerminal:SingleDuct:VAV:Reheat': ['Air Inlet Node Name'], 'AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat': ['Air Inlet Node Name'], 'AirTerminal:SingleDuct:VAV:NoReheat': ['Air Inlet Node Name'], 'AirTerminal:SingleDuct:ConstantVolume:Reheat': ['Air Inlet Node Name'], 'AirTerminal:SingleDuct:ConstantVolume:FourPipeInduction': ['Supply Air Inlet Node Name', 'Induced Air Inlet Node Name'], 'AirTerminal:SingleDuct:ConstantVolume:CooledBeam': ['Supply Air Inlet Node Name'], 'AirTerminal:SingleDuct:SeriesPIU:Reheat': ['Supply Air Inlet Node Name', 'Secondary Air Inlet Node Name', 'Reheat Coil Air Inlet Node Name'], 'AirTerminal:DualDuct:ConstantVolume': ['Hot Air Inlet Node Name', 'Cold Air Inlet Node Name']} fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) result = loops.makeadistu_inlets(data, commdct) assert result == adistuinlets
def test_fieldvalue(): """py.test for fieldvalue""" thedata = (("""RunPeriodControl:SpecialDays, Christmas, December 25, 1, Holiday; """, "RunPeriodControl:SpecialDays", "Christmas", 'Start Date', '12/25', """RunPeriodControl:SpecialDays, Christmas, 12/25, 1, Holiday; """), # idftxt, objkey, objname, field, value, outtxt ("""SimulationControl, Yes, Yes, Yes, Yes, Yes; """, "SimulationControl", None, 'Do Zone Sizing Calculation', 'No', """SimulationControl, No, Yes, Yes, Yes, Yes; """), # idftxt, objkey, objname, field, value, outtxt ) for idftxt, objkey, objname, field, value, outtxt in thedata: objkey = objkey.upper() fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) result = eplus_functions.fieldvalue(idfw, objkey, objname, field, value) data = idfw.idf fname = StringIO(outtxt) newdata, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) assert newdata.dt[objkey] == data.dt[objkey]
def makesavebranchdiagrams(fname, iddfile): """make and save branch diagrams""" data, commdct = readidf.readdatacommdct(fname, iddfile=iddfile) allgraphs = makebranchgrapsh(data, commdct) newfolder = makefolder(fname) objkey = "BRANCH" branchnames = [br[1] for br in data.dt[objkey]] for branchname, gr in zip(branchnames, allgraphs): gr.write('%s/%s.dot' % (newfolder, branchname, )) gr.write_png('%s/%s.png' % (newfolder, branchname, ))
def test_getfieldindex(): """py.test for getfieldindex""" thedata = (( "AirTerminal:SingleDuct:VAV:Reheat".upper(), "Air Inlet Node Name", 4),# objkey, fname, theindex ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) for objkey, fname, theindex in thedata: result = loops.getfieldindex(data, commdct, objkey, fname) assert result == theindex
def test_getextensiblesize(): """py.test for getextensiblesize""" thedata = (("branchlist".upper(), 1), # objkey, extensiblesize ("branch".upper(), 5), # objkey, extensiblesize ("SimulationControl".upper(), None), # objkey, extensiblesize ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd for objkey, extensiblesize in thedata: result = eplus_functions.getextensiblesize(data, commdct, objkey) assert result == extensiblesize
def test_getobjfieldnames(): """py.test for getobjfieldnames""" thedata = (("SHADOWCALCULATION", [None, 'Calculation Frequency', 'Maximum Figures in Shadow Overlap Calculations'] ), # objkey, fields ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) for objkey, fields in thedata: result = eplus_functions.getobjfieldnames(data, commdct, objkey) assert result == fields
def test_objectcount(): """py.test for objectcount""" thedata = (("""Output:Variable,*, Time Heating Setpoint Not Met While Occupied,hourly; Output:Variable,*,Time Cooling Setpoint Not Met While Occupied,hourly; Output:Variable,*,VAV Terminal Damper Position,hourly; Output:VariableDictionary,Regular; Output:Surfaces:Drawing,dxf; """, "Output:Variable", 3), # idftxt, key, thecount ) for idftxt, key, thecount in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) result = loops.objectcount(data, key) assert result == thecount
def test_branch_inlet_outlet(): """py.test for branch_inlet_outlet""" thedata = (("""Branch, SPACE1__1_Cooling_Coil_ChW_Branch, !- Name , !- Maximum Flow Rate {m3/s} , !- Pressure Drop Curve Name Coil:Cooling:Water, !- Component 1 Object Type SPACE1__1_Cooling_Coil, !- Component 1 Name SPACE1-1 Cooling Coil ChW Inlet, !- Component 1 Inlet Node Name SPACE1-1 Cooling Coil ChW Outlet, !- Component 1 Outlet Node Name Active; !- Component 1 Branch Control Type Branch, VAV WITH REHEAT Air Loop Main Branch, !- Name AUTOSIZE, !- Maximum Flow Rate {m3/s} , !- Pressure Drop Curve Name AirLoopHVAC:OutdoorAirSystem, !- Component 1 Object Type VAV WITH REHEAT_OA, !- Component 1 Name VAV WITH REHEAT Supply Equipment Inlet Node, !- Component 1 Inlet Node Name VAV WITH REHEAT_OA-VAV WITH REHEAT_CoolCNode, !- Component 1 Outlet Node Name PASSIVE, !- Component 1 Branch Control Type Coil:Cooling:Water, !- Component 2 Object Type VAV WITH REHEAT_CoolC, !- Component 2 Name VAV WITH REHEAT_OA-VAV WITH REHEAT_CoolCNode, !- Component 2 Inlet Node Name VAV WITH REHEAT_CoolC-VAV WITH REHEAT_HeatCNode, !- Component 2 Outlet Node Name PASSIVE, !- Component 2 Branch Control Type Coil:Heating:Water, !- Component 3 Object Type VAV WITH REHEAT_HeatC, !- Component 3 Name VAV WITH REHEAT_CoolC-VAV WITH REHEAT_HeatCNode, !- Component 3 Inlet Node Name VAV WITH REHEAT_HeatC-VAV WITH REHEAT FanNode, !- Component 3 Outlet Node Name PASSIVE, !- Component 3 Branch Control Type Fan:VariableVolume, !- Component 4 Object Type VAV WITH REHEAT Fan, !- Component 4 Name VAV WITH REHEAT_HeatC-VAV WITH REHEAT FanNode, !- Component 4 Inlet Node Name VAV WITH REHEAT Supply Equipment Outlet Node, !- Component 4 Outlet Node Name ACTIVE; !- Component 4 Branch Control Type """, 'VAV WITH REHEAT Air Loop Main Branch', ['VAV WITH REHEAT Supply Equipment Inlet Node', 'VAV WITH REHEAT Supply Equipment Outlet Node']), # idftxt, branchname, inletoutlet ) for idftxt, branchname, inletoutlet in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) result = loops.branch_inlet_outlet(data, commdct, branchname) assert result == inletoutlet
def test_getobject(): """py.test for getobject""" thedata = (({"PLANTLOOP":[["PLANTLOOP", "ploop1",""], ["PLANTLOOP", "ploop2", "yahoo"]], "BRANCH":[]}, "PLANTLOOP", "ploop2", ["PLANTLOOP", "ploop2", "yahoo"]), # data_dt, objkey, objname, obj ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd for data_dt, objkey, objname, obj in thedata: data.dt = data_dt result = eplus_functions.getobject(data, commdct, objkey, objname) assert result == obj
def test_getchoiceOFField(): """py.test for getchoiceOFField""" thedata = (("""Building, Building, 30., City, 0.04, 0.4, FullExterior, 25;""", "Building".upper(), 0, 3, ["Country", "Suburbs", "City", "Ocean", "Urban"]), # idftxt, objkey, objid, fieldid, choicelist ("""Building, Building, 30., City, 0.04, 0.4, FullExterior, 25;""", "Building".upper(), 0, 1, []), # idftxt, objkey, objid, fieldid, choicelist ) for idftxt, objkey, objid, fieldid, choicelist in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) result = eplus_functions.getchoiceOFField(idfw, objkey, objid, fieldid) assert result == choicelist
def test_getfieldindex(): """py.test for getfieldindex""" thedata = (("plantloop".upper(), "Plant Side Inlet Node Name", 10), # objkey, fielddescp, findex ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd for objkey, fielddescp, findex in thedata: result = eplus_functions.getfieldindex(data, commdct, objkey, fielddescp) assert result == findex thedata = (("OUTPUT:VARIABLE".upper(), "Name", eplus_functions.NoSuchFieldError), # objkey, fielddescp, excep ) for objkey, fielddescp, excep in thedata: with pytest.raises(excep): eplus_functions.getfieldindex(data, commdct, objkey, fielddescp)
def test_makeanobject(): """py.test for makeanobject""" thedata = (('LEAD INPUT', "aname", ['LEAD INPUT']), # objkey, objname, anobject ('PLANTLOOP', "aname", ['PLANTLOOP', 'aname', 'Water', '', '', '', '', '', '0.0', 'Autocalculate', '', '', '', '', '', '', '', '', 'Sequential', '', 'SingleSetpoint', 'None', 'None']), # more complex object ('BRANCH', "aname", ['BRANCH', 'aname', '0', '', '', '', '', '', ''] ), # for an extensible object ) fname = StringIO("") data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd for objkey, objname, anobject in thedata: result = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) assert result == anobject
def test_rename_name(): """py.test for rename_name""" thedata = (("""Zone,SPACE1__1,0,0,0,0,1,1,2.438400269,239.247360229;People,SPACE1__1_People_1,SPACE1__1,OCCUPY__1,people,11,,,0.3,,ActSchd;""", "ZONE", "SPACE1__1", "LOBBY" , """Zone,LOBBY,0,0,0,0,1,1,2.438400269,239.247360229;People,SPACE1__1_People_1,LOBBY,OCCUPY__1,people,11,,,0.3,,ActSchd;""" ),# idftxt, objkey, oldname, newname, newidf ) for idftxt, objkey, oldname, newname, newidf in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddfile=iddV6_0.theidd, commdct=iddV6_0.commdct) idd = eplus_functions.Idd(iddV6_0.commdct, iddV6_0.commlst, iddV6_0.theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) result = eplus_functions.rename_name(idfw, objkey, oldname, newname) data = idfw.idf txt = `data` lst = txt.split() rtxt = ''.join(lst) print rtxt print newidf assert rtxt == newidf
iddfile = "../iddfiles/Energy+V6_0.idd" # fname = "/Applications/EnergyPlus-6-0-0/Examples/DualDuctConstVolGasHC.idf" # fname = "../idffiles/a.idf" # fname = "/Volumes/Server/Active_Projects/stanttecE+Conssulting2/3_Simulation/2_Energy/EnergyPlus/fromMatt/Proposed110614exp.idf" # fname = "/Volumes/Server/Active_Projects/stanttecE+Conssulting2/3_Simulation/2_Energy/EnergyPlus/workingfiles/5ZoneAirCooled.idf" # fname = "/Volumes/Server/Active_Projects/LBNL_UHM/3_Simulation/2_Energy/Energyplus3/airflow/air6.expidf" # fname = "/Volumes/Server/Staff/Santosh/transfer/asul/05_Baseline_06.idf" fname = "/Applications/EnergyPlus-6-0-0/Examples/DualDuctConstVolGasHC.idf" # fname = "../idffiles/HVACTemplate-5ZoneVAVFanPowered.idf" # outname = "../idffiles/.idf" fname = "../idffiles/CoolingTower.idf" fname = "../idffiles/a.idf" fname = "../idffiles/5ZoneSupRetPlenRAB.idf" # for supply plenum # fname = "a.idf" 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] anode = "epnode" endnode = "EndNode" # # supply barnchlist # branch1 -> inlet, outlet # branch2 -> inlet, outlet # branch3 -> inlet, outlet sbranchlist = plantloop[3]
# #-------------------------- # fname = "../idffiles/doas2.idf" # outname = "../idffiles/doas2_1.idf" # aduname = "ZN_1_FLR_2_SEC_1 ATU" # uunitname = "ZN_1_FLR_2_SEC_1 uncontrolled" # zonename = "ZN_1_FLR_2_SEC_1" # #-------------------------- #-------------------------- fname = "../idffiles/doas2_1.idf" zonename = "ZN_1_FLR_2_SEC_2" aduname = "ZN_1_FLR_2_SEC_2 ATU" uunitname = "ZN_1_FLR_2_SEC_2 uncontrolled" outname = "../idffiles/doas2_2.idf" #-------------------------- data, commdct = readidf.readdatacommdct(fname, iddfile=theidd, commdct=commdct) idd = eplus_functions.Idd(commdct, commlst, theidd, block) idfw = eplus_functions.IdfWrapper(data, idd) # from ADU grab objtype and objname # remove ADU # - # in ZoneHVAC:AirDistributionUnit: # get name, objtype, objname objkey = "ZoneHVAC:AirDistributionUnit".upper() singlefields = ["Name", "Air Terminal Object Type", "Air Terminal Name"] repeatfields = [] fieldlist = singlefields + repeatfields fieldlists = [fieldlist] * loops.objectcount(data, objkey) adus = loops.extractfields(data, commdct, objkey, fieldlists)
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
import sys sys.path.append("../EPlusInputcode") from EPlusCode.EPlusInterfaceFunctions import readidf # # just read a file and dump the text out. iddfile = "../iddfiles/Energy+V6_0.idd" fname = "../idffiles/a.idf" data1, commdct1 = readidf.readdatacommdct(fname, iddfile=iddfile) txt1 = ` data1 ` # print txt1[:100] iddfile = "../iddfiles/Energy+V6_0.idd" iddfobject = open(iddfile, "r") fname = "../idffiles/a.idf" fnamefobject = open(fname, "r") data2, commdct2 = readidf.readdatacommdct(fnamefobject, iddfile=iddfile) txt2 = ` data2 ` # print txt2[:100] print "txt1 == txt2" print txt1 == txt2 iddfile = "../iddfiles/Energy+V6_0.idd" iddfobject = open(iddfile, "r") fname = "../idffiles/a.idf" fnamefobject = open(fname, "r") data3, commdct3 = readidf.readdatacommdct(fname, iddfile=iddfobject) txt3 = ` data3 `
def test_getobjlist(): """py.test for getobjlist""" thedata = (("""Zone, PLENUM__1, 0, 0, 0, 0, 1, 1, 0.609600067, 283.2; Zone, SPACE1__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE2__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE3__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE4__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE5__1, 0, 0, 0, 0, 1, 1, 2.438400269, 447.682556152; Lights, SPACE1__1_Lights_1, SPACE1__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE2__1_Lights_1, SPACE2__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE3__1_Lights_1, SPACE3__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE4__1_Lights_1, SPACE4__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE5__1_Lights_1, SPACE5__1, LIGHTS__1, LightingLevel, 2964, , , 0, 0.59, 0.2, 0, GeneralLights; """, 'lights'.upper(), 0, 2, ["PLENUM__1", "SPACE1__1", "SPACE2__1", "SPACE3__1", "SPACE4__1", "SPACE5__1"] ), # idftxt, objkey, objid, fieldid, theobjlist ("""Zone, PLENUM__1, 0, 0, 0, 0, 1, 1, 0.609600067, 283.2; Zone, SPACE1__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE2__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE3__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE4__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE5__1, 0, 0, 0, 0, 1, 1, 2.438400269, 447.682556152; Lights, SPACE1__1_Lights_1, SPACE1__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE2__1_Lights_1, SPACE2__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE3__1_Lights_1, SPACE3__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE4__1_Lights_1, SPACE4__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE5__1_Lights_1, SPACE5__1, LIGHTS__1, LightingLevel, 2964, , , 0, 0.59, 0.2, 0, GeneralLights; """, 'lights'.upper(), 0, 1, [] ), # idftxt, objkey, objid, fieldid, theobjlist ("""Zone, PLENUM__1, 0, 0, 0, 0, 1, 1, 0.609600067, 283.2; Zone, SPACE1__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE2__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE3__1, 0, 0, 0, 0, 1, 1, 2.438400269, 239.247360229; Zone, SPACE4__1, 0, 0, 0, 0, 1, 1, 2.438400269, 103.311355591; Zone, SPACE5__1, 0, 0, 0, 0, 1, 1, 2.438400269, 447.682556152; ZoneList, azonelist, SPACE1__1, SPACE2__1; Lights, SPACE1__1_Lights_1, SPACE1__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE2__1_Lights_1, SPACE2__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE3__1_Lights_1, SPACE3__1, LIGHTS__1, LightingLevel, 1584, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE4__1_Lights_1, SPACE4__1, LIGHTS__1, LightingLevel, 684, , , 0, 0.59, 0.2, 0, GeneralLights; Lights, SPACE5__1_Lights_1, SPACE5__1, LIGHTS__1, LightingLevel, 2964, , , 0, 0.59, 0.2, 0, GeneralLights; """, 'lights'.upper(), 0, 2, ["PLENUM__1", "SPACE1__1", "SPACE2__1", "SPACE3__1", "SPACE4__1", "SPACE5__1", "azonelist"] ), # list comes from zone and zonelist # idftxt, objkey, objid, fieldid, theobjlist ) # TODO : test if it is not an object list, test for zone and zonelist for idftxt, objkey, objid, fieldid, theobjlist in thedata: fname = StringIO(idftxt) data, commdct = readidf.readdatacommdct(fname, iddV6_0.theidd, iddV6_0.commdct) theidd = iddV6_0.theidd idd = eplus_functions.Idd(commdct, iddV6_0.commlst, theidd, iddV6_0.block) idfw = eplus_functions.IdfWrapper(data, idd) dt = idfw.idf.dt result = eplus_functions.getobjlistOfField(idfw, objkey, objid, fieldid) assert result == theobjlist