本文整理汇总了Python中r2s.scdmesh.ScdMesh.getDivisions方法的典型用法代码示例。如果您正苦于以下问题:Python ScdMesh.getDivisions方法的具体用法?Python ScdMesh.getDivisions怎么用?Python ScdMesh.getDivisions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2s.scdmesh.ScdMesh
的用法示例。
在下文中一共展示了ScdMesh.getDivisions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_divs
# 需要导入模块: from r2s.scdmesh import ScdMesh [as 别名]
# 或者: from r2s.scdmesh.ScdMesh import getDivisions [as 别名]
def test_get_divs(self):
x = [1, 2.5, 4, 6.9]
y = [-12, -10, -.5]
z = [100, 200]
sm = ScdMesh( x, y, z )
self.assertEqual( sm.getDivisions('x'), x )
self.assertEqual( sm.getDivisions('y'), y )
self.assertEqual( sm.getDivisions('z'), z )
示例2: magic_wwinp
# 需要导入模块: from r2s.scdmesh import ScdMesh [as 别名]
# 或者: from r2s.scdmesh.ScdMesh import getDivisions [as 别名]
def magic_wwinp(flux_mesh, ww_mesh='None', total_bool=False, null_value=0, tolerance=0.1):
"""This function reads in a flux mesh and a ww mesh as well as relevant paramters
then the magic method is applied and a newly tagged flux is returned.
"""
# find meshtal type
tag_names = []
for tag in flux_mesh.imesh.getAllTags(flux_mesh.getHex(0,0,0)):
tag_names.append(tag.name)
if 'n_group_001' in tag_names or 'n_group_total' in tag_names:
particle = 'n'
elif 'p_group_001' in tag_names or 'p_group_total' in tag_names:
particle = 'p'
else:
print >>sys.stderr, 'Tag X_group_YYY or X_group_total not found'
sys.exit(1)
# find number of e_groups
num_e_groups = find_num_e_groups(flux_mesh, particle)
if total_bool == False:
e_groups = ['{0:03d}'.format(x) for x in range(1, num_e_groups + 1)]
print "\tGenerating WW for {0} energy groups".format(num_e_groups)
else:
e_groups = ['total']
print "\tGenerating WW for Total energy group"
# find the max flux value for each e_group, store in vector
max_fluxes = find_max_fluxes(flux_mesh, particle, e_groups, total_bool)
if ww_mesh == 'None':
print "\tNo WW mesh file supplied; generating one based on meshtal"
ww_bool = False # mesh file NOT preexisting
# create a mesh with the same dimensions as flux_mesh
ww_mesh = ScdMesh(flux_mesh.getDivisions('x'),\
flux_mesh.getDivisions('y'),\
flux_mesh.getDivisions('z'))
# create a tag for each energy group
for e_group in e_groups:
group_name = "ww_{0}_group_{1}".format(particle, e_group)
ww_mesh.imesh.createTag(group_name, 1, float)
# create energy bounds
tag_e_groups = ww_mesh.imesh.createTag("e_groups", len(e_groups), float)
if e_groups != ['total']:
tag_e_groups[ww_mesh.imesh.rootSet] = \
flux_mesh.imesh.getTagHandle("e_groups")[flux_mesh.imesh.rootSet]
else:
tag_e_groups[ww_mesh.imesh.rootSet] = 1E36 # usual MCNP value
else:
ww_bool = True # mesh file preexisting
# make sure the supplied meshes have the same dimenstions
ww_mesh = ScdMesh.fromFile(ww_mesh)
try:
for i in ('x', 'y', 'z'):
flux_mesh.getDivisions(i) == ww_mesh.getDivisions(i)
except:
print >>sys.stderr, 'Mismatched dimensions on WWINP and flux meshes'
sys.exit(1)
print "\tSupplied meshes confirmed to have same dimensions"
# iterate through all voxels
flux_voxels = flux_mesh.iterateHex('xyz')
ww_voxels = ww_mesh.iterateHex('xyz')
for (flux_voxel, ww_voxel) in zip(flux_voxels, ww_voxels):
for i, e_group in enumerate(e_groups):
flux = flux_mesh.imesh.getTagHandle(\
'{0}_group_{1}'.format(particle, e_group))[flux_voxel]
error = flux_mesh.imesh.getTagHandle(\
'{0}_group_{1}_error'.format(particle, e_group))[flux_voxel]
if ((ww_bool == False and error != 0.0) \
or (0.0 < error and error < tolerance)):
if ww_bool == True:
if ww_mesh.imesh.getTagHandle('ww_{0}_group_{1}'\
.format(particle, e_group))[ww_voxel] != -1:
ww_mesh.imesh.getTagHandle('ww_{0}_group_{1}'\
.format(particle, e_group))[ww_voxel]\
= flux/(2*max_fluxes[i]) # apply magic method
else:
ww_mesh.imesh.getTagHandle(\
'ww_{0}_group_{1}'.format(particle, e_group))[ww_voxel]\
= flux/(2*max_fluxes[i]) # apply magic method
elif ww_bool == False and error == 0.0 :
ww_mesh.imesh.getTagHandle(\
'ww_{0}_group_{1}'.format(particle, e_group))[ww_voxel]\
= null_value
return ww_mesh, e_groups