def test_write_tape9(): tape9_file = StringIO() tape9_dict = {1: {'_type': 'decay', 'half_life': {10010: 42.0}, 'title': 'decay1'}, 2: {'_type': 'decay', '_bad_key': None, 'title': 'decay2'}, 3: {'_type': 'decay', 'title': "Sweet Decay"}, 381: {'_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': {10010: 12.0}, 'title': 'xs1'}, 382: {'_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': {922350: 16.0}, 'title': 'xs2'}, 383: {'_type': 'xsfpy', '_subtype': 'fission_products', 'sigma_gamma': {10010: 20.0}, 'title': 'xsfpy3'}, } # Test that basic functionality works origen22.write_tape9(tape9_dict, tape9_file) tape9_file.seek(0) t9str = tape9_file.read() # Try to round-trip full_tape9_file = StringIO(sample_tape9) full_tape9 = origen22.parse_tape9(tape9_file) backout_tape9 = StringIO() origen22.write_tape9(full_tape9, backout_tape9) backout_tape9.seek(0) backin_tape9 = origen22.parse_tape9(backout_tape9) assert_equal(full_tape9, backin_tape9)
def test_write_tape9(): tape9_file = StringIO() tape9_dict = {1: {'_type': 'decay', 'half_life': {10010: 42.0}, 'title': 'decay1'}, 2: {'_type': 'decay', '_bad_key': None, 'title': 'decay2', 'half_life': {922350: 42.0}}, 3: {'_type': 'decay', 'title': "Sweet Decay", 'half_life': {10010: 42.0, 421000: 42.0}}, 381: {'_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': {10010: 12.0}, 'title': 'xs1'}, 382: {'_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': {922350: 16.0}, 'title': 'xs2'}, 383: {'_type': 'xsfpy', '_subtype': 'fission_products', 'sigma_gamma': {10010: 20.0}, 'title': 'xsfpy3', 'U235_fiss_yield': {421000: 42.0}, 'fiss_yields_present': {421000: True}}} # Test that basic functionality works origen22.write_tape9(tape9_dict, tape9_file) tape9_file.seek(0) t9str = tape9_file.readlines() for line in t9str: assert(len(line) <= 81) # 81 since newline is counted in len # Try to round-trip full_tape9_file = StringIO(sample_tape9) full_tape9 = origen22.parse_tape9(full_tape9_file) backout_tape9 = StringIO() origen22.write_tape9(full_tape9, backout_tape9) backout_tape9.seek(0) backin_tape9 = origen22.parse_tape9(backout_tape9)
def execute_origen(xs_tape9, time, nuclide, phi, origen, decay_tape9): xs_tape9 = xs_tape9 if not os.path.isabs(xs_tape9): xs_tape9 = os.path.join(LIBS_DIR, xs_tape9) parsed_xs_tape9 = parse_tape9(xs_tape9) parsed_decay_tape9 = parse_tape9(decay_tape9) merged_tape9 = merge_tape9([parsed_decay_tape9, parsed_xs_tape9]) # Can set outfile to change directory, but the file name needs to be # TAPE9.INP. write_tape9(merged_tape9) decay_nlb, xsfpy_nlb = nlbs(parsed_xs_tape9) # Can set outfile, but the file name should be called TAPE5.INP. write_tape5_irradiation("IRF", time/(60*60*24), phi, xsfpy_nlb=xsfpy_nlb, cut_off=0, out_table_num=[4, 5], out_table_nes=[True, False, False]) M = from_atom_frac({nuclide: 1}, mass=1, atoms_per_molecule=1) write_tape4(M) # Make pyne use naive atomic mass numbers to match ORIGEN for i in pyne.data.atomic_mass_map: pyne.data.atomic_mass_map[i] = float(pyne.nucname.anum(i)) origen_time, data = time_func(run_origen, origen) logger.info("ORIGEN runtime: %s", origen_time) return origen_time, data
def test_write_tape9(): tape9_file = StringIO() tape9_dict = { 1: {"_type": "decay", "half_life": {10010: 42.0}, "title": "decay1"}, 2: { "_type": "decay", "_bad_key": None, "title": "decay2", "half_life": {922350: 42.0}, }, 3: { "_type": "decay", "title": "Sweet Decay", "half_life": {10010: 42.0, 421000: 42.0}, }, 381: { "_type": "xsfpy", "_subtype": "activation_products", "sigma_gamma": {10010: 12.0}, "title": "xs1", }, 382: { "_type": "xsfpy", "_subtype": "actinides", "sigma_f": {922350: 16.0}, "title": "xs2", }, 383: { "_type": "xsfpy", "_subtype": "fission_products", "sigma_gamma": {10010: 20.0}, "title": "xsfpy3", "U235_fiss_yield": {421000: 42.0}, "fiss_yields_present": {421000: True}, }, } # Test that basic functionality works origen22.write_tape9(tape9_dict, tape9_file) tape9_file.seek(0) t9str = tape9_file.readlines() for line in t9str: assert len(line) <= 81 # 81 since newline is counted in len # Try to round-trip full_tape9_file = StringIO(sample_tape9) full_tape9 = origen22.parse_tape9(full_tape9_file) backout_tape9 = StringIO() origen22.write_tape9(full_tape9, backout_tape9) backout_tape9.seek(0) backin_tape9 = origen22.parse_tape9(backout_tape9)
def test_merge_tape9(): tape9_file = StringIO(sample_tape9) tape9_file = origen22.parse_tape9(tape9_file) tape9_dict = {1: {'_type': 'decay', 'half_life': {10010: 42.0}}, 2: {'_type': 'decay', '_bad_key': None}, 3: {'_type': 'decay', 'title': "Sweet Decay"}, 382: {'_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': {922350: 16.0}}, } # merge so that dict takes precedence tape9 = origen22.merge_tape9([tape9_dict, tape9_file]) # run tests assert_equal(tape9[1]['half_life'][10010], 42.0) assert_true('_bad_key' in tape9[2]) assert_equal(tape9[3]['title'], "Sweet Decay") assert_equal(tape9[382]['sigma_f'][922350], 16.0) assert_true('_cards' not in tape9[1]) assert_true('_cards' not in tape9[2]) assert_true('_cards' not in tape9[3]) assert_true('_cards' in tape9[381]) assert_true('_cards' not in tape9[382]) assert_true('_cards' in tape9[383])
def test_merge_tape9(): tape9_file = StringIO(sample_tape9) tape9_file = origen22.parse_tape9(tape9_file) tape9_dict = { 1: {"_type": "decay", "half_life": {10010: 42.0}}, 2: {"_type": "decay", "_bad_key": None}, 3: {"_type": "decay", "title": "Sweet Decay"}, 382: {"_type": "xsfpy", "_subtype": "actinides", "sigma_f": {922350: 16.0}}, } # merge so that dict takes precedence tape9 = origen22.merge_tape9([tape9_dict, tape9_file]) # run tests assert_equal(tape9[1]["half_life"][10010], 42.0) assert_true("_bad_key" in tape9[2]) assert_equal(tape9[3]["title"], "Sweet Decay") assert_equal(tape9[382]["sigma_f"][922350], 16.0) assert_true("_cards" not in tape9[1]) assert_true("_cards" not in tape9[2]) assert_true("_cards" not in tape9[3]) assert_true("_cards" in tape9[381]) assert_true("_cards" not in tape9[382]) assert_true("_cards" in tape9[383])
def find_decaylib(t9, tape9, decaylib): """Finds and loads a decay lib.""" if len({1, 2, 3} & set(t9.keys())) == 3: return t9 if not os.path.isabs(decaylib): d = os.path.dirname(tape9) decaylib = os.path.join(d, decaylib) decay = parse_tape9(decaylib) return decay
def __init__(self, t=0.0, phi=0.0, temp=300.0, tol=1e-7, cwd='', base_tape9=origen22.BASE_TAPE9, xscache=None, o2exe='o2_therm_linux.exe', *args, **kwargs): """Parameters ---------- t : float Transmutations time [sec]. phi : float or array of floats Neutron flux vector [n/cm^2/sec]. Currently this must either be a scalar or match the group structure of EAF. temp : float, optional Temperature [K] of material, defaults to 300.0. tol : float Tolerance level for chain truncation. cwd : str, optional Current working directory for origen runs. Defaults to this dir. base_tape9 : str or dict, optional A base TAPE9.INP file. If this is a str it is interpreted as a path to a file, which is then read in and parsed. If this is a dict, it is assumed to be in the format described in the main origen22 module. xscache : XSCache, optional A cross section cache to generate cross sections with. o2exe : str, optional Name or path to ORIGEN 2.2 executable. args : tuple, optional Other arguments ignored for compatibility with other Transmuters. kwargs : dict, optional Other keyword arguments ignored for compatibility with other Transmuters. """ if not isinstance(base_tape9, Mapping): base_tape9 = origen22.parse_tape9(tape9=base_tape9) self.base_tape9 = base_tape9 if xscache is None: eafds = EAFDataSource() eafds.load(temp=temp) gs = np.array([eafds.src_group_struct[0], eafds.src_group_struct[-1]]) eafds.dst_group_struct = gs xscache = XSCache(group_struct=gs, data_source_classes=[SimpleDataSource, NullDataSource]) xscache.load(temp=temp) xscache.data_sources.insert(0, eafds) self.xscache = xscache self.t = t self._phi = None self.phi = phi self.temp = temp self.tol = tol self.cwd = os.path.abspath(cwd) self.o2exe = o2exe
def __init__(self, *args, **kwargs): tape9 = kwargs.pop('tape9', None) super(OrigenReactorMG, self).__init__(*args, **kwargs) self._nearest_neighbors = [] if tape9 is None: raise ValueError("must supply a default TAPE9 file to OrigenReactorMG.") elif isinstance(tape9, basestring): self._tape9 = origen22.parse_tape9(tape9) elif hasattr(tape9, 'keys'): self._tape9 = tape9 else: # assume sequence of tape9s self._tape9 = origen22.merge_tape9(tape9)
def test_merge_tape9(): tape9_file = StringIO(sample_tape9) tape9_file = origen22.parse_tape9(tape9_file) tape9_dict = { 1: { '_type': 'decay', 'half_life': { 10010: 42.0 } }, 2: { '_type': 'decay', '_bad_key': None }, 3: { '_type': 'decay', 'title': "Sweet Decay" }, 382: { '_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': { 922350: 16.0 } }, } # merge so that dict takes precedence tape9 = origen22.merge_tape9([tape9_dict, tape9_file]) # run tests assert_equal(tape9[1]['half_life'][10010], 42.0) assert_true('_bad_key' in tape9[2]) assert_equal(tape9[3]['title'], "Sweet Decay") assert_equal(tape9[382]['sigma_f'][922350], 16.0) assert_true('_cards' not in tape9[1]) assert_true('_cards' not in tape9[2]) assert_true('_cards' not in tape9[3]) assert_true('_cards' in tape9[381]) assert_true('_cards' not in tape9[382]) assert_true('_cards' in tape9[383])
def test_parse_tape9(): tape9_file = StringIO(sample_tape9) tape9 = origen22.parse_tape9(tape9_file) assert_equal(set(tape9), set([1, 2, 3, 381, 382, 383])) # Activation product decay deck1 = tape9[1] assert_equal(deck1['_type'], 'decay') assert_equal(deck1['title'], 'SAMPLE DECAY LIB: ACTIVATION PRODUCTS') assert_equal(deck1['half_life'][10020], np.inf) assert_equal(deck1['half_life'][10040], 1.000E-03) assert_equal(deck1['half_life'][200410], 8.100E+01 * 31556926.0 * 1E3) assert_equal(deck1['half_life'][781900], 6.000E+02 * 31556926.0 * 1E9) assert_equal(deck1['frac_beta_minus_x'][10010], 0.0) assert_equal(deck1['frac_beta_plus_or_electron_capture'][200410], 1.0) assert_equal(deck1['frac_beta_plus_or_electron_capture_x'][10010], 0.0) assert_equal(deck1['frac_alpha'][781900], 1.0) assert_equal(deck1['frac_isomeric_transition'][10020], 0.0) assert_equal(deck1['frac_spont_fiss'][10020], 0.0) assert_equal(deck1['frac_beta_n'][10020], 0.0) assert_equal(deck1['recoverable_energy'][10030], 5.680E-03) assert_equal(deck1['frac_natural_abund'][10020], 1.500E-02 * 0.01) assert_equal(deck1['inhilation_concentration'][781900], 2.000E-14) assert_equal(deck1['ingestion_concentration'][781900], 3.000E-08) # Actinide Decay deck2 = tape9[2] assert_equal(deck2['_type'], 'decay') assert_equal(deck2['title'], 'SAMPLE DECAY LIB: ACTINIDES') assert_equal(deck2['half_life'][932410], 1.600E+01 * 60.0) assert_equal(deck2['half_life'][942370], 4.560E+01 * 86400.0) # Fission Product Decay deck3 = tape9[3] assert_equal(deck3['_type'], 'decay') assert_equal(deck3['title'], 'SAMPLE DECAY LIB: FISSION PRODUCTS') assert_equal(deck3['half_life'][611460], 5.500E+00 * 31556926.0) assert_equal(deck3['half_life'][621460], 7.000E+01 * 31556926.0 * 1E6) assert_equal(deck3['half_life'][691720], 6.360E+01 * 3600.0) # Activation product cross sections deck381 = tape9[381] assert_equal(deck381['_type'], 'xsfpy') assert_equal(deck381['_subtype'], 'activation_products') assert_equal(deck381['title'], 'SAMPLE ACTIVATION PRODUCT XS LIB') assert_true(all(['_fiss_yield' not in key for key in deck381])) assert_true('sigma_alpha' in deck381) assert_true('sigma_3n' not in deck381) assert_true('sigma_p' in deck381) assert_true('sigma_f' not in deck381) assert_equal(deck381['sigma_gamma'][80170], 7.341E-05) assert_equal(deck381['sigma_2n'][80170], 9.378E-06) assert_equal(deck381['sigma_alpha'][80170], 3.639E-02) assert_equal(deck381['sigma_p'][80170], 3.310E-06) assert_equal(deck381['sigma_gamma_x'][80170], 0.0) assert_equal(deck381['sigma_2n_x'][80170], 0.0) assert_equal(deck381['fiss_yields_present'][80170], False) # Actinide cross sections deck382 = tape9[382] assert_equal(deck382['_type'], 'xsfpy') assert_equal(deck382['_subtype'], 'actinides') assert_equal(deck382['title'], 'SAMPLE ACTINIDE XS LIB') assert_true(all(['_fiss_yield' not in key for key in deck382])) assert_true('sigma_alpha' not in deck382) assert_true('sigma_3n' in deck382) assert_true('sigma_p' not in deck382) assert_true('sigma_f' in deck382) assert_equal(deck382['sigma_gamma'][922380], 2.125E-01) assert_equal(deck382['sigma_2n'][922380], 2.731E-03) assert_equal(deck382['sigma_3n'][922380], 2.132E-05) assert_equal(deck382['sigma_f'][922380], 4.976E-02) assert_equal(deck382['sigma_gamma_x'][922380], 0.0) assert_equal(deck382['sigma_2n_x'][922380], 0.0) assert_equal(deck382['fiss_yields_present'][922380], False) # Fission product cross sections deck383 = tape9[383] assert_equal(deck383['_type'], 'xsfpy') assert_equal(deck383['_subtype'], 'fission_products') assert_equal(deck383['title'], 'SAMPLE FISSION PRODUCT YIELD') assert_true(any(['_fiss_yield' in key for key in deck383])) assert_true('sigma_alpha' in deck383) assert_true('sigma_3n' not in deck383) assert_true('sigma_p' in deck383) assert_true('sigma_f' not in deck383) assert_equal(deck383['sigma_gamma'][300670], 2.600E-02) assert_equal(deck383['sigma_2n'][300670], 0.0) assert_equal(deck383['sigma_alpha'][300670], 3.512E-09) assert_equal(deck383['sigma_p'][300670], 0.0) assert_equal(deck383['sigma_gamma_x'][300670], 0.0) assert_equal(deck383['sigma_2n_x'][300670], 0.0) assert_equal(deck383['fiss_yields_present'][300670], True) assert_equal(deck383['TH232_fiss_yield'][300670], 0.0) assert_equal(deck383['U233_fiss_yield'][300670], 2.50E-09) assert_equal(deck383['U235_fiss_yield'][300670], 3.84E-10) assert_equal(deck383['U238_fiss_yield'][300670], 4.60E-12) assert_equal(deck383['PU239_fiss_yield'][300670], 2.14E-11) assert_equal(deck383['PU241_fiss_yield'][300670], 0.0) assert_equal(deck383['CM245_fiss_yield'][300670], 0.0) assert_equal(deck383['CF249_fiss_yield'][300670], 0.0)
def test_write_tape9(): tape9_file = StringIO() tape9_dict = { 1: { '_type': 'decay', 'half_life': { 10010: 42.0 }, 'title': 'decay1' }, 2: { '_type': 'decay', '_bad_key': None, 'title': 'decay2' }, 3: { '_type': 'decay', 'title': "Sweet Decay" }, 381: { '_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': { 10010: 12.0 }, 'title': 'xs1' }, 382: { '_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': { 922350: 16.0 }, 'title': 'xs2' }, 383: { '_type': 'xsfpy', '_subtype': 'fission_products', 'sigma_gamma': { 10010: 20.0 }, 'title': 'xsfpy3' }, } # Test that basic functionality works origen22.write_tape9(tape9_dict, tape9_file) tape9_file.seek(0) t9str = tape9_file.read() # Try to round-trip full_tape9_file = StringIO(sample_tape9) full_tape9 = origen22.parse_tape9(tape9_file) backout_tape9 = StringIO() origen22.write_tape9(full_tape9, backout_tape9) backout_tape9.seek(0) backin_tape9 = origen22.parse_tape9(backout_tape9) assert_equal(full_tape9, backin_tape9)
def test_parse_tape9(): tape9_file = StringIO(sample_tape9) tape9 = origen22.parse_tape9(tape9_file) assert_equal(set(tape9.keys()), set([1, 2, 3, 381, 382, 383])) # Activation product decay deck1 = tape9[1] assert_equal(deck1['_type'], 'decay') assert_equal(deck1['title'], 'SAMPLE DECAY LIB: ACTIVATION PRODUCTS') assert_equal(deck1['half_life'][10020], np.inf) assert_equal(deck1['half_life'][10040], 1.000E-03) assert_equal(deck1['half_life'][200410], 8.100E+01 * 31556926.0 * 1E3) assert_equal(deck1['half_life'][781900], 6.000E+02 * 31556926.0 * 1E9) assert_equal(deck1['frac_beta_minus_x'][10010], 0.0) assert_equal(deck1['frac_beta_plus_or_electron_capture'][200410], 1.0) assert_equal(deck1['frac_beta_plus_or_electron_capture_x'][10010], 0.0) assert_equal(deck1['frac_alpha'][781900], 1.0) assert_equal(deck1['frac_isomeric_transition'][10020], 0.0) assert_equal(deck1['frac_spont_fiss'][10020], 0.0) assert_equal(deck1['frac_beta_n'][10020], 0.0) assert_equal(deck1['recoverable_energy'][10030], 5.680E-03) assert_equal(deck1['frac_natural_abund'][10020], 1.500E-02 * 0.01) assert_equal(deck1['inhilation_concentration'][781900], 2.000E-14) assert_equal(deck1['ingestion_concentration'][781900], 3.000E-08) # Actinide Decay deck2 = tape9[2] assert_equal(deck2['_type'], 'decay') assert_equal(deck2['title'], 'SAMPLE DECAY LIB: ACTINIDES') assert_equal(deck2['half_life'][932410], 1.600E+01 * 60.0) assert_equal(deck2['half_life'][942370], 4.560E+01 * 86400.0) # Fission Product Decay deck3 = tape9[3] assert_equal(deck3['_type'], 'decay') assert_equal(deck3['title'], 'SAMPLE DECAY LIB: FISSION PRODUCTS') assert_equal(deck3['half_life'][611460], 5.500E+00 * 31556926.0) assert_equal(deck3['half_life'][621460], 7.000E+01 * 31556926.0 * 1E6) assert_equal(deck3['half_life'][691720], 6.360E+01 * 3600.0) # Activation product cross sections deck381 = tape9[381] assert_equal(deck381['_type'], 'xsfpy') assert_equal(deck381['_subtype'], 'activation_products') assert_equal(deck381['title'], 'SAMPLE ACTIVATION PRODUCT XS LIB') assert_true(all(['_fiss_yield' not in key for key in deck381.keys()])) assert_true('sigma_alpha' in deck381) assert_true('sigma_3n' not in deck381) assert_true('sigma_p' in deck381) assert_true('sigma_f' not in deck381) assert_equal(deck381['sigma_gamma'][80170], 7.341E-05) assert_equal(deck381['sigma_2n'][80170], 9.378E-06) assert_equal(deck381['sigma_alpha'][80170], 3.639E-02) assert_equal(deck381['sigma_p'][80170], 3.310E-06) assert_equal(deck381['sigma_gamma_x'][80170], 0.0) assert_equal(deck381['sigma_2n_x'][80170], 0.0) assert_equal(deck381['fiss_yields_present'][80170], False) # Actinide cross sections deck382 = tape9[382] assert_equal(deck382['_type'], 'xsfpy') assert_equal(deck382['_subtype'], 'actinides') assert_equal(deck382['title'], 'SAMPLE ACTINIDE XS LIB') assert_true(all(['_fiss_yield' not in key for key in deck382.keys()])) assert_true('sigma_alpha' not in deck382) assert_true('sigma_3n' in deck382) assert_true('sigma_p' not in deck382) assert_true('sigma_f' in deck382) assert_equal(deck382['sigma_gamma'][922380], 2.125E-01) assert_equal(deck382['sigma_2n'][922380], 2.731E-03) assert_equal(deck382['sigma_3n'][922380], 2.132E-05) assert_equal(deck382['sigma_f'][922380], 4.976E-02) assert_equal(deck382['sigma_gamma_x'][922380], 0.0) assert_equal(deck382['sigma_2n_x'][922380], 0.0) assert_equal(deck382['fiss_yields_present'][922380], False) # Fission product cross sections deck383 = tape9[383] assert_equal(deck383['_type'], 'xsfpy') assert_equal(deck383['_subtype'], 'fission_products') assert_equal(deck383['title'], 'SAMPLE FISSION PRODUCT YIELD') assert_true(any(['_fiss_yield' in key for key in deck383.keys()])) assert_true('sigma_alpha' in deck383) assert_true('sigma_3n' not in deck383) assert_true('sigma_p' in deck383) assert_true('sigma_f' not in deck383) assert_equal(deck383['sigma_gamma'][300670], 2.600E-02) assert_equal(deck383['sigma_2n'][300670], 0.0) assert_equal(deck383['sigma_alpha'][300670], 3.512E-09) assert_equal(deck383['sigma_p'][300670], 0.0) assert_equal(deck383['sigma_gamma_x'][300670], 0.0) assert_equal(deck383['sigma_2n_x'][300670], 0.0) assert_equal(deck383['fiss_yields_present'][300670], True) assert_equal(deck383['TH232_fiss_yield'][300670], 0.0) assert_equal(deck383['U233_fiss_yield'][300670], 2.50E-09) assert_equal(deck383['U235_fiss_yield'][300670], 3.84E-10) assert_equal(deck383['U238_fiss_yield'][300670], 4.60E-12) assert_equal(deck383['PU239_fiss_yield'][300670], 2.14E-11) assert_equal(deck383['PU241_fiss_yield'][300670], 0.0) assert_equal(deck383['CM245_fiss_yield'][300670], 0.0) assert_equal(deck383['CF249_fiss_yield'][300670], 0.0)
def test_write_tape9(): tape9_file = StringIO() tape9_dict = { 1: { '_type': 'decay', 'half_life': { 10010: 42.0 }, 'title': 'decay1' }, 2: { '_type': 'decay', '_bad_key': None, 'title': 'decay2', 'half_life': { 922350: 42.0 } }, 3: { '_type': 'decay', 'title': "Sweet Decay", 'half_life': { 10010: 42.0, 421000: 42.0 } }, 381: { '_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': { 10010: 12.0 }, 'title': 'xs1' }, 382: { '_type': 'xsfpy', '_subtype': 'actinides', 'sigma_f': { 922350: 16.0 }, 'title': 'xs2' }, 383: { '_type': 'xsfpy', '_subtype': 'fission_products', 'sigma_gamma': { 10010: 20.0 }, 'title': 'xsfpy3', 'U235_fiss_yield': { 421000: 42.0 }, 'fiss_yields_present': { 421000: True } } } # Test that basic functionality works origen22.write_tape9(tape9_dict, tape9_file) tape9_file.seek(0) t9str = tape9_file.readlines() for line in t9str: assert (len(line) <= 81) # 81 since newline is counted in len # Try to round-trip full_tape9_file = StringIO(sample_tape9) full_tape9 = origen22.parse_tape9(full_tape9_file) backout_tape9 = StringIO() origen22.write_tape9(full_tape9, backout_tape9) backout_tape9.seek(0) backin_tape9 = origen22.parse_tape9(backout_tape9)
def test_parse_tape9(): tape9_file = StringIO(sample_tape9) tape9 = origen22.parse_tape9(tape9_file) assert_equal(set(tape9), set([1, 2, 3, 381, 382, 383])) # Activation product decay deck1 = tape9[1] assert_equal(deck1["_type"], "decay") assert_equal(deck1["title"], "SAMPLE DECAY LIB: ACTIVATION PRODUCTS") assert_equal(deck1["half_life"][10020], np.inf) assert_equal(deck1["half_life"][10040], 1.000e-03) assert_equal(deck1["half_life"][200410], 8.100e01 * 31556926.0 * 1e3) assert_equal(deck1["half_life"][781900], 6.000e02 * 31556926.0 * 1e9) assert_equal(deck1["frac_beta_minus_x"][10010], 0.0) assert_equal(deck1["frac_beta_plus_or_electron_capture"][200410], 1.0) assert_equal(deck1["frac_beta_plus_or_electron_capture_x"][10010], 0.0) assert_equal(deck1["frac_alpha"][781900], 1.0) assert_equal(deck1["frac_isomeric_transition"][10020], 0.0) assert_equal(deck1["frac_spont_fiss"][10020], 0.0) assert_equal(deck1["frac_beta_n"][10020], 0.0) assert_equal(deck1["recoverable_energy"][10030], 5.680e-03) assert_equal(deck1["frac_natural_abund"][10020], 1.500e-02 * 0.01) assert_equal(deck1["inhilation_concentration"][781900], 2.000e-14) assert_equal(deck1["ingestion_concentration"][781900], 3.000e-08) # Actinide Decay deck2 = tape9[2] assert_equal(deck2["_type"], "decay") assert_equal(deck2["title"], "SAMPLE DECAY LIB: ACTINIDES") assert_equal(deck2["half_life"][932410], 1.600e01 * 60.0) assert_equal(deck2["half_life"][942370], 4.560e01 * 86400.0) # Fission Product Decay deck3 = tape9[3] assert_equal(deck3["_type"], "decay") assert_equal(deck3["title"], "SAMPLE DECAY LIB: FISSION PRODUCTS") assert_equal(deck3["half_life"][611460], 5.500e00 * 31556926.0) assert_equal(deck3["half_life"][621460], 7.000e01 * 31556926.0 * 1e6) assert_equal(deck3["half_life"][691720], 6.360e01 * 3600.0) # Activation product cross sections deck381 = tape9[381] assert_equal(deck381["_type"], "xsfpy") assert_equal(deck381["_subtype"], "activation_products") assert_equal(deck381["title"], "SAMPLE ACTIVATION PRODUCT XS LIB") assert_true(all(["_fiss_yield" not in key for key in deck381])) assert_true("sigma_alpha" in deck381) assert_true("sigma_3n" not in deck381) assert_true("sigma_p" in deck381) assert_true("sigma_f" not in deck381) assert_equal(deck381["sigma_gamma"][80170], 7.341e-05) assert_equal(deck381["sigma_2n"][80170], 9.378e-06) assert_equal(deck381["sigma_alpha"][80170], 3.639e-02) assert_equal(deck381["sigma_p"][80170], 3.310e-06) assert_equal(deck381["sigma_gamma_x"][80170], 0.0) assert_equal(deck381["sigma_2n_x"][80170], 0.0) assert_equal(deck381["fiss_yields_present"][80170], False) # Actinide cross sections deck382 = tape9[382] assert_equal(deck382["_type"], "xsfpy") assert_equal(deck382["_subtype"], "actinides") assert_equal(deck382["title"], "SAMPLE ACTINIDE XS LIB") assert_true(all(["_fiss_yield" not in key for key in deck382])) assert_true("sigma_alpha" not in deck382) assert_true("sigma_3n" in deck382) assert_true("sigma_p" not in deck382) assert_true("sigma_f" in deck382) assert_equal(deck382["sigma_gamma"][922380], 2.125e-01) assert_equal(deck382["sigma_2n"][922380], 2.731e-03) assert_equal(deck382["sigma_3n"][922380], 2.132e-05) assert_equal(deck382["sigma_f"][922380], 4.976e-02) assert_equal(deck382["sigma_gamma_x"][922380], 0.0) assert_equal(deck382["sigma_2n_x"][922380], 0.0) assert_equal(deck382["fiss_yields_present"][922380], False) # Fission product cross sections deck383 = tape9[383] assert_equal(deck383["_type"], "xsfpy") assert_equal(deck383["_subtype"], "fission_products") assert_equal(deck383["title"], "SAMPLE FISSION PRODUCT YIELD") assert_true(any(["_fiss_yield" in key for key in deck383])) assert_true("sigma_alpha" in deck383) assert_true("sigma_3n" not in deck383) assert_true("sigma_p" in deck383) assert_true("sigma_f" not in deck383) assert_equal(deck383["sigma_gamma"][300670], 2.600e-02) assert_equal(deck383["sigma_2n"][300670], 0.0) assert_equal(deck383["sigma_alpha"][300670], 3.512e-09) assert_equal(deck383["sigma_p"][300670], 0.0) assert_equal(deck383["sigma_gamma_x"][300670], 0.0) assert_equal(deck383["sigma_2n_x"][300670], 0.0) assert_equal(deck383["fiss_yields_present"][300670], True) assert_equal(deck383["TH232_fiss_yield"][300670], 0.0) assert_equal(deck383["U233_fiss_yield"][300670], 2.50e-09) assert_equal(deck383["U235_fiss_yield"][300670], 3.84e-10) assert_equal(deck383["U238_fiss_yield"][300670], 4.60e-12) assert_equal(deck383["PU239_fiss_yield"][300670], 2.14e-11) assert_equal(deck383["PU241_fiss_yield"][300670], 0.0) assert_equal(deck383["CM245_fiss_yield"][300670], 0.0) assert_equal(deck383["CF249_fiss_yield"][300670], 0.0)
def tape9_to_sparse(tape9s, phi, format='csr', decaylib='decay.lib', include_fission=True, alpha_as_He4=False): """Converts a TAPE9 file to a sparse matrix. Parameters ---------- tape9s : str or list of str The filename(s) of the tape file(s). phi : float The neutron flux in [n / cm^2 / sec] format : str, optional Format of the sparse matrix created. decaylib : str, optional A path to TAPE9 containg the decay data libraries if the decay libraries are not present in tape9. If this is a relative path, it is taken relative to the given tape9 location. include_fission : bool Flag for whether or not the fission data should be included in the resultant matrix. Returns ------- mat : scipy.sparse matrix A sparse matrix in the specified layout. nucs : list The list of nuclide names in canonical order. """ all_decays_consts, all_gammas, all_sigma_ij, all_sigma_fission, all_fission_product_yields = [], [], [], [], [] all_alpha_ij, all_gamma_alphas = [], [] nucs = set() mats = [] # seed initial nucs with known atomic masses data.atomic_mass('u235') for tape9 in tape9s: print("Getting data for", tape9) t9 = parse_tape9(tape9) decay = find_decaylib(t9, tape9, decaylib) for i in data.atomic_mass_map.keys(): if nucname.iselement(i): continue try: nucs.add(nucname.name(i)) except RuntimeError: pass # get the tape 9 data nucs, decays_consts, gammas, gammas_alphas = decay_data(decay, nucs=nucs) nucs, sigma_ij, sigma_fission, fission_product_yields, alpha_ij = cross_section_data( t9, nucs=nucs) if not include_fission: sigma_fission = {} fission_product_yields = {} if not alpha_as_He4: gammas_alphas = {} alpha_ij = {} all_decays_consts.append(decays_consts) all_gammas.append(gammas) all_sigma_ij.append(sigma_ij) all_sigma_fission.append(sigma_fission) all_fission_product_yields.append(fission_product_yields) all_alpha_ij.append(alpha_ij) all_gamma_alphas.append(gammas_alphas) nucs = sort_nucs(nucs) for i in range(len(tape9s)): dok = create_dok(phi, nucs, all_decays_consts[i], all_gammas[i], all_sigma_ij[i], all_sigma_fission[i], all_fission_product_yields[i], all_alpha_ij[i], all_gamma_alphas[i]) rows, cols, vals, shape = dok_to_sparse_info(nucs, dok) mats.append(SPMAT_FORMATS[format]((vals, (rows, cols)), shape=shape)) return mats, nucs
water.mass = 1E3 # Make a tape4 file for water origen22.write_tape4(water) # Make a tape 5 for this calculation # * Just output the concentration tables # * The cross-section library numbers must # the library / deck numbers in tape9 origen22.write_tape5_irradiation("IRF", 1000.0, 4E14, xsfpy_nlb=(381, 382, 383), out_table_num=[5]) # Grab a base tape9 from which we will overlay new values # This must be supplied by the user base_tape9 = origen22.parse_tape9("BASE_TAPE9.INP") base_h1_xs = base_tape9[381]['sigma_gamma'][10010] # Init a dumb overlay tape9 overlay_tape9 = {381: {'_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': {10010: base_h1_xs}, } } # Run origen, increasing the cross section each time. h2_concentration = [] for i in range(11): overlay_tape9[381]['sigma_gamma'][10010] = (1.0 + i*0.1) * base_h1_xs
# Make a tape4 file for water origen22.write_tape4(water) # Make a tape 5 for this calculation # * Just output the concentration tables # * The cross-section library numbers must # the library / deck numbers in tape9 origen22.write_tape5_irradiation("IRF", 1000.0, 4E14, xsfpy_nlb=(381, 382, 383), out_table_num=[5]) # Grab a base tape9 from which we will overlay new values # This must be supplied by the user base_tape9 = origen22.parse_tape9("BASE_TAPE9.INP") base_h1_xs = base_tape9[381]['sigma_gamma'][10010] # Init a dumb overlay tape9 overlay_tape9 = { 381: { '_type': 'xsfpy', '_subtype': 'activation_products', 'sigma_gamma': { 10010: base_h1_xs }, } } # Run origen, increasing the cross section each time.