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_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 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 makemixer(data, commdct, aloop): """make the mixer for the loop""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - # make mixer objkey = "Connector:Mixer".upper() objname = aloop.themixer mixer = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # add nodes to mixer fields = idd_fields.Connector_Mixer() mixer[indx(objkey, fields.outlet)] = aloop.lastbranch mixer[indx(objkey, fields.firstinlet)] = aloop.inbranches[0] for branchname in aloop.inbranches[1:]: mixer.append(branchname) # append the object data.dt[objkey].append(mixer)
def makesplitter(data, commdct, aloop): """make a splitter for the loop""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - # make splitter objkey = "Connector:Splitter".upper() objname = aloop.thesplitter splitter = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # add nodes to splitter fields = idd_fields.Connector_Splitter() splitter[indx(objkey, fields.inlet)] = aloop.firstbranch splitter[indx(objkey, fields.firstoutlet)] = aloop.outbranches[0] for branchname in aloop.outbranches[1:]: splitter.append(branchname) # append the object data.dt[objkey].append(splitter)
def pipebranch(branchname): """make a pipebranch""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - objkey = "branch".upper() objname = branchname branch = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # put a pipe object fields = idd_fields.Branch() branch[indx(objkey, fields.componenttype1)] = "Pipe:Adiabatic" pipename = "%s_%s" % (objname, "pipe") branch[indx(objkey, fields.component1)] = pipename branch[indx(objkey, fields.inlet1)] = "%s_%s" % (pipename, "inlet") branch[indx(objkey, fields.outlet1)] = "%s_%s" % (pipename, "outlet") branch[indx(objkey, fields.controltype1)] = fields.bypass return branch
def makeconnectorlist(data, commdct, aloop): """docstring for makeconnectorlist""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - # connectorlist objkey = "ConnectorList".upper() objname = aloop.connectorlistN connectorlist = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # add connectors to connectorlist fields = idd_fields.ConnectorList() connectorlist[indx(objkey, fields.connectortype1)] = fields.splitter connectorlist[indx(objkey, fields.connector1)] = aloop.thesplitter connectorlist[indx(objkey, fields.connectortype2)] = fields.mixer connectorlist[indx(objkey, fields.connector2)] = aloop.themixer # append the object data.dt[objkey].append(connectorlist)
def makeplantloop(data, commdct, sloop, dloop, loopname): """make the plantloop""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - objkey = "plantloop".upper() objname = loopname plantloop = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # add the fields. fields = idd_fields.PlantLoop() plantloop[indx(objkey, fields.plantinlet)] = sloop.plantinlet plantloop[indx(objkey, fields.plantoutlet)] = sloop.plantoutlet plantloop[indx(objkey, fields.demandinlet)] = dloop.plantinlet plantloop[indx(objkey, fields.demandoutlet)] = dloop.plantoutlet plantloop[indx(objkey, fields.plantbranchlist)] = sloop.branchlistN plantloop[indx(objkey, fields.plantconnectorlist)] = sloop.connectorlistN plantloop[indx(objkey, fields.demandbranchlist)] = dloop.branchlistN plantloop[indx(objkey, fields.demandconnectorlist)] = dloop.connectorlistN # append the object data.dt[objkey].append(plantloop)
def makebranchlist(data, commdct, aloop): """make the baranchlists""" # - def indx(objkey, fielddesc): return eplus_functions.getfieldindex(data, commdct, objkey, fielddesc) # - # branchlist objkey = "branchlist".upper() objname = aloop.branchlistN branchlist = eplus_functions.makeanobject(data, theidd, commdct, objkey, objname) # add branches to branch list fields = idd_fields.BranchList() ix = eplus_functions.getextensibleposition(data, commdct, objkey) extlength = eplus_functions.getextensiblesize(data, commdct, objkey) for i in range(extlength): branchlist.pop(-1) zlist = zip(range(ix, ix + len(aloop.outbranches)), aloop.outbranches) for i, branch in zlist: branchlist.append(branch) # append the object data.dt[objkey].append(branchlist)