Ejemplo n.º 1
0
def step1():
    config = ConfigParser.ConfigParser()
    config.read(config_filename)

    structured = config.getboolean("general", "structured")
    sub_voxel = config.getboolean("general", "sub_voxel")
    meshtal = config.get("step1", "meshtal")
    tally_num = config.getint("step1", "tally_num")
    flux_tag = config.get("step1", "flux_tag")
    decay_times = config.get("step2", "decay_times").split(",")
    geom = config.get("step1", "geom")
    reverse = config.getboolean("step1", "reverse")
    num_rays = config.getint("step1", "num_rays")
    grid = config.getboolean("step1", "grid")

    load(geom)

    # get meshtal info from meshtal file
    flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag)

    # create the cell_fracs array before irradiation_steup
    if flux_mesh.structured:
        cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid)
        # tag cell fracs for both default and subvoxel r2s modes
        flux_mesh.tag_cell_fracs(cell_fracs)
    else:
        cell_fracs = discretize_geom(flux_mesh)

    cell_mats = cell_materials(geom)
    irradiation_setup(
        flux_mesh,
        cell_mats,
        cell_fracs,
        alara_params_filename,
        tally_num,
        num_rays=num_rays,
        grid=grid,
        reverse=reverse,
        flux_tag=flux_tag,
        decay_times=decay_times,
        sub_voxel=sub_voxel,
    )

    # create a blank mesh for step 2:
    ves = list(flux_mesh.iter_ve())
    tags_keep = (
        "cell_number",
        "cell_fracs",
        "cell_largest_frac_number",
        "cell_largest_frac",
    )
    for tag in flux_mesh.get_all_tags():
        if tag.name not in tags_keep and isinstance(tag, NativeMeshTag):
            tag.delete()
    flux_mesh.write_hdf5("blank_mesh.h5m")
    print("The file blank_mesh.h5m has been saved to disk.")
    print("Do not delete this file; it is needed by r2s.py step2.\n")

    print("R2S step1 complete, run ALARA with the command:")
    print(">> alara alara_inp > output.txt")
Ejemplo n.º 2
0
def step1():
    config = ConfigParser.ConfigParser()
    config.read(config_filename)

    structured = config.getboolean("general", "structured")
    meshtal = config.get("step1", "meshtal")
    tally_num = config.getint("step1", "tally_num")
    flux_tag = config.get("step1", "flux_tag")
    decay_times = config.get("step2", "decay_times").split(",")
    geom = config.get("step1", "geom")
    reverse = config.getboolean("step1", "reverse")
    num_rays = config.getint("step1", "num_rays")
    grid = config.getboolean("step1", "grid")
    responses = config.get("general", "responses").split(",")
    wdr_file = config.get("general", "wdr_file")

    load(geom)

    # get meshtal info from meshtal file
    flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag)

    # create the cell_fracs array before irradiation_steup
    if flux_mesh.structured:
        cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid)
    else:
        cell_fracs = discretize_geom(flux_mesh)

    cell_mats = cell_materials(geom)
    irradiation_setup(
        flux_mesh,
        cell_mats,
        cell_fracs,
        alara_params_filename,
        tally_num,
        num_rays=num_rays,
        grid=grid,
        reverse=reverse,
        output_mesh="activation_responses_step1.h5m",
        flux_tag=flux_tag,
        decay_times=decay_times,
        sub_voxel=False,
        responses=responses,
        wdr_file=wdr_file,
    )

    # create a blank mesh for step 2:
    ves = list(flux_mesh.iter_ve())
    for tag in flux_mesh.get_all_tags():
        tag.delete()
    flux_mesh.write_hdf5("blank_mesh.h5m")
    print("The file blank_mesh.h5m has been saved to disk.")
    print(
        "Do not delete this file; it is needed by activation_responses.py step2.\n"
    )
    print("Decay_heat step1 complete, run ALARA with the command:")
    print(">> alara alara_inp > output.txt")
Ejemplo n.º 3
0
def irradiation_setup_structured():

    meshtal = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    tally_num = 4
    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'mat_number': 11}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'mat_number': 12})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True

    irradiation_setup(meshtal, cell_mats, alara_params, tally_num, geom,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh, output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    m_out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [m_out, f1, f2, f3]
Ejemplo n.º 4
0
def irradiation_setup_unstructured():

    flux_tag = "n_flux"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    meshtal = Meshtal(meshtal_file, {4: (flux_tag, flux_tag + "_err",
                                         flux_tag + "_total",
                                         flux_tag + "_err_total")})
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.mesh.save(meshtal_mesh_file)

    cell_mats = {2: Material({2004: 1.0}, density=1.0, metadata={'mat_number':11}),
                 3: Material({3007: 0.4, 3006: 0.6}, density=2.0, metadata={'mat_number':12})}
    alara_params = "Bogus line for testing\n" 
    geom = os.path.join(thisdir, "unitbox.h5m")
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib= os.path.join(os.getcwd(), "alara_matlib")
    output_mesh= os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
 
    irradiation_setup(flux_mesh=meshtal_mesh_file, cell_mats=cell_mats, 
                      alara_params=alara_params, geom=geom, flux_tag=flux_tag, 
                      fluxin=fluxin, reverse=reverse, alara_inp=alara_inp,
                      alara_matlib=alara_matlib, output_mesh=output_mesh,
                      output_material=output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp_un")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s", 
                                             "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")
   
    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)
    
    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    m_out = [m.n_flux[:].tolist(), m.n_flux_err[:].tolist(), 
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(), 
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]]
    
    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)
    
    return [m_out, f1, f2, f3]
Ejemplo n.º 5
0
def step1():
    config = ConfigParser.ConfigParser()
    config.read(config_filename)

    structured = config.getboolean('general', 'structured')
    meshtal = config.get('step1', 'meshtal')
    tally_num = config.getint('step1', 'tally_num')
    flux_tag = config.get('step1', 'flux_tag')
    decay_times = config.get('step2', 'decay_times').split(',')
    geom = config.get('step1', 'geom')
    reverse = config.getboolean('step1', 'reverse')
    num_rays = config.getint('step1', 'num_rays')
    grid = config.getboolean('step1', 'grid')
    responses = config.get('general', 'responses').split(',')
    wdr_file = config.get('general', 'wdr_file')

    load(geom)

    # get meshtal info from meshtal file
    flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag)

    # create the cell_fracs array before irradiation_steup
    if flux_mesh.structured:
        cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid)
    else:
        cell_fracs = discretize_geom(flux_mesh)

    cell_mats = cell_materials(geom)
    irradiation_setup(flux_mesh,
                      cell_mats,
                      cell_fracs,
                      alara_params_filename,
                      tally_num,
                      num_rays=num_rays,
                      grid=grid,
                      reverse=reverse,
                      output_mesh="activation_responses_step1.h5m",
                      flux_tag=flux_tag,
                      decay_times=decay_times,
                      sub_voxel=False,
                      responses=responses,
                      wdr_file=wdr_file)

    # create a blank mesh for step 2:
    ves = list(flux_mesh.iter_ve())
    for tag in flux_mesh.get_all_tags():
        tag.delete()
    flux_mesh.write_hdf5('blank_mesh.h5m')
    print('The file blank_mesh.h5m has been saved to disk.')
    print(
        'Do not delete this file; it is needed by activation_responses.py step2.\n'
    )
    print('Decay_heat step1 complete, run ALARA with the command:')
    print('>> alara alara_inp > output.txt')
Ejemplo n.º 6
0
def step1():
    config = ConfigParser.ConfigParser()
    config.read(config_filename)

    structured = config.getboolean('general', 'structured')
    sub_voxel = config.getboolean('general', 'sub_voxel')
    meshtal = config.get('step1', 'meshtal')
    tally_num = config.getint('step1', 'tally_num')
    flux_tag = config.get('step1', 'flux_tag')
    decay_times = config.get('step2', 'decay_times').split(',')
    geom = config.get('step1', 'geom')
    reverse = config.getboolean('step1', 'reverse')
    num_rays = config.getint('step1', 'num_rays')
    grid = config.getboolean('step1', 'grid')

    load(geom)

    # get meshtal info from meshtal file
    flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag)

    # create the cell_fracs array before irradiation_steup
    if flux_mesh.structured:
        cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid)
        # tag cell fracs for both default and subvoxel r2s modes
        flux_mesh.tag_cell_fracs(cell_fracs)
    else:
        cell_fracs = discretize_geom(flux_mesh)

    cell_mats = cell_materials(geom)
    irradiation_setup(flux_mesh,
                      cell_mats,
                      cell_fracs,
                      alara_params_filename,
                      tally_num,
                      num_rays=num_rays,
                      grid=grid,
                      reverse=reverse,
                      flux_tag=flux_tag,
                      decay_times=decay_times,
                      sub_voxel=sub_voxel)

    # create a blank mesh for step 2:
    ves = list(flux_mesh.iter_ve())
    tags_keep = ("cell_number", "cell_fracs", "cell_largest_frac_number",
                 "cell_largest_frac")
    for tag in flux_mesh.get_all_tags():
        if tag.name not in tags_keep and isinstance(tag, NativeMeshTag):
            tag.delete()
    flux_mesh.write_hdf5('blank_mesh.h5m')
    print('The file blank_mesh.h5m has been saved to disk.')
    print('Do not delete this file; it is needed by r2s.py step2.\n')

    print('R2S step1 complete, run ALARA with the command:')
    print('>> alara alara_inp > output.txt')
Ejemplo n.º 7
0
def irradiation_setup_structured():

    meshtal = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    tally_num = 4
    cell_mats = {2: Material({2004: 1.0}, density=1.0, metadata={'mat_number': 11}),
                 3: Material({3007: 0.4, 3006: 0.6}, density=2.0, metadata={'mat_number':12})}
    alara_params = "Bogus line for testing\n" 
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
    
    irradiation_setup(meshtal, cell_mats, alara_params, tally_num, geom,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh, output_material)
    
    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s", 
                                             "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")
    
    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)
    
    m_out = [m.n_flux[:].tolist(), m.n_flux_err[:].tolist(), 
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(), 
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]]

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [m_out, f1, f2, f3]
Ejemplo n.º 8
0
def irradiation_setup_structured(flux_tag="n_flux",
                                 meshtal_file="meshtal_2x2x1"):

    meshtal = os.path.join(thisdir, "files_test_r2s", meshtal_file)
    tally_num = 4
    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'name': 'mat_11'}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'name': 'mat_12'})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
    cell_fracs = np.zeros(8,
                          dtype=[('idx', np.int64), ('cell', np.int64),
                                 ('vol_frac', np.float64),
                                 ('rel_error', np.float64)])
    cell_fracs[:] = [(0, 2, 0.037037037037037035, 0.5443310539518174),
                     (0, 3, 0.9629629629629631, 0.010467904883688123),
                     (1, 2, 0.037037037037037035, 0.5443310539518174),
                     (1, 3, 0.9629629629629629, 0.010467904883688454),
                     (2, 2, 0.037037037037037035, 0.5443310539518174),
                     (2, 3, 0.9629629629629629, 0.010467904883688454),
                     (3, 2, 0.037037037037037035, 0.5443310539518174),
                     (3, 3, 0.9629629629629629, 0.010467904883688454)]

    irradiation_setup(meshtal, cell_mats, cell_fracs, alara_params, tally_num,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh, output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    m_out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [m_out, f1, f2, f3]
Ejemplo n.º 9
0
def irradiation_setup_unstructured(flux_tag="n_flux"):
    meshtal_filename = "meshtal_2x2x1"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", meshtal_filename)

    meshtal = Meshtal(
        meshtal_file, {
            4: (flux_tag, flux_tag + "_err", flux_tag + "_total",
                flux_tag + "_err_total")
        })
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.write_hdf5(meshtal_mesh_file, write_mats=False)

    if flux_tag != "n_flux":
        # if not using n_flux makes a mesh containing n_flux tag, and then
        # makes a new tag called flux_tag, to use later in the test
        flux_tag_name = "n_flux"
        meshtal = Meshtal(
            meshtal_file, {
                4: (flux_tag_name, flux_tag_name + "_err",
                    flux_tag_name + "_total", flux_tag_name + "_err_total")
            })
        #  Explicitly make this mesh unstructured, it will now iterate in yxz
        #  order which is MOAB structured mesh creation order.
        meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
        meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
        meshtal.write_hdf5(meshtal_mesh_file, write_mats=False)
        new_mesh = Mesh(structured=False, mesh=meshtal_mesh_file)
        new_mesh.TALLY_TAG = NativeMeshTag(2, float)  # 2 egroups
        new_mesh.TALLY_TAG = meshtal.n_flux[:]

        # overwrite the mesh file
        new_mesh.write_hdf5(meshtal_mesh_file, write_mats=False)

    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'name': 'mat_11'}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'name': 'mat_12'})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
    cell_fracs = np.zeros(4,
                          dtype=[('idx', np.int64), ('cell', np.int64),
                                 ('vol_frac', np.float64),
                                 ('rel_error', np.float64)])
    cell_fracs[:] = [(0, 3, 1.0, 1.0), (1, 3, 1.0, 1.0), (2, 3, 1.0, 1.0),
                     (3, 3, 1.0, 1.0)]
    irradiation_setup(flux_mesh=meshtal_mesh_file,
                      cell_mats=cell_mats,
                      cell_fracs=cell_fracs,
                      alara_params=alara_params,
                      flux_tag=flux_tag,
                      fluxin=fluxin,
                      reverse=reverse,
                      alara_inp=alara_inp,
                      alara_matlib=alara_matlib,
                      output_mesh=output_mesh,
                      output_material=output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp_un")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    m_out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [m_out, f1, f2, f3]
Ejemplo n.º 10
0
def test_irradiation_setup_structured():

    meshtal = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    tally_num = 4
    cell_mats = {2: Material({2004: 1.0}, density=1.0),
                 3: Material({3007: 0.4, 3006: 0.6}, density=2.0)}
    alara_params = "Bogus line for testing" 
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib= os.path.join(os.getcwd(), "alara_matlib")
    output_mesh= os.path.join(os.getcwd(), "r2s_step1.h5m")
 
    irradiation_setup(meshtal, cell_mats, alara_params, tally_num, geom,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s", 
                                             "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")

    #  test alara input file
    with open(alara_inp, 'r') as f1, open(exp_alara_inp, 'r') as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara matlibe file
    with open(alara_matlib, 'r') as f1, open(exp_alara_matlib) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara fluxin file
    with open(fluxin, 'r') as f1, open(exp_fluxin) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07], 
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06] 
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)
    for i, mat, _ in m:
        assert_almost_equal(mat.density, 1.962963E+00)
        assert_equal(len(mat.comp), 3)
        assert_almost_equal(mat.comp[20040000], 1.886792E-02)
        assert_almost_equal(mat.comp[30060000], 5.886792E-01)
        assert_almost_equal(mat.comp[30070000], 3.924528E-01)
        assert_array_equal(m.n_flux[i], fluxes[i])
        assert_array_equal(m.n_flux_err[i], errs[i])
        assert_almost_equal(m.n_flux_total[i], tot_fluxes[i])
        assert_almost_equal(m.n_flux_err_total[i], tot_errs[i])

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)
Ejemplo n.º 11
0
def test_irradiation_setup_unstructured():

    flux_tag = "n_flux"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    meshtal = Meshtal(meshtal_file, {4: (flux_tag, flux_tag + "_err",
                                         flux_tag + "_total",
                                         flux_tag + "_err_total")})
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.mesh.save(meshtal_mesh_file)

    cell_mats = {2: Material({2004: 1.0}, density=1.0),
                 3: Material({3007: 0.4, 3006: 0.6}, density=2.0)}
    alara_params = "Bogus line for testing" 
    geom = os.path.join(thisdir, "unitbox.h5m")
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib= os.path.join(os.getcwd(), "alara_matlib")
    output_mesh= os.path.join(os.getcwd(), "r2s_step1.h5m")
 
    irradiation_setup(flux_mesh=meshtal_mesh_file, cell_mats=cell_mats, 
                      alara_params=alara_params, geom=geom, flux_tag=flux_tag, 
                      fluxin=fluxin, reverse=reverse, alara_inp=alara_inp,
                      alara_matlib=alara_matlib, output_mesh=output_mesh)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s", 
                                             "exp_alara_matlib_un")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")

    #  test alara input file
    with open(alara_inp, 'r') as f1, open(exp_alara_inp, 'r') as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara matlibe file
    with open(alara_matlib, 'r') as f1, open(exp_alara_matlib) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara fluxin file
    with open(fluxin, 'r') as f1, open(exp_fluxin) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07], 
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06] 
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)
    for i, mat, _ in m:
        assert_almost_equal(mat.density, 2.0)
        assert_equal(len(mat.comp), 2)
        assert_almost_equal(mat.comp[30060000], 0.6)
        assert_almost_equal(mat.comp[30070000], 0.4)
        assert_array_equal(m.n_flux[i], fluxes[i])
        assert_array_equal(m.n_flux_err[i], errs[i])
        assert_almost_equal(m.n_flux_total[i], tot_fluxes[i])
        assert_almost_equal(m.n_flux_err_total[i], tot_errs[i])

    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)
Ejemplo n.º 12
0
def irradiation_setup_structured(flux_tag="n_flux",
                                 meshtal_file="meshtal_2x2x1"):

    meshtal = os.path.join(thisdir, "files_test_r2s", meshtal_file)
    tally_num = 4
    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'name': 'mat_11'}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'name': 'mat_12'})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
    cell_fracs = np.zeros(8,
                          dtype=[('idx', np.int64), ('cell', np.int64),
                                 ('vol_frac', np.float64),
                                 ('rel_error', np.float64)])
    cell_fracs[:] = [(0, 2, 0.037037037037037035, 0.5443310539518174),
                     (0, 3, 0.9629629629629631, 0.010467904883688123),
                     (1, 2, 0.037037037037037035, 0.5443310539518174),
                     (1, 3, 0.9629629629629629, 0.010467904883688454),
                     (2, 2, 0.037037037037037035, 0.5443310539518174),
                     (2, 3, 0.9629629629629629, 0.010467904883688454),
                     (3, 2, 0.037037037037037035, 0.5443310539518174),
                     (3, 3, 0.9629629629629629, 0.010467904883688454)]

    irradiation_setup(meshtal, cell_mats, cell_fracs, alara_params, tally_num,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh, output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    n_flux = out[0]
    n_flux_err = out[1]
    n_flux_total = out[2]
    n_flux_err_total = out[3]
    densities = out[5]

    comps = np.zeros(shape=(len(out[4])), dtype=dict)
    for i, comp in enumerate(out[4]):
        comps[i] = {}
        for nucid in comp:
            comps[i][nucid[0]] = nucid[1]

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07],
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06]
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    i = 0
    for nf, nfe, nft, nfte, comp, density in izip(n_flux, n_flux_err,
                                                  n_flux_total,
                                                  n_flux_err_total, comps,
                                                  densities):
        assert_almost_equal(density, 1.962963E+00)
        assert_equal(len(comp), 3)
        assert_almost_equal(comp[20040000], 1.886792E-02)
        assert_almost_equal(comp[30060000], 5.886792E-01)
        assert_almost_equal(comp[30070000], 3.924528E-01)
        assert_array_equal(nf, fluxes[i])
        assert_array_equal(nfe, errs[i])
        assert_almost_equal(nft, tot_fluxes[i])
        assert_almost_equal(nfte, tot_errs[i])
        i += 1

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [f1, f2, f3]
Ejemplo n.º 13
0
def irradiation_setup_unstructured(flux_tag="n_flux"):
    meshtal_filename = "meshtal_2x2x1"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", meshtal_filename)

    meshtal = Meshtal(
        meshtal_file, {
            4: (flux_tag, flux_tag + "_err", flux_tag + "_total",
                flux_tag + "_err_total")
        })
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.write_hdf5(meshtal_mesh_file, write_mats=False)

    if flux_tag != "n_flux":
        # if not using n_flux makes a mesh containing n_flux tag, and then
        # makes a new tag called flux_tag, to use later in the test
        flux_tag_name = "n_flux"
        meshtal = Meshtal(
            meshtal_file, {
                4: (flux_tag_name, flux_tag_name + "_err",
                    flux_tag_name + "_total", flux_tag_name + "_err_total")
            })
        #  Explicitly make this mesh unstructured, it will now iterate in yxz
        #  order which is MOAB structured mesh creation order.
        meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
        meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
        meshtal.write_hdf5(meshtal_mesh_file, write_mats=False)
        new_mesh = Mesh(structured=False, mesh=meshtal_mesh_file)
        new_mesh.TALLY_TAG = NativeMeshTag(2, float)  # 2 egroups
        new_mesh.TALLY_TAG = meshtal.n_flux[:]

        # overwrite the mesh file
        new_mesh.write_hdf5(meshtal_mesh_file, write_mats=False)

    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'name': 'mat_11'}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'name': 'mat_12'})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True
    cell_fracs = np.zeros(4,
                          dtype=[('idx', np.int64), ('cell', np.int64),
                                 ('vol_frac', np.float64),
                                 ('rel_error', np.float64)])
    cell_fracs[:] = [(0, 3, 1.0, 1.0), (1, 3, 1.0, 1.0), (2, 3, 1.0, 1.0),
                     (3, 3, 1.0, 1.0)]
    irradiation_setup(flux_mesh=meshtal_mesh_file,
                      cell_mats=cell_mats,
                      cell_fracs=cell_fracs,
                      alara_params=alara_params,
                      flux_tag=flux_tag,
                      fluxin=fluxin,
                      reverse=reverse,
                      alara_inp=alara_inp,
                      alara_matlib=alara_matlib,
                      output_mesh=output_mesh,
                      output_material=output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp_un")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    n_flux = out[0]
    n_flux_err = out[1]
    n_flux_total = out[2]
    n_flux_err_total = out[3]
    densities = out[5]

    comps = np.zeros(shape=(len(out[4])), dtype=dict)
    for i, comp in enumerate(out[4]):
        comps[i] = {}
        for nucid in comp:
            comps[i][nucid[0]] = nucid[1]

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07],
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06]
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    i = 0
    for nf, nfe, nft, nfte, comp, density in izip(n_flux, n_flux_err,
                                                  n_flux_total,
                                                  n_flux_err_total, comps,
                                                  densities):
        assert_almost_equal(density, 2.0)
        assert_equal(len(comp), 2)
        assert_almost_equal(comp[30060000], 0.6)
        assert_almost_equal(comp[30070000], 0.4)
        assert_array_equal(nf, fluxes[i])
        assert_array_equal(nfe, errs[i])
        assert_almost_equal(nft, tot_fluxes[i])
        assert_almost_equal(nfte, tot_errs[i])
        i += 1

    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [f1, f2, f3]
Ejemplo n.º 14
0
def irradiation_setup_unstructured():

    flux_tag = "n_flux"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    meshtal = Meshtal(
        meshtal_file, {
            4: (flux_tag, flux_tag + "_err", flux_tag + "_total",
                flux_tag + "_err_total")
        })
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.mesh.save(meshtal_mesh_file)

    cell_mats = {
        2:
        Material({2004: 1.0}, density=1.0, metadata={'mat_number': 11}),
        3:
        Material({
            3007: 0.4,
            3006: 0.6
        },
                 density=2.0,
                 metadata={'mat_number': 12})
    }
    alara_params = "Bogus line for testing\n"
    geom = os.path.join(thisdir, "unitbox.h5m")
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")
    output_material = True

    irradiation_setup(flux_mesh=meshtal_mesh_file,
                      cell_mats=cell_mats,
                      alara_params=alara_params,
                      geom=geom,
                      flux_tag=flux_tag,
                      fluxin=fluxin,
                      reverse=reverse,
                      alara_inp=alara_inp,
                      alara_matlib=alara_matlib,
                      output_mesh=output_mesh,
                      output_material=output_material)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp_un")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")

    # test files
    f1 = filecmp.cmp(alara_inp, exp_alara_inp)
    f2 = filecmp.cmp(alara_matlib, exp_alara_matlib)
    f3 = filecmp.cmp(fluxin, exp_fluxin)

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)

    m_out = [
        m.n_flux[:].tolist(), m.n_flux_err[:].tolist(),
        m.n_flux_total[:].tolist(), m.n_flux_err_total[:].tolist(),
        [x.comp.items() for y, x, z in m], [x.density for y, x, z in m]
    ]

    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)

    return [m_out, f1, f2, f3]
Ejemplo n.º 15
0
def test_irradiation_setup_structured():

    meshtal = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    tally_num = 4
    cell_mats = {
        2: Material({2004: 1.0}, density=1.0),
        3: Material({
            3007: 0.4,
            3006: 0.6
        }, density=2.0)
    }
    alara_params = "Bogus line for testing"
    geom = os.path.join(thisdir, "unitbox.h5m")
    num_rays = 9
    grid = True
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")

    irradiation_setup(meshtal, cell_mats, alara_params, tally_num, geom,
                      num_rays, grid, flux_tag, fluxin, reverse, alara_inp,
                      alara_matlib, output_mesh)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin")

    #  test alara input file
    with open(alara_inp, 'r') as f1, open(exp_alara_inp, 'r') as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara matlibe file
    with open(alara_matlib, 'r') as f1, open(exp_alara_matlib) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara fluxin file
    with open(fluxin, 'r') as f1, open(exp_fluxin) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07],
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06]
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)
    for i, mat, _ in m:
        assert_almost_equal(mat.density, 1.962963E+00)
        assert_equal(len(mat.comp), 3)
        assert_almost_equal(mat.comp[20040000], 1.886792E-02)
        assert_almost_equal(mat.comp[30060000], 5.886792E-01)
        assert_almost_equal(mat.comp[30070000], 3.924528E-01)
        assert_array_equal(m.n_flux[i], fluxes[i])
        assert_array_equal(m.n_flux_err[i], errs[i])
        assert_almost_equal(m.n_flux_total[i], tot_fluxes[i])
        assert_almost_equal(m.n_flux_err_total[i], tot_errs[i])

    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)
Ejemplo n.º 16
0
def test_irradiation_setup_unstructured():

    flux_tag = "n_flux"
    meshtal_file = os.path.join(thisdir, "files_test_r2s", "meshtal_2x2x1")
    meshtal = Meshtal(
        meshtal_file, {
            4: (flux_tag, flux_tag + "_err", flux_tag + "_total",
                flux_tag + "_err_total")
        })
    #  Explicitly make this mesh unstructured, it will now iterate in yxz
    #  order which is MOAB structured mesh creation order.
    meshtal = Mesh(structured=False, mesh=meshtal.tally[4].mesh)
    meshtal_mesh_file = os.path.join(thisdir, "meshtal.h5m")
    meshtal.mesh.save(meshtal_mesh_file)

    cell_mats = {
        2: Material({2004: 1.0}, density=1.0),
        3: Material({
            3007: 0.4,
            3006: 0.6
        }, density=2.0)
    }
    alara_params = "Bogus line for testing"
    geom = os.path.join(thisdir, "unitbox.h5m")
    flux_tag = "n_flux"
    fluxin = os.path.join(os.getcwd(), "alara_fluxin")
    reverse = True
    alara_inp = os.path.join(os.getcwd(), "alara_inp")
    alara_matlib = os.path.join(os.getcwd(), "alara_matlib")
    output_mesh = os.path.join(os.getcwd(), "r2s_step1.h5m")

    irradiation_setup(flux_mesh=meshtal_mesh_file,
                      cell_mats=cell_mats,
                      alara_params=alara_params,
                      geom=geom,
                      flux_tag=flux_tag,
                      fluxin=fluxin,
                      reverse=reverse,
                      alara_inp=alara_inp,
                      alara_matlib=alara_matlib,
                      output_mesh=output_mesh)

    #  expected output files
    exp_alara_inp = os.path.join(thisdir, "files_test_r2s", "exp_alara_inp")
    exp_alara_matlib = os.path.join(thisdir, "files_test_r2s",
                                    "exp_alara_matlib_un")
    exp_fluxin = os.path.join(thisdir, "files_test_r2s", "exp_fluxin_un")

    #  test alara input file
    with open(alara_inp, 'r') as f1, open(exp_alara_inp, 'r') as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara matlibe file
    with open(alara_matlib, 'r') as f1, open(exp_alara_matlib) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    #  test alara fluxin file
    with open(fluxin, 'r') as f1, open(exp_fluxin) as f2:
        for a, b in zip(f1.readlines(), f2.readlines()):
            assert_equal(a, b)

    # test r2s step 1 output mesh
    fluxes = [[6.93088E-07, 1.04838E-06], [6.36368E-07, 9.78475E-07],
              [5.16309E-07, 9.86586E-07], [6.36887E-07, 9.29879E-07]]
    errs = [[9.67452E-02, 7.55950E-02], [9.88806E-02, 7.61482E-02],
            [1.04090E-01, 7.69284E-02], [9.75826E-02, 7.54181E-02]]
    tot_fluxes = [1.74147E-06, 1.61484E-06, 1.50290E-06, 1.56677E-06]
    tot_errs = [6.01522E-02, 6.13336E-02, 6.19920E-02, 5.98742E-02]

    m = Mesh(structured=True, mesh=output_mesh, mats=output_mesh)
    for i, mat, _ in m:
        assert_almost_equal(mat.density, 2.0)
        assert_equal(len(mat.comp), 2)
        assert_almost_equal(mat.comp[30060000], 0.6)
        assert_almost_equal(mat.comp[30070000], 0.4)
        assert_array_equal(m.n_flux[i], fluxes[i])
        assert_array_equal(m.n_flux_err[i], errs[i])
        assert_almost_equal(m.n_flux_total[i], tot_fluxes[i])
        assert_almost_equal(m.n_flux_err_total[i], tot_errs[i])

    os.remove(meshtal_mesh_file)
    os.remove(alara_inp)
    os.remove(alara_matlib)
    os.remove(fluxin)
    os.remove(output_mesh)