本文整理汇总了Python中pyne.mesh.Mesh.structured_iterate_hex方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.structured_iterate_hex方法的具体用法?Python Mesh.structured_iterate_hex怎么用?Python Mesh.structured_iterate_hex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyne.mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.structured_iterate_hex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_iterate_3d
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_iterate_3d():
# use izip_longest in the lockstep iterations below; this will catch any
# situations where one iterator turns out to be longer than expected.
sm = Mesh(structured=True,
structured_coords =[range(10,15), range(21,25), range(31,34)])
I = range(0,4)
J = range(0,3)
K = range(0,2)
izip = itertools.izip_longest
it = sm.structured_set.iterate(iBase.Type.region,
iMesh.Topology.hexahedron)
# Test the zyx order, which is default; it should be equivalent
# to the standard imesh iterator
for it_x, sm_x in izip(it, sm.structured_iterate_hex()):
assert_equal(it_x, sm_x)
#testing xyz
all_indices_zyx = itertools.product(I, J, K)
# Test the xyz order, the default from original mmGridGen
for ijk_index, sm_x in izip(all_indices_zyx,
sm.structured_iterate_hex("xyz")):
assert_equal(sm.structured_get_hex(*ijk_index), sm_x )
def _tuple_sort(collection, indices ):
# sorting function for order test
def t(tup):
# sort this 3-tuple according to the order of x, y, and z in
#indices
return (tup["xyz".find(indices[0])]*100 +
tup["xyz".find(indices[1])]*10 +
tup["xyz".find(indices[2])])
return sorted(collection, key = t)
def test_order(order, *args, **kw):
all_indices = itertools.product(*args)
for ijk_index, sm_x in izip(_tuple_sort(all_indices, order),
sm.structured_iterate_hex(order,**kw)):
assert_equal(sm.structured_get_hex(*ijk_index), sm_x)
test_order("yxz", I, J, K)
test_order("yzx", I, J, K)
test_order("xzy", I, J, K)
test_order("zxy", I, J, K)
# Specify z=[1] to iterator
test_order("xyz", I, J, [1], z=[1])
# Specify y=2 to iterator
test_order("zyx", I, [2], K, y=2)
# specify x and y both to iterator
test_order("yzx", [1,2,3],J[:-1], K, y=J[:-1], x=[1,2,3])
示例2: test_write_fluxin_single
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_write_fluxin_single():
"""This function tests the flux_mesh_to_fluxin function for a single energy
group case.
"""
if not HAVE_PYTAPS:
raise SkipTest
output_name = "fluxin.out"
forward_fluxin = os.path.join(thisdir, "files_test_alara", "fluxin_single_forward.txt")
output = os.path.join(os.getcwd(), output_name)
flux_mesh = Mesh(structured=True, structured_coords=[[0, 1, 2], [0, 1, 2], [0, 1]])
tag_flux = flux_mesh.mesh.createTag("flux", 1, float)
flux_data = [1, 2, 3, 4]
ves = flux_mesh.structured_iterate_hex("xyz")
for i, ve in enumerate(ves):
tag_flux[ve] = flux_data[i]
# test forward writting
mesh_to_fluxin(flux_mesh, "flux", output_name, False)
with open(output) as f:
written = f.readlines()
with open(forward_fluxin) as f:
expected = f.readlines()
assert_equal(written, expected)
if os.path.isfile(output):
os.remove(output)
示例3: test_photon_source_hdf5_to_mesh
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_photon_source_hdf5_to_mesh():
"""Tests the function photon source_h5_to_mesh."""
if not HAVE_PYTAPS:
raise SkipTest
filename = os.path.join(thisdir, "files_test_alara", "phtn_src")
photon_source_to_hdf5(filename, chunkshape=(10,))
assert_true(os.path.exists(filename + ".h5"))
mesh = Mesh(structured=True, structured_coords=[[0, 1, 2], [0, 1, 2], [0, 1]])
tags = {("1001", "shutdown"): "tag1", ("TOTAL", "1 h"): "tag2"}
photon_source_hdf5_to_mesh(mesh, filename + ".h5", tags)
# create lists of lists of expected results
tag1_answers = [[1] + [0] * 41, [2] + [0] * 41, [3] + [0] * 41, [4] + [0] * 41]
tag2_answers = [[5] + [0] * 41, [6] + [0] * 41, [7] + [0] * 41, [8] + [0] * 41]
ves = list(mesh.structured_iterate_hex("xyz"))
for i, ve in enumerate(ves):
assert_array_equal(mesh.mesh.getTagHandle("tag1")[ve], tag1_answers[i])
assert_array_equal(mesh.mesh.getTagHandle("tag2")[ve], tag2_answers[i])
if os.path.isfile(filename + ".h5"):
os.remove(filename + ".h5")
示例4: gen_mesh
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def gen_mesh(mats=()):
mesh_1 = Mesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True,
structured_ordering='zyx', mats=mats)
volumes1 = list(mesh_1.structured_iterate_hex("xyz"))
flux_tag = mesh_1.mesh.createTag("flux", 1, float)
flux_data = [1.0, 2.0, 3.0, 4.0]
flux_tag[volumes1] = flux_data
return mesh_1
示例5: test_iterate_1d
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_iterate_1d():
sm = Mesh(structured=True,
structured_coords =[range(10,15), range(21,25), range(31,34)])
def test_equal(ijk_list, miter):
for ijk, i in itertools.izip_longest(ijk_list, miter):
assert_equal(sm.structured_get_hex(*ijk), i)
test_equal([[0,0,0],[0,0,1]],
sm.structured_iterate_hex("z"))
test_equal([[0,1,1],[0,2,1]],
sm.structured_iterate_hex("y", y=[1,2], z=1))
test_equal([[2,0,0],[2,1,0],[2,2,0]],
sm.structured_iterate_hex("y", x=2))
test_equal([[0,0,0],[1,0,0],[2,0,0]],
sm.structured_iterate_hex("x", x=[0,1,2]))
示例6: test_iterate_2d
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_iterate_2d():
sm = Mesh(structured=True,
structured_coords =[range(10,15), range(21,25), range(31,34)])
def test_order(iter1, iter2):
for i1, i2 in itertools.izip_longest(iter1, iter2):
assert_equal(i1, i2)
test_order(sm.structured_iterate_hex("yx"),
sm.structured_iterate_hex("zyx", z=[0]))
test_order(sm.structured_iterate_hex("yx",z=1),
sm.structured_iterate_hex("zyx",z=[1]))
test_order(sm.structured_iterate_hex("yx",z=1),
sm.structured_iterate_hex("yzx",z=[1]))
test_order(sm.structured_iterate_hex("zy",x=[3]),
sm.structured_iterate_hex("zxy",x=3))
# Cannot iterate over multiple z's without specifing z order
assert_raises(MeshError, sm.structured_iterate_hex, "yx", z=[0,1])
示例7: test_single_meshtally_meshtal
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_single_meshtally_meshtal():
"""Test a meshtal file containing a single mesh tally.
"""
if not HAVE_PYTAPS:
raise SkipTest
thisdir = os.path.dirname(__file__)
meshtal_file = os.path.join(thisdir, "mcnp_meshtal_single_meshtal.txt")
expected_h5m = os.path.join(thisdir, "mcnp_meshtal_single_mesh.h5m")
expected_sm = Mesh(mesh=expected_h5m, structured=True)
tags = {4: ["n_result", "n_rel_error",
"n_total_result", "n_total_rel_error"]}
meshtal_object = mcnp.Meshtal(meshtal_file, tags, meshes_have_mats=True)
assert_not_equal(meshtal_object.tally[4].mats, None)
# test Meshtal attributes
assert_equal(meshtal_object.version, '5.mpi')
assert_equal(meshtal_object.ld, "09282010")
assert_equal(meshtal_object.title,
"Input file to general test meshtal file")
assert_equal(meshtal_object.histories, 100000)
# test MeshTally attributes
assert_equal(meshtal_object.tally[4].tally_number, 4)
assert_equal(meshtal_object.tally[4].particle, "neutron")
assert_equal(meshtal_object.tally[4].dose_response, True)
assert_equal(
meshtal_object.tally[4].x_bounds,
[-200.00, -66.67, 66.67, 200.00])
assert_equal(
meshtal_object.tally[4].y_bounds,
[-200.00, -120.00, -40.00, 40.00, 120.00, 200.00])
assert_equal(
meshtal_object.tally[4].z_bounds,
[-200.00, -50.00, 100.00, 200.00])
assert_equal(
meshtal_object.tally[4].e_bounds,
[0.00E+00, 1.00E-01, 2.00E-01, 1.00E+00])
# test vector tags
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_result")[v_e]
expected = expected_sm.mesh.getTagHandle("n_result")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_rel_error")[v_e]
expected = expected_sm.mesh.getTagHandle("n_rel_error")[expected_v_e]
assert_array_equal(written, expected)
# test total tag
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_total_result")[v_e]
expected = expected_sm.mesh.getTagHandle("n_total_result")[expected_v_e]
assert_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_total_rel_error")[v_e]
expected = expected_sm.mesh.getTagHandle("n_total_rel_error")[expected_v_e]
assert_equal(written, expected)
示例8: test_wwinp_np
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_wwinp_np():
if not HAVE_PYTAPS:
raise SkipTest
thisdir = os.path.dirname(__file__)
wwinp_file = os.path.join(thisdir, 'mcnp_wwinp_wwinp_np.txt')
expected_h5m = os.path.join(thisdir, 'mcnp_wwinp_mesh_np.h5m')
expected_sm = Mesh(mesh=expected_h5m, structured=True)
output = os.path.join(os.getcwd(), 'test_wwinp')
# Read in the wwinp file to an object and check resulting attributes.
ww1 = mcnp.Wwinp()
ww1.read_wwinp(wwinp_file)
assert_equal(ww1.ni, 2)
assert_equal(ww1.nr, 10)
assert_equal(ww1.ne, [7, 1])
assert_equal(ww1.nf, [1, 8, 6])
assert_equal(ww1.origin, [-100, -100, -100])
assert_equal(ww1.nc, [1, 3, 1])
assert_equal(ww1.nwg, 1)
assert_equal(ww1.cm, [[100], [-50, 60, 100], [100]])
assert_equal(ww1.fm, [[1], [1, 3, 4], [6]])
assert_equal(
ww1.e[0], [0.1, 0.14678, 0.21544, 0.31623, 0.46416, 0.68129, 1.0000])
assert_array_equal(ww1.e[1], [100])
assert_equal(
ww1.bounds,
[[-100.0, 100],
[-100.0, -50.0, -13.333333333333336,
23.333333333333329, 60.0, 70.0, 80.0, 90.0, 100.0],
[-100.0, -66.666666666666657, -33.333333333333329,
0.0, 33.333333333333343, 66.666666666666657, 100.0]])
expected_ves = list(expected_sm.structured_iterate_hex("zyx"))
written_ves = list(expected_sm.structured_iterate_hex("zyx"))
for expected_ve, written_ve in zip(expected_ves, written_ves):
expected = expected_sm.mesh.getTagHandle("ww_n")[expected_ve]
written = ww1.mesh.getTagHandle("ww_n")[written_ve]
assert_array_equal(written, expected)
expected_ves = list(expected_sm.structured_iterate_hex("zyx"))
written_ves = list(expected_sm.structured_iterate_hex("zyx"))
for expected_ve, written_ve in zip(expected_ves, written_ves):
expected = expected_sm.mesh.getTagHandle("ww_p")[expected_ve]
written = ww1.mesh.getTagHandle("ww_p")[written_ve]
assert_array_equal(written, expected)
# Create an new object based off of only the mesh attribute of the first
# object and check resutling attributes.
ww2 = mcnp.Wwinp()
ww2.read_mesh(ww1.mesh)
assert_equal(ww2.ni, 2)
assert_equal(ww2.nr, 10)
assert_equal(ww2.ne, [7, 1])
assert_equal(ww2.nf, [1, 8, 6])
assert_equal(ww2.origin, [-100, -100, -100])
assert_equal(ww2.nc, [1, 3, 1])
assert_equal(ww2.nwg, 1)
assert_equal(ww2.cm, [[100], [-50, 60, 100], [100]])
assert_equal(ww2.fm, [[1], [1, 3, 4], [6]])
assert_array_equal(
ww2.e[0], [0.1, 0.14678, 0.21544, 0.31623, 0.46416, 0.68129, 1.0000])
assert_array_equal(ww2.e[1], [100])
assert_equal(
ww2.bounds,
[[-100.0, 100],
[-100.0, -50.0, -13.333333333333336,
23.333333333333329, 60.0, 70.0, 80.0, 90.0, 100.0],
[-100.0, -66.666666666666657, -33.333333333333329,
0.0, 33.333333333333343, 66.666666666666657, 100.0]])
expected_ves = list(expected_sm.structured_iterate_hex("zyx"))
written_ves = list(expected_sm.structured_iterate_hex("zyx"))
for expected_ve, written_ve in zip(expected_ves, written_ves):
expected = expected_sm.mesh.getTagHandle("ww_n")[expected_ve]
written = ww2.mesh.getTagHandle("ww_n")[written_ve]
assert_array_equal(written, expected)
expected_ves = list(expected_sm.structured_iterate_hex("zyx"))
written_ves = list(expected_sm.structured_iterate_hex("zyx"))
for expected_ve, written_ve in zip(expected_ves, written_ves):
expected = expected_sm.mesh.getTagHandle("ww_p")[expected_ve]
written = ww2.mesh.getTagHandle("ww_p")[written_ve]
assert_array_equal(written, expected)
# write a new wwinp file and verify that is same wwinp file used as an
# input to this test
ww2.write_wwinp(output)
expected_output = wwinp_file
with open(output) as f:
written = f.readlines()
with open(expected_output) as f:
expected = f.readlines()
# check to make sure file are the same except for the data/time info
# on line 1
assert_equal(written[0].split()[:-2], expected[0].split()[:-2])
assert_equal(len(written), len(expected))
#.........这里部分代码省略.........
示例9: test_multiple_meshtally_meshtal
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
def test_multiple_meshtally_meshtal():
"""Test a meshtal file containing 4 mesh tallies including neutron and
photon, single energy group and multiple energy group.
"""
if not HAVE_PYTAPS:
raise SkipTest
thisdir = os.path.dirname(__file__)
meshtal_file = os.path.join(thisdir, "mcnp_meshtal_multiple_meshtal.txt")
expected_h5m_4 = os.path.join(thisdir, "mcnp_meshtal_tally_4.h5m")
expected_sm_4 = Mesh(mesh=expected_h5m_4, structured=True)
expected_h5m_14 = os.path.join(thisdir, "mcnp_meshtal_tally_14.h5m")
expected_sm_14 = Mesh(mesh=expected_h5m_14, structured=True)
expected_h5m_24 = os.path.join(thisdir, "mcnp_meshtal_tally_24.h5m")
expected_sm_24 = Mesh(mesh=expected_h5m_24, structured=True)
expected_h5m_34 = os.path.join(thisdir, "mcnp_meshtal_tally_34.h5m")
expected_sm_34 = Mesh(mesh=expected_h5m_34, structured=True)
tags = {4: ["n_result", "n_rel_error",
"n_total_result", "n_total_rel_error"],
14: ["n_result", "n_rel_error",
"n_total_result", "n_total_rel_error"],
24: ["p_result", "p_rel_error",
"p_total_result", "p_total_rel_error"],
34: ["p_result", "p_rel_error",
"p_total_result", "p_total_rel_error"]}
meshtal_object = mcnp.Meshtal(meshtal_file, tags)
assert_equal(meshtal_object.version, '5')
assert_equal(meshtal_object.tally[4].mats, None)
# test meshtally 4
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm_4.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_result")[v_e]
expected = expected_sm_4.mesh.getTagHandle("n_result")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm_4.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_rel_error")[v_e]
expected = expected_sm_4.mesh.getTagHandle("n_rel_error")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm_4.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_total_result")[v_e]
expected = expected_sm_4.mesh.getTagHandle("n_total_result")[expected_v_e]
assert_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[4].structured_iterate_hex("xyz"),
expected_sm_4.structured_iterate_hex("xyz")):
written = meshtal_object.tally[4].mesh.getTagHandle("n_total_rel_error")[v_e]
expected = expected_sm_4.mesh.getTagHandle("n_total_rel_error")[expected_v_e]
assert_equal(written, expected)
# test meshtally 14
for v_e, expected_v_e in zip(
meshtal_object.tally[14].structured_iterate_hex("xyz"),
expected_sm_14.structured_iterate_hex("xyz")):
written = meshtal_object.tally[14].mesh.getTagHandle("n_result")[v_e]
expected = expected_sm_14.mesh.getTagHandle("n_result")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[14].structured_iterate_hex("xyz"),
expected_sm_14.structured_iterate_hex("xyz")):
written = meshtal_object.tally[14].mesh.getTagHandle("n_rel_error")[v_e]
expected = expected_sm_14.mesh.getTagHandle("n_rel_error")[expected_v_e]
assert_array_equal(written, expected)
# test meshtally 24
for v_e, expected_v_e in zip(
meshtal_object.tally[24].structured_iterate_hex("xyz"),
expected_sm_24.structured_iterate_hex("xyz")):
written = meshtal_object.tally[24].mesh.getTagHandle("p_result")[v_e]
expected = expected_sm_24.mesh.getTagHandle("p_result")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[24].structured_iterate_hex("xyz"),
expected_sm_24.structured_iterate_hex("xyz")):
written = meshtal_object.tally[24].mesh.getTagHandle("p_rel_error")[v_e]
expected = expected_sm_24.mesh.getTagHandle("p_rel_error")[expected_v_e]
assert_array_equal(written, expected)
for v_e, expected_v_e in zip(
meshtal_object.tally[24].structured_iterate_hex("xyz"),
expected_sm_24.structured_iterate_hex("xyz")):
written = meshtal_object.tally[24].mesh.getTagHandle("p_total_result")[v_e]
expected = expected_sm_24.mesh.getTagHandle("p_total_result")[expected_v_e]
assert_equal(written, expected)
#.........这里部分代码省略.........
示例10: TestArithmetic
# 需要导入模块: from pyne.mesh import Mesh [as 别名]
# 或者: from pyne.mesh.Mesh import structured_iterate_hex [as 别名]
class TestArithmetic():
def arithmetic_mesh_setup(self):
self.mesh_1 = Mesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True)
volumes1 = list(self.mesh_1.structured_iterate_hex("xyz"))
volumes2 = list(self.mesh_1.structured_iterate_hex("xyz"))
flux_tag = self.mesh_1.mesh.createTag("flux", 1, float)
flux_data = [1.0, 2.0, 3.0, 4.0]
flux_tag[volumes1] = flux_data
self.mesh_2 = Mesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True)
volumes1 = list(self.mesh_2.structured_iterate_hex("xyz"))
volumes2 = list(self.mesh_2.structured_iterate_hex("xyz"))
flux_tag = self.mesh_2.mesh.createTag("flux", 1, float)
flux_data = [1.1, 2.2, 3.3, 4.4]
flux_tag[volumes1] = flux_data
def arithmetic_statmesh_setup(self):
self.statmesh_1 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True)
volumes1 = list(self.statmesh_1.structured_iterate_hex("xyz"))
volumes2 = list(self.statmesh_1.structured_iterate_hex("xyz"))
flux_tag = self.statmesh_1.mesh.createTag("flux", 1, float)
error_tag = self.statmesh_1.mesh.createTag("flux_error", 1, float)
flux_data = [1.0, 2.0, 3.0, 4.0]
error_data = [0.1, 0.2, 0.3, 0.4]
flux_tag[volumes1] = flux_data
error_tag[volumes2] = error_data
self.statmesh_2 = StatMesh(structured_coords=[[-1,0,1],[-1,0,1],[0,1]], structured=True)
volumes1 = list(self.statmesh_2.structured_iterate_hex("xyz"))
volumes2 = list(self.statmesh_2.structured_iterate_hex("xyz"))
flux_tag = self.statmesh_2.mesh.createTag("flux", 1, float)
error_tag = self.statmesh_2.mesh.createTag("flux_error", 1, float)
flux_data = [1.1, 2.2, 3.3, 4.4]
error_data = [0.1, 0.2, 0.3, 0.4]
flux_tag[volumes1] = flux_data
error_tag[volumes2] = error_data
def test_add_mesh(self):
self.arithmetic_mesh_setup()
self.mesh_1 += self.mesh_2
exp_res = [2.1, 4.2, 6.3, 8.4]
obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.mesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
def test_subtract_mesh(self):
self.arithmetic_mesh_setup()
self.mesh_1 -= self.mesh_2
exp_res = [-0.1, -0.2, -0.3, -0.4]
obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.mesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
def test_multiply_mesh(self):
self.arithmetic_mesh_setup()
self.mesh_1 *= self.mesh_2
exp_res = [1.1, 4.4, 9.9, 17.6]
obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.mesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
def test_divide_mesh(self):
self.arithmetic_mesh_setup()
self.mesh_1 /= self.mesh_2
exp_res = [0.9090909091, 0.9090909091, 0.9090909091, 0.9090909091]
obs_res = [self.mesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.mesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
def test_add_statmesh(self):
self.arithmetic_statmesh_setup()
self.statmesh_1 += self.statmesh_2
exp_res = [2.1, 4.2, 6.3, 8.4]
exp_err = [0.070790803558659549, 0.1415816071173191,
0.21237241067597862, 0.28316321423463819]
obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.statmesh_1.structured_iterate_hex("xyz")]
obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol]
for vol in self.statmesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
assert_array_almost_equal(exp_err, obs_err)
def test_subtract_statmesh(self):
self.arithmetic_statmesh_setup()
self.statmesh_1 -= self.statmesh_2
exp_res = [-0.1, -0.2, -0.3, -0.4]
exp_err = [-1.4866068747, -2.9732137495, -4.4598206242, -5.9464274989]
obs_res = [self.statmesh_1.mesh.getTagHandle("flux")[vol]
for vol in self.statmesh_1.structured_iterate_hex("xyz")]
obs_err = [self.statmesh_1.mesh.getTagHandle("flux_error")[vol]
for vol in self.statmesh_1.structured_iterate_hex("xyz")]
assert_array_almost_equal(exp_res, obs_res)
assert_array_almost_equal(exp_err, obs_err)
def test_multiply_statmesh(self):
self.arithmetic_statmesh_setup()
self.statmesh_1 *= self.statmesh_2
exp_res = [1.1, 4.4, 9.9, 17.6]
exp_err = [0.1414213562, 0.2828427125, 0.4242640687, 0.5656854249,]
#.........这里部分代码省略.........