def get_zones_iteration_order(): """Test that _get_zones function gives results in zyx order. """ try: from pyne import dagmc except: raise SkipTest if not HAVE_PYMOAB: raise SkipTest # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + '/files_test_partisn/fractal_box.h5m' data_hdf5path = '/materials' # Load dagmc geometry dagmc.load(hdf5) bounds = [-5., 0., 5.] sc = [bounds] * 3 mesh = Mesh(structured_coords=sc, structured=True) bounds = {'x': bounds, 'y': bounds, 'z': bounds} num_rays = 9 grid = True dg = None mat_assigns = None unique_names = { 'mat:m1': 'M1', 'mat:m2': 'M2', 'mat:m3': 'M3', 'mat:m4': 'M4' } voxel_zones, zones = partisn._get_zones(mesh, hdf5, bounds, num_rays, grid, dg, mat_assigns, unique_names) voxel_zones_expected = np.array([[1, 2], [1, 4], [1, 3], [1, 4]]) zones_expected = { 1: { 'vol_frac': [1.0], 'mat': ['M2'] }, 2: { 'vol_frac': [1.0], 'mat': ['M4'] }, 3: { 'vol_frac': [1.0], 'mat': ['M1'] }, 4: { 'vol_frac': [1.0], 'mat': ['M3'] } } vz_tf = voxel_zones.all() == voxel_zones_expected.all() z_tf = zones == zones_expected return [vz_tf, z_tf]
def get_zones_iteration_order(): """Test that _get_zones function gives results in zyx order.""" try: from pyne import dagmc except: raise SkipTest if not HAVE_PYMOAB: raise SkipTest # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + "/files_test_partisn/fractal_box.h5m" data_hdf5path = "/materials" # Load dagmc geometry dagmc.load(hdf5) bounds = [-5.0, 0.0, 5.0] sc = [bounds] * 3 mesh = Mesh(structured_coords=sc, structured=True) bounds = {"x": bounds, "y": bounds, "z": bounds} num_rays = 9 grid = True dg = None mat_assigns = None unique_names = { "mat:m1": "M1", "mat:m2": "M2", "mat:m3": "M3", "mat:m4": "M4" } voxel_zones, zones = partisn._get_zones(mesh, hdf5, bounds, num_rays, grid, dg, mat_assigns, unique_names) voxel_zones_expected = np.array([[1, 2], [1, 4], [1, 3], [1, 4]]) zones_expected = { 1: { "vol_frac": [1.0], "mat": ["M2"] }, 2: { "vol_frac": [1.0], "mat": ["M4"] }, 3: { "vol_frac": [1.0], "mat": ["M1"] }, 4: { "vol_frac": [1.0], "mat": ["M3"] }, } vz_tf = voxel_zones.all() == voxel_zones_expected.all() z_tf = zones == zones_expected return [vz_tf, z_tf]
def get_zones_with_void(): """Test the _get_zones function if a void is present. """ try: from pyne import dagmc except: raise SkipTest if not HAVE_PYMOAB: raise SkipTest # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m' data_hdf5path = '/materials' nuc_hdf5path = '/nucid' dagmc.load(hdf5) # mesh xvals = [-5., 0., 10., 15., 15.1] yvals = [-5., 0., 5.] zvals = [-5., 0., 5.] mesh = Mesh(structured_coords=[xvals, yvals, zvals], structured=True, structured_ordering='xyz') # more inputs bounds = {'x': xvals, 'y': yvals, 'z': zvals} num_rays = 400 grid = True dg = None mat_assigns = None unique_names = {'mat:Helium, Natural': 'HELIUMNA', 'mat:Mercury': 'MERCURY1'} voxel_zones, zones = partisn._get_zones( mesh, hdf5, bounds, num_rays, grid, dg, mat_assigns, unique_names) # expected results voxel_zones_expected = np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [0, 0, 0, 0]]) zones_expected = {1: {'vol_frac': [1.0], 'mat': [u'HELIUMNA']}, 2: {'vol_frac': [0.5, 0.5], 'mat': [u'HELIUMNA', u'MERCURY1']}, 3: {'vol_frac': [1.0], 'mat': [u'MERCURY1']}} vz_tf = False z_tf = False if voxel_zones.all() == voxel_zones_expected.all(): vz_tf = True if zones == zones_expected: z_tf = True #assert(voxel_zones.all() == voxel_zones_expected.all()) #assert(zones == zones_expected) return [vz_tf, z_tf]
def get_zones_with_void(): """Test the _get_zones function if a void is present. """ # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m' data_hdf5path = '/materials' nuc_hdf5path = '/nucid' from pyne import dagmc dagmc.load(hdf5) # mesh xvals = [-5., 0., 10., 15., 15.1] yvals = [-5., 0., 5.] zvals = [-5., 0., 5.] mesh=Mesh(structured_coords=[xvals, yvals, zvals], structured=True, structured_ordering='xyz') # more inputs bounds = {'x':xvals, 'y':yvals, 'z':zvals} num_rays = 400 grid = True voxel_zones, zones = partisn._get_zones(mesh, hdf5, bounds, num_rays, grid) # expected results voxel_zones_expected = np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [0, 0, 0, 0]]) zones_expected = {1:{'vol_frac':[1.0], 'mat':[u'HeliumNatural']}, 2:{'vol_frac':[0.5, 0.5], 'mat':[u'HeliumNatural', u'Mercury']}, 3:{'vol_frac':[1.0], 'mat':[u'Mercury']}} vz_tf = False z_tf = False if voxel_zones.all() == voxel_zones_expected.all(): vz_tf = True if zones == zones_expected: z_tf = True #assert(voxel_zones.all() == voxel_zones_expected.all()) #assert(zones == zones_expected) return [vz_tf, z_tf]
def get_zones_no_void(): """Test the _get_zones function if no void is in the meshed area. """ # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + '/files_test_partisn/partisn_test_geom.h5m' data_hdf5path = '/materials' nuc_hdf5path = '/nucid' # Load dagmc geometry from pyne import dagmc dagmc.load(hdf5) # mesh xvals = [-5., 0., 10., 15.] yvals = [-5., 0., 5.] zvals = [-5., 0., 5.] mesh=Mesh(structured_coords=[xvals, yvals, zvals], structured=True, structured_ordering='xyz') # more inputs bounds = {'x':xvals, 'y':yvals, 'z':zvals} num_rays = 144 grid = True voxel_zones, zones = partisn._get_zones(mesh, hdf5, bounds, num_rays, grid) voxel_zones_expected = np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]) zones_expected = {1:{'vol_frac':[1.0], 'mat':[u'HeliumNatural']}, 2:{'vol_frac':[0.5, 0.5], 'mat':[u'HeliumNatural', u'Mercury']}, 3:{'vol_frac':[1.0], 'mat':[u'Mercury']}} vz_tf = False z_tf = False if voxel_zones.all() == voxel_zones_expected.all(): vz_tf = True if zones == zones_expected: z_tf = True #assert(voxel_zones.all() == voxel_zones_expected.all()) #assert(zones == zones_expected) return [vz_tf, z_tf]
def get_zones_with_void(): """Test the _get_zones function if a void is present.""" try: from pyne import dagmc except: raise SkipTest if not HAVE_PYMOAB: raise SkipTest # hdf5 test file THIS_DIR = os.path.dirname(os.path.realpath(__file__)) hdf5 = THIS_DIR + "/files_test_partisn/partisn_test_geom.h5m" data_hdf5path = "/materials" dagmc.load(hdf5) # mesh xvals = [-5.0, 0.0, 10.0, 15.0, 15.1] yvals = [-5.0, 0.0, 5.0] zvals = [-5.0, 0.0, 5.0] mesh = Mesh( structured_coords=[xvals, yvals, zvals], structured=True, structured_ordering="xyz", ) # more inputs bounds = {"x": xvals, "y": yvals, "z": zvals} num_rays = 400 grid = True dg = None mat_assigns = None unique_names = { "mat:Helium, Natural": "HELIUMNA", "mat:Mercury": "MERCURY1" } voxel_zones, zones = partisn._get_zones(mesh, hdf5, bounds, num_rays, grid, dg, mat_assigns, unique_names) # expected results voxel_zones_expected = np.array([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [0, 0, 0, 0]]) zones_expected = { 1: { "vol_frac": [1.0], "mat": ["HELIUMNA"] }, 2: { "vol_frac": [0.5, 0.5], "mat": ["HELIUMNA", "MERCURY1"] }, 3: { "vol_frac": [1.0], "mat": ["MERCURY1"] }, } vz_tf = False z_tf = False if voxel_zones.all() == voxel_zones_expected.all(): vz_tf = True if zones == zones_expected: z_tf = True # assert(voxel_zones.all() == voxel_zones_expected.all()) # assert(zones == zones_expected) return [vz_tf, z_tf]