本文整理汇总了Python中pyne.mesh.Mesh.ve_center方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.ve_center方法的具体用法?Python Mesh.ve_center怎么用?Python Mesh.ve_center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyne.mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.ve_center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_analog_single_tet
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import ve_center [as 别名]
def test_analog_single_tet():
"""This test tests uniform sampling within a single tetrahedron. This is
done by dividing the tetrahedron in 4 smaller tetrahedrons and ensuring
that each sub-tet is sampled equally.
"""
seed(1953)
mesh = iMesh.Mesh()
v1 = [0, 0, 0]
v2 = [1, 0, 0]
v3 = [0, 1, 0]
v4 = [0, 0, 1]
verts = mesh.createVtx([v1, v2, v3, v4])
mesh.createEnt(iMesh.Topology.tetrahedron, verts)
m = Mesh(structured=False, mesh=mesh)
m.src = IMeshTag(1, float)
m.src[:] = np.array([1])
m.mesh.save("tet.h5m")
center = m.ve_center(list(m.iter_ve())[0])
subtets = [[center, v1, v2, v3], [center, v1, v2, v4], [center, v1, v3, v4], [center, v2, v3, v4]]
sampler = Sampler("tet.h5m", "src", np.array([0, 1]), False)
num_samples = 5000
score = 1.0 / num_samples
tally = np.zeros(shape=(4))
for i in range(num_samples):
s = sampler.particle_birth([uniform(0, 1) for x in range(6)])
assert_equal(s[4], 1.0)
for i, tet in enumerate(subtets):
if point_in_tet(tet, [s[0], s[1], s[2]]):
tally[i] += score
break
for t in tally:
assert abs(t - 0.25) / 0.25 < 0.2
示例2: test_ve_center
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import ve_center [as 别名]
def test_ve_center():
m = Mesh(structured=True, structured_coords=[[-1, 3, 5], [-1, 1], [-1, 1]])
exp_centers = [(1, 0, 0), (4, 0, 0)]
for i, mat, ve in m:
assert_equal(m.ve_center(ve), exp_centers[i])