本文整理汇总了Python中eppy.modeleditor.IDF.getobject方法的典型用法代码示例。如果您正苦于以下问题:Python IDF.getobject方法的具体用法?Python IDF.getobject怎么用?Python IDF.getobject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eppy.modeleditor.IDF
的用法示例。
在下文中一共展示了IDF.getobject方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_initread
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_initread():
"""Test for IDF.initread() with filename in unicode and as python str.
"""
# setup
idf = IDF()
idf.initreadtxt(idfsnippet)
idf.saveas('tmp.idf')
# test fname as unicode
fname = 'tmp.idf'
assert isinstance(fname, string_types)
idf = IDF()
idf.initread(fname)
assert idf.getobject('BUILDING', 'Building')
# test fname as str
fname = str('tmp.idf')
assert isinstance(fname, string_types)
idf = IDF()
idf.initread(fname)
assert idf.getobject('BUILDING', 'Building')
# test that a nonexistent file raises an IOError
fname = "notarealfilename.notreal"
idf = IDF()
try:
idf.initread(fname)
assert False # shouldn't reach here
except IOError:
pass
# teardown
os.remove('tmp.idf')
示例2: test_get_referenced_object
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_get_referenced_object(self):
"""py.test for get_referenced_object"""
idf = IDF()
idf.initnew('test.idf')
idf.newidfobject('VERSION') # does not have a field "Name"
# construction material
construction = idf.newidfobject('CONSTRUCTION', 'construction')
construction.Outside_Layer = 'TestMaterial'
expected = idf.newidfobject('MATERIAL', 'TestMaterial')
fetched = idf.getobject('MATERIAL', 'TestMaterial')
assert fetched == expected
material = construction.get_referenced_object('Outside_Layer')
assert material == expected
# window material
glazing_group = idf.newidfobject(
'WINDOWMATERIAL:GLAZINGGROUP:THERMOCHROMIC', 'glazing_group')
glazing_group.Window_Material_Glazing_Name_1 = 'TestWindowMaterial'
expected = idf.newidfobject(
'WINDOWMATERIAL:GLAZING', 'TestWindowMaterial') # has several \references
fetched = idf.getobject('WINDOWMATERIAL:GLAZING', 'TestWindowMaterial')
assert fetched == expected
material = glazing_group.get_referenced_object(
'Window_Material_Glazing_Name_1')
assert material == expected
示例3: test_zonearea_zonevolume
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_zonearea_zonevolume():
"""py.test for zonearea and zonevolume"""
idftxt = "Zone, 473222, 0.0, 0.0, 0.0, 0.0, , 1; BuildingSurface:Detailed, F7289B, Floor, Exterior Floor, 473222, Ground, , NoSun, NoWind, , 4, 2.23, 2.56, 0.0, 2.23, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.56, 0.0; BuildingSurface:Detailed, F3659B, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.56, 1.49, 2.23, 2.56, 0.0, 0.0, 2.56, 0.0, 0.0, 2.56, 1.49; BuildingSurface:Detailed, 46C6C9, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 0.0, 1.49, 2.23, 0.0, 0.0, 2.23, 1.02548139464, 0.0, 2.23, 1.02548139464, 1.49; BuildingSurface:Detailed, 4287DD, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 2.56, 1.49, 0.0, 2.56, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.49; BuildingSurface:Detailed, 570C2E, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 0.0, 1.49, 0.0, 0.0, 0.0, 2.23, 0.0, 0.0, 2.23, 0.0, 1.49; BuildingSurface:Detailed, BAEA99, Roof, Exterior Roof, 473222, Outdoors, , SunExposed, WindExposed, , 4, 0.0, 2.56, 1.49, 0.0, 0.0, 1.49, 2.23, 0.0, 1.49, 2.23, 2.56, 1.49; BuildingSurface:Detailed, C879FE, Floor, Exterior Floor, 473222, Ground, , NoSun, NoWind, , 4, 3.22, 2.52548139464, 0.0, 3.22, 1.02548139464, 0.0, 2.23, 1.02548139464, 0.0, 2.23, 2.52548139464, 0.0; BuildingSurface:Detailed, 25B601, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 2.23, 2.52548139464, 0.0, 2.23, 2.52548139464, 1.49; BuildingSurface:Detailed, F5EADC, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 1.02548139464, 1.49, 2.23, 1.02548139464, 0.0, 3.22, 1.02548139464, 0.0, 3.22, 1.02548139464, 1.49; BuildingSurface:Detailed, D0AABE, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 3.22, 1.02548139464, 1.49, 3.22, 1.02548139464, 0.0, 3.22, 2.52548139464, 0.0, 3.22, 2.52548139464, 1.49; BuildingSurface:Detailed, B0EA02, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 3.22, 2.52548139464, 1.49, 3.22, 2.52548139464, 0.0, 2.23, 2.52548139464, 0.0, 2.23, 2.52548139464, 1.49; BuildingSurface:Detailed, E6DF3B, Roof, Exterior Roof, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.52548139464, 1.49, 2.23, 1.02548139464, 1.49, 3.22, 1.02548139464, 1.49, 3.22, 2.52548139464, 1.49; BuildingSurface:Detailed, 4F8681, Wall, Exterior Wall, 473222, Outdoors, , SunExposed, WindExposed, , 4, 2.23, 2.52548139464, 1.49, 2.23, 2.52548139464, 0.0, 2.23, 2.56, 0.0, 2.23, 2.56, 1.49; "
idf = IDF(StringIO(idftxt))
result = modeleditor.zonearea(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zonearea_floor(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zonearea_roofceiling(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zone_floor2roofheight(idf, '473222')
assert almostequal(result, 1.49)
result = modeleditor.zoneheight(idf, '473222')
assert almostequal(result, 1.49)
result = modeleditor.zone_floor2roofheight(idf, '473222')
assert almostequal(result, 1.49)
result = modeleditor.zonevolume(idf, '473222')
assert almostequal(result, 10.718762)
# remove floor
zone = idf.getobject('ZONE', '473222')
surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()]
zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
floors = [s for s in zone_surfs if s.Surface_Type.upper() == 'FLOOR']
for floor in floors:
idf.removeidfobject(floor)
result = modeleditor.zonearea_floor(idf, '473222')
assert almostequal(result, 0)
result = modeleditor.zonearea_roofceiling(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zonearea(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zoneheight(idf, '473222')
assert almostequal(result, 1.49)
result = modeleditor.zonevolume(idf, '473222')
assert almostequal(result, 10.718762)
# reload idf and remove roof/ceiling
idf = IDF(StringIO(idftxt))
zone = idf.getobject('ZONE', '473222')
surfs = idf.idfobjects['BuildingSurface:Detailed'.upper()]
zone_surfs = [s for s in surfs if s.Zone_Name == zone.Name]
roofs = [s for s in zone_surfs if s.Surface_Type.upper() == 'ROOF']
ceilings = [s for s in zone_surfs if s.Surface_Type.upper() == 'CEILING']
topsurfaces = roofs + ceilings
for surf in topsurfaces:
idf.removeidfobject(surf)
result = modeleditor.zonearea_roofceiling(idf, '473222')
assert almostequal(result, 0)
result = modeleditor.zonearea(idf, '473222')
assert almostequal(result, 7.1938)
result = modeleditor.zoneheight(idf, '473222')
assert almostequal(result, 1.49)
result = modeleditor.zonevolume(idf, '473222')
assert almostequal(result, 10.718762)
示例4: test_makeductbranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_makeductbranch():
"""py.test for makeductbranch"""
tdata = ((
'd_branch',
[
'BRANCH',
'd_branch',
'0',
'',
'duct',
'd_branch_duct',
'd_branch_duct_inlet',
'd_branch_duct_outlet',
'Bypass'],
[
'DUCT',
'd_branch_duct',
'd_branch_duct_inlet',
'd_branch_duct_outlet']), # db_name, branch_obj, duct_obj
)
for db_name, branch_obj, duct_obj in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
result = hvacbuilder.makeductbranch(idf, db_name)
assert result.obj == branch_obj
theduct = idf.getobject('DUCT', result.Component_1_Name)
assert theduct.obj == duct_obj
示例5: test_makepipebranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_makepipebranch():
"""py.test for makepipebranch"""
tdata = ((
"p_branch",
['BRANCH',
'p_branch',
'0',
'',
'Pipe:Adiabatic',
'p_branch_pipe',
'p_branch_pipe_inlet',
'p_branch_pipe_outlet',
'Bypass'],
[
'PIPE:ADIABATIC',
'p_branch_pipe',
'p_branch_pipe_inlet',
'p_branch_pipe_outlet']
), # pb_name, branch_obj, pipe_obj
)
for pb_name, branch_obj, pipe_obj in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
result = hvacbuilder.makepipebranch(idf, pb_name)
assert result.obj == branch_obj
thepipe = idf.getobject('PIPE:ADIABATIC', result.Component_1_Name)
assert thepipe.obj == pipe_obj
示例6: test_replacebranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_replacebranch():
"""py.test for replacebranch"""
tdata = (
(
"p_loop", ['sb0', ['sb1', 'sb2', 'sb3'], 'sb4'],
['db0', ['db1', 'db2', 'db3'], 'db4'],
'sb0',
[
("Chiller:Electric".upper(), 'Central_Chiller',
'Chilled_Water_'),
("PIPE:ADIABATIC", 'np1', None),
("PIPE:ADIABATIC", 'np2', None)
],
'Water',
[
'BRANCH', 'sb0', '0', '', 'CHILLER:ELECTRIC', 'Central_Chiller',
'p_loop Supply Inlet', 'Central_Chiller_np1_node', '',
'PIPE:ADIABATIC',
'np1', 'Central_Chiller_np1_node', 'np1_np2_node', '',
'PIPE:ADIABATIC',
'np2', 'np1_np2_node', 'np2_Outlet_Node_Name', ''
]
), # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
)
for (loopname, sloop, dloop, branchname,
componenttuple, fluid, outbranch) in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
components_thisnodes = [(idf.newidfobject(key, nm), thisnode)
for key, nm, thisnode in componenttuple]
branch = idf.getobject('BRANCH', branchname)
newbr = hvacbuilder.replacebranch(idf, loop, branch,
components_thisnodes, fluid=fluid)
assert newbr.obj == outbranch
示例7: test_makeductbranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_makeductbranch():
"""py.test for makeductbranch"""
tdata = (
(
"d_branch",
[
"BRANCH",
"d_branch",
"0",
"",
"duct",
"d_branch_duct",
"d_branch_duct_inlet",
"d_branch_duct_outlet",
"Bypass",
],
["DUCT", "d_branch_duct", "d_branch_duct_inlet", "d_branch_duct_outlet"],
), # db_name, branch_obj, duct_obj
)
for db_name, branch_obj, duct_obj in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
result = hvacbuilder.makeductbranch(idf, db_name)
assert result.obj == branch_obj
theduct = idf.getobject("DUCT", result.Component_1_Name)
assert theduct.obj == duct_obj
示例8: test_makepipebranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_makepipebranch():
"""py.test for makepipebranch"""
tdata = (
(
"p_branch",
[
"BRANCH",
"p_branch",
"0",
"",
"Pipe:Adiabatic",
"p_branch_pipe",
"p_branch_pipe_inlet",
"p_branch_pipe_outlet",
"Bypass",
],
["PIPE:ADIABATIC", "p_branch_pipe", "p_branch_pipe_inlet", "p_branch_pipe_outlet"],
), # pb_name, branch_obj, pipe_obj
)
for pb_name, branch_obj, pipe_obj in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
result = hvacbuilder.makepipebranch(idf, pb_name)
assert result.obj == branch_obj
thepipe = idf.getobject("PIPE:ADIABATIC", result.Component_1_Name)
assert thepipe.obj == pipe_obj
示例9: test_replacebranch
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_replacebranch():
"""py.test for replacebranch"""
tdata = (
(
"p_loop",
["sb0", ["sb1", "sb2", "sb3"], "sb4"],
["db0", ["db1", "db2", "db3"], "db4"],
"sb0",
[
("Chiller:Electric".upper(), "Central_Chiller", "Chilled_Water_"),
("PIPE:ADIABATIC", "np1", None),
("PIPE:ADIABATIC", "np2", None),
],
"Water",
[
"BRANCH",
"sb0",
"0",
"",
"CHILLER:ELECTRIC",
"Central_Chiller",
"p_loop Supply Inlet",
"Central_Chiller_np1_node",
"",
"PIPE:ADIABATIC",
"np1",
"Central_Chiller_np1_node",
"np1_np2_node",
"",
"PIPE:ADIABATIC",
"np2",
"np1_np2_node",
"np2_Outlet_Node_Name",
"",
],
), # loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch
)
for (loopname, sloop, dloop, branchname, componenttuple, fluid, outbranch) in tdata:
fhandle = StringIO("")
idf = IDF(fhandle)
loop = hvacbuilder.makeplantloop(idf, loopname, sloop, dloop)
components_thisnodes = [(idf.newidfobject(key, nm), thisnode) for key, nm, thisnode in componenttuple]
branch = idf.getobject("BRANCH", branchname)
newbr = hvacbuilder.replacebranch(idf, loop, branch, components_thisnodes, fluid=fluid)
assert newbr.obj == outbranch
示例10: test_initreadtxt
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_initreadtxt():
"""Test for IDF.initreadtxt().
"""
idftxt = """
Material,
G01a 19mm gypsum board, !- Name
MediumSmooth, !- Roughness
0.019, !- Thickness {m}
0.16, !- Conductivity {W/m-K}
800, !- Density {kg/m3}
1090; !- Specific Heat {J/kg-K}
Construction,
Interior Wall, !- Name
G01a 19mm gypsum board, !- Outside Layer
F04 Wall air space resistance, !- Layer 2
G01a 19mm gypsum board; !- Layer 3
"""
idf = IDF()
idf.initreadtxt(idftxt)
assert idf.getobject('MATERIAL', 'G01a 19mm gypsum board')
示例11: are
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
# <codecell>
# make a new branch chiller->pipe1-> pipe2
# make a new pipe component
pipe1 = idf.newidfobject("PIPE:ADIABATIC", 'np1')
# make a new chiller
chiller = idf.newidfobject("Chiller:Electric".upper(), 'Central_Chiller')
# make another pipe component
pipe2 = idf.newidfobject("PIPE:ADIABATIC", 'np2')
# get the loop we are trying to modify
loop = idf.getobject('PLANTLOOP', 'p_loop') # args are (key, name)
# get the branch we are trying to modify
branch = idf.getobject('BRANCH', 'sb0') # args are (key, name)
listofcomponents = [chiller, pipe1, pipe2] # the new components are connected in this order
newbr = hvacbuilder.replacebranch(idf, loop, branch, listofcomponents, fluid='Water')
# in "loop"
# this replaces the components in "branch" with the components in "listofcomponents"
idf.saveas("hhh_new.idf")
# <markdowncell>
# We have saved this as file "hhh_new.idf".
# Let us draw the diagram of this file. (run this from eppy/eppy folder)
示例12: test_getreferingobjs
# 需要导入模块: from eppy.modeleditor import IDF [as 别名]
# 或者: from eppy.modeleditor.IDF import getobject [as 别名]
def test_getreferingobjs(self):
"""py.test for getreferingobjs"""
thedata = ((
""" Zone,
Box, !- Name
0.0, !- Direction of Relative North {deg}
0.288184, !- X Origin {m}
0.756604, !- Y Origin {m}
0.0, !- Z Origin {m}
, !- Type
1; !- Multiplier
BuildingSurface:Detailed,
N_Wall, !- Name
Wall, !- Surface Type
Exterior Wall, !- Construction Name
Box, !- Zone Name
Outdoors, !- Outside Boundary Condition
, !- Outside Boundary Condition Object
SunExposed, !- Sun Exposure
WindExposed, !- Wind Exposure
, !- View Factor to Ground
1, !- Number of Vertices
5.000000000000, !- Vertex 1 X-coordinate {m}
6.000000000000, !- Vertex 1 Y-coordinate {m}
3.000000000000; !- Vertex 1 Z-coordinate {m}
WALL:EXTERIOR,
WallExterior, !- Name
, !- Construction Name
Box, !- Zone Name
, !- Azimuth Angle
90; !- Tilt Angle
BUILDINGSURFACE:DETAILED,
EWall, !- Name
, !- Surface Type
, !- Construction Name
BOX, !- Zone Name
OtherBox, !- Outside Boundary Condition
, !- Outside Boundary Condition Object
SunExposed, !- Sun Exposure
WindExposed, !- Wind Exposure
autocalculate, !- View Factor to Ground
autocalculate; !- Number of Vertices
BUILDINGSURFACE:DETAILED,
EWall1, !- Name
, !- Surface Type
, !- Construction Name
BOX_other, !- Zone Name
OtherBox, !- Outside Boundary Condition
, !- Outside Boundary Condition Object
SunExposed, !- Sun Exposure
WindExposed, !- Wind Exposure
autocalculate, !- View Factor to Ground
autocalculate; !- Number of Vertices
HVACTemplate:Thermostat,
Constant Setpoint Thermostat, !- Name
, !- Heating Setpoint Schedule Name
20, !- Constant Heating Setpoint {C}
, !- Cooling Setpoint Schedule Name
25; !- Constant Cooling Setpoint {C}
FENESTRATIONSURFACE:DETAILED,
Window1, !- Name
, !- Surface Type
, !- Construction Name
EWall1, !- Building Surface Name
, !- Outside Boundary Condition Object
autocalculate, !- View Factor to Ground
, !- Shading Control Name
, !- Frame and Divider Name
1.0, !- Multiplier
autocalculate; !- Number of Vertices
""",
'Box',
['N_Wall', 'EWall', 'WallExterior']), # idftxt, zname, surfnamelst
)
for idftxt, zname, surfnamelst in thedata:
# import pdb; pdb.set_trace()
idf = IDF(StringIO(idftxt))
zone = idf.getobject('zone'.upper(), zname)
kwargs = {}
result = zone.getreferingobjs(**kwargs)
rnames = [item.Name for item in result]
rnames.sort()
surfnamelst.sort()
assert rnames == surfnamelst
for idftxt, zname, surfnamelst in thedata:
idf = IDF(StringIO(idftxt))
zone = idf.getobject('zone'.upper(), zname)
kwargs = {'iddgroups':[u'Thermal Zones and Surfaces', ]}
result = zone.getreferingobjs(**kwargs)
rnames = [item.Name for item in result]
rnames.sort()
surfnamelst.sort()
assert rnames == surfnamelst
for idftxt, zname, surfnamelst in thedata:
idf = IDF(StringIO(idftxt))
#.........这里部分代码省略.........