예제 #1
0
def grab_kaeri_simple_xs(build_dir=""):
    """Grabs the KAERI files needed for the simple cross sections table, 
    if not already present.

    Parameters
    ----------
    build_dir : str
        Major directory to place html files in. 'KAERI/' will be appended.
    """
    # Add kaeri to build_dir
    build_dir = os.path.join(build_dir, 'KAERI')
    try:
        os.makedirs(build_dir)
    except OSError:
        pass
    already_grabbed = set(os.listdir(build_dir))

    # Grab and parse elemental summary files.
    all_nuclides = set()
    for element in nucname.name_zz.keys():
        htmlfile = element + '.html'
        if htmlfile not in already_grabbed:
            grab_kaeri_nuclide(element, build_dir)

        all_nuclides = all_nuclides | parse_for_all_isotopes(os.path.join(build_dir, htmlfile))

    # Grab nuclide XS summary files
    for nuc in sorted(all_nuclides):
        nuc = nucname.name(nuc)
        htmlfile = nuc + '_2.html'
        if htmlfile not in already_grabbed:
            grab_kaeri_nuclide(nuc, build_dir, 2)
예제 #2
0
파일: simple_xs.py 프로젝트: rwcarlsen/pyne
def grab_kaeri_simple_xs(build_dir=""):
    """Grabs the KAERI files needed for the simple cross sections table, 
    if not already present.

    Parameters
    ----------
    build_dir : str
        Major directory to place html files in. 'KAERI/' will be appended.
    """
    # Add kaeri to build_dir
    build_dir = os.path.join(build_dir, 'KAERI')
    try:
        os.makedirs(build_dir)
    except OSError:
        pass
    already_grabbed = set(os.listdir(build_dir))

    # Grab and parse elemental summary files.
    all_nuclides = set()
    for element in nucname.name_zz.keys():
        htmlfile = element + '.html'
        if htmlfile not in already_grabbed:
            grab_kaeri_nuclide(element, build_dir)

        all_nuclides = all_nuclides | parse_for_all_isotopes(
            os.path.join(build_dir, htmlfile))

    # Grab nuclide XS summary files
    for nuc in sorted(all_nuclides):
        nuc = nucname.name(nuc)
        htmlfile = nuc + '_2.html'
        if htmlfile not in already_grabbed:
            grab_kaeri_nuclide(nuc, build_dir, 2)
예제 #3
0
def parse_simple_xs(build_dir=""):
    """Builds and returns a dictionary from cross-section types to nuclides."""
    build_dir = os.path.join(build_dir, "KAERI")

    # Grab and parse elemental summary files.
    all_nuclides = set()
    for element in nucname.name_zz.keys():
        htmlfile = element + ".html"
        all_nuclides = all_nuclides | parse_for_all_isotopes(os.path.join(build_dir, htmlfile))

    all_nuclides = sorted([nucname.zzaaam(nuc) for nuc in all_nuclides])

    energy_tables = {eng: np.zeros(len(all_nuclides), dtype=simple_xs_dtype) for eng in simple_xs_energy.keys()}

    # Loop through species
    for i, nuc_zz in enumerate(all_nuclides):
        nuc_name = nucname.name(nuc_zz)
        filename = os.path.join(build_dir, nuc_name + "_2.html")

        # Loop through all energy types
        for eng in simple_xs_energy:
            energy_tables[eng]["nuc_name"][i] = nuc_name
            energy_tables[eng]["nuc_zz"][i] = nuc_zz

            # Loop trhough reactions
            for chan in simple_xs_channels:
                energy_tables[eng][chan][i] = get_xs_from_file(filename, eng, chan)

    for eng in simple_xs_energy:
        # Store only non-trivial entries
        mask = (
            energy_tables[eng][simple_xs_channels.keys()]
            != np.zeros(1, dtype=simple_xs_dtype)[simple_xs_channels.keys()]
        )
        energy_tables[eng] = energy_tables[eng][mask]

        # Calculate some xs
        energy_tables[eng]["sigma_s"] = energy_tables[eng]["sigma_e"] + energy_tables[eng]["sigma_i"]

        energy_tables[eng]["sigma_a"] = (
            energy_tables[eng]["sigma_gamma"]
            + energy_tables[eng]["sigma_f"]
            + energy_tables[eng]["sigma_alpha"]
            + energy_tables[eng]["sigma_proton"]
            + energy_tables[eng]["sigma_deut"]
            + energy_tables[eng]["sigma_trit"]
            + energy_tables[eng]["sigma_2n"]
            + energy_tables[eng]["sigma_3n"]
            + energy_tables[eng]["sigma_4n"]
        )
    return energy_tables
예제 #4
0
파일: simple_xs.py 프로젝트: rwcarlsen/pyne
def parse_simple_xs(build_dir=""):
    """Builds and returns a dictionary from cross-section types to nuclides."""
    build_dir = os.path.join(build_dir, 'KAERI')

    # Grab and parse elemental summary files.
    all_nuclides = set()
    for element in nucname.name_zz.keys():
        htmlfile = element + '.html'
        all_nuclides = all_nuclides | parse_for_all_isotopes(
            os.path.join(build_dir, htmlfile))

    all_nuclides = sorted([nucname.zzaaam(nuc) for nuc in all_nuclides])

    energy_tables = dict([(eng, np.zeros(len(all_nuclides), dtype=simple_xs_dtype)) \
                          for eng in simple_xs_energy.keys()])

    # Loop through species
    for i, nuc in enumerate(all_nuclides):
        nuc_name = nucname.name(nuc)
        filename = os.path.join(build_dir, nuc_name + '_2.html')

        # Loop through all energy types
        for eng in simple_xs_energy:
            energy_tables[eng]['nuc'][i] = nuc

            # Loop trhough reactions
            for chan in simple_xs_channels:
                energy_tables[eng][chan][i] = get_xs_from_file(
                    filename, eng, chan)

    for eng in simple_xs_energy:
        # Store only non-trivial entries
        mask = (energy_tables[eng][simple_xs_channels.keys()] != np.zeros(
            1, dtype=simple_xs_dtype)[simple_xs_channels.keys()])
        energy_tables[eng] = energy_tables[eng][mask]

        # Calculate some xs
        energy_tables[eng]['sigma_s'] = energy_tables[eng][
            'sigma_e'] + energy_tables[eng]['sigma_i']

        energy_tables[eng]['sigma_a'] = energy_tables[eng]['sigma_gamma'] + \
                                        energy_tables[eng]['sigma_f'] + \
                                        energy_tables[eng]['sigma_alpha'] + \
                                        energy_tables[eng]['sigma_proton'] + \
                                        energy_tables[eng]['sigma_deut'] + \
                                        energy_tables[eng]['sigma_trit'] + \
                                        energy_tables[eng]['sigma_2n'] + \
                                        energy_tables[eng]['sigma_3n'] + \
                                        energy_tables[eng]['sigma_4n']
    return energy_tables
예제 #5
0
def parse_simple_xs(build_dir=""):
    """Builds and returns a dictionary from cross-section types to nuclides."""
    build_dir = os.path.join(build_dir, 'KAERI')

    # Grab and parse elemental summary files.
    all_nuclides = set()
    for element in nucname.name_zz.keys():
        htmlfile = element + '.html'
        all_nuclides = all_nuclides | parse_for_all_isotopes(os.path.join(build_dir, htmlfile))

    all_nuclides = sorted([nucname.zzaaam(nuc) for nuc in all_nuclides])

    energy_tables = dict([(eng, np.zeros(len(all_nuclides), dtype=simple_xs_dtype)) \
                          for eng in simple_xs_energy.keys()])

    # Loop through species
    for i, nuc in enumerate(all_nuclides):
        nuc_name = nucname.name(nuc)
        filename = os.path.join(build_dir, nuc_name + '_2.html')

        # Loop through all energy types
        for eng in simple_xs_energy:
            energy_tables[eng]['nuc'][i] = nuc

            # Loop trhough reactions
            for chan in simple_xs_channels:
                energy_tables[eng][chan][i] = get_xs_from_file(filename, eng, chan)

    for eng in simple_xs_energy:
        # Store only non-trivial entries
        mask = (energy_tables[eng][simple_xs_channels.keys()] != np.zeros(1, dtype=simple_xs_dtype)[simple_xs_channels.keys()])
        energy_tables[eng] = energy_tables[eng][mask]

        # Calculate some xs
        energy_tables[eng]['sigma_s'] = energy_tables[eng]['sigma_e'] + energy_tables[eng]['sigma_i']

        energy_tables[eng]['sigma_a'] = energy_tables[eng]['sigma_gamma'] + \
                                        energy_tables[eng]['sigma_f'] + \
                                        energy_tables[eng]['sigma_alpha'] + \
                                        energy_tables[eng]['sigma_proton'] + \
                                        energy_tables[eng]['sigma_deut'] + \
                                        energy_tables[eng]['sigma_trit'] + \
                                        energy_tables[eng]['sigma_2n'] + \
                                        energy_tables[eng]['sigma_3n'] + \
                                        energy_tables[eng]['sigma_4n']
    return energy_tables