def test_parse_tape6_PWRM021(): "Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwrmox_orlibj33/PWRM0210.out" r = origen22.parse_tape6('tape6_PWRM0210.test') assert_true(0 < len(r)) assert_array_equal(r['time_sec'], [0.00E+00, 1.21E+07, 2.42E+07, 3.63E+07, 4.84E+07, 6.05E+07, 7.26E+07, 8.47E+07, 9.68E+07, 1.09E+08, 1.21E+08, 1.33E+08]) assert_array_equal(r['average_flux'], [0.00E+00, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14]) tab_keys = set(['table_{0}'.format(n) for n in [5]]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true(set(r[tk][ttype]) <= set(['title', 'units', 'activation_products', 'actinides', 'fission_products'])) assert_array_equal(r['alpha_neutron_source']['CM242'], [0.00000E+00, 8.50160E+08, 1.28411E+09, 1.48965E+09, 1.57830E+09, 1.60855E+09, 1.61128E+09, 1.60202E+09, 1.58856E+09, 1.57406E+09, 1.55987E+09, 1.54529E+09]) assert_array_equal(r['spont_fiss_neutron_source']['PU238'], [5.58385E+06, 5.52908E+06, 5.68992E+06, 5.94790E+06, 6.24106E+06, 6.53804E+06, 6.82350E+06, 7.09041E+06, 7.33580E+06, 7.55876E+06, 7.75904E+06, 7.93683E+06]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
def test_parse_tape6(): r = origen22.parse_tape6('tape6.test') assert_true(0 < len(r)) assert_array_equal(r['time_sec'], [0.0, 8.64E+06]) assert_array_equal(r['flux'], [0.0, 1.71E+17]) assert_array_equal(r['specific_power_MW'], [0.0, 5.50E-01]) assert_array_equal(r['burnup_MWD'], [0.0, 5.50E+01]) assert_array_equal(r['k_inf'], [0.0, 0.08498]) assert_array_equal(r['neutron_production_rate'], [0.0, 2.97E-04]) assert_array_equal(r['neutron_destruction_rate'], [0.0, 3.50E-03]) assert_array_equal(r['total_burnup'], [0.0, 5.50E+01]) assert_array_equal(r['average_flux'], [0.0, 1.71E+17]) assert_array_equal(r['average_specific_power'], [0.0, 5.50E-01]) tab_keys = set(['table_{0}'.format(n) for n in list(range(1, 11)) + list(range(13, 25))]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true(set(r[tk][ttype]) <= set(['title', 'units', 'activation_products', 'actinides', 'fission_products'])) assert_array_equal(r['alpha_neutron_source']['U235'], [7.509E-04, 2.442E-14]) assert_array_equal(r['spont_fiss_neutron_source']['ES255'], [0.000E+00, 1.917E+05]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
def test_parse_tape6_sf97(): """Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwruo2_orlibj33/SF97-4.out""" r = origen22.parse_tape6('tape6_SF97_4.test') assert_true(0 < len(r)) assert_array_equal(r['time_sec'], [1.07E+08, 1.11E+08, 1.13E+08, 1.15E+08, 1.16E+08, 1.16E+08, 1.25E+08]) assert_array_equal(r['k_inf'], [1.17263, 1.16222, 1.15412, 1.14823, 1.14351, 1.14351, 1.14238]) tab_keys = set(['table_{0}'.format(n) for n in [5]]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true(set(r[tk][ttype]) <= set(['title', 'units', 'activation_products', 'actinides', 'fission_products'])) assert_array_equal(r['alpha_neutron_source']['PU240'], [4.51852E+05, 4.62660E+05, 4.71046E+05, 4.76390E+05, 4.81151E+05, 4.81151E+05, 4.82556E+05]) assert_array_equal(r['spont_fiss_neutron_source']['CM246'], [2.78744E+06, 3.40763E+06, 3.98241E+06, 4.41669E+06, 4.83645E+06, 4.83645E+06, 4.83365E+06]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
def test_parse_tape6(): """Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwruo2_orlibj33/SF97-4.out""" r = origen22.parse_tape6('tape6_SF97_4.test') assert_true(0 < len(r)) assert_array_equal( r['time_sec'], [1.07E+08, 1.11E+08, 1.13E+08, 1.15E+08, 1.16E+08, 1.16E+08, 1.25E+08]) assert_array_equal( r['k_inf'], [1.17263, 1.16222, 1.15412, 1.14823, 1.14351, 1.14351, 1.14238]) tab_keys = set(['table_{0}'.format(n) for n in [5]]) assert_true(tab_keys <= set(r.keys())) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true( set(r[tk][ttype].keys()) <= set([ 'title', 'units', 'activation_products', 'actinides', 'fission_products' ])) assert_array_equal(r['alpha_neutron_source']['PU240'], [ 4.51852E+05, 4.62660E+05, 4.71046E+05, 4.76390E+05, 4.81151E+05, 4.81151E+05, 4.82556E+05 ]) assert_array_equal(r['spont_fiss_neutron_source']['CM246'], [ 2.78744E+06, 3.40763E+06, 3.98241E+06, 4.41669E+06, 4.83645E+06, 4.83645E+06, 4.83365E+06 ]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
def test_parse_tape6(): r = origen22.parse_tape6('tape6.test') assert_true(0 < len(r)) assert_array_equal(r['time_sec'], [0.0, 8.64E+06]) assert_array_equal(r['flux'], [0.0, 1.71E+17]) assert_array_equal(r['specific_power_MW'], [0.0, 5.50E-01]) assert_array_equal(r['burnup_MWD'], [0.0, 5.50E+01]) assert_array_equal(r['k_inf'], [0.0, 0.08498]) assert_array_equal(r['neutron_production_rate'], [0.0, 2.97E-04]) assert_array_equal(r['neutron_destruction_rate'], [0.0, 3.50E-03]) assert_array_equal(r['total_burnup'], [0.0, 5.50E+01]) assert_array_equal(r['average_flux'], [0.0, 1.71E+17]) assert_array_equal(r['average_specific_power'], [0.0, 5.50E-01]) tab_keys = set( ['table_{0}'.format(n) for n in range(1, 11) + range(13, 25)]) assert_true(tab_keys <= set(r.keys())) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true( set(r[tk][ttype].keys()) <= set([ 'title', 'units', 'activation_products', 'actinides', 'fission_products' ])) assert_array_equal(r['alpha_neutron_source']['U235'], [7.509E-04, 2.442E-14]) assert_array_equal(r['spont_fiss_neutron_source']['ES255'], [0.000E+00, 1.917E+05]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
def _origen(origen_params): """Run ORIGEN on a state. Parameters ---------- state : namedtuple (State) A namedtuple containing the state parameters. transmute_time : float Length of transmutation timestep. phi_tot : float Total neutron flux. mat_id : str or int The material to start transmuting. Either "fuel" or a nuclide in ID form. Returns ------- results : dict Dictionary with neutron production and destruction rates, burnup, and transmutation results. """ abs_time, transmute_time, phi_tot, mat_id, mat, pwd, origen_call = origen_params mat.mass = 1000 mat.attrs = {"units": "g"} with indir(pwd): if not os.path.isfile("TAPE6.OUT"): # make_inputs(transmute_time, phi_tot, mat) times_called = 0 while times_called < 3: times_called += 1 try: subprocess.check_call(origen_call) break except subprocess.CalledProcessError: print("Warning: ORIGEN2.2 in " + pwd + "failed. Retrying.") print("Parsing " + pwd + "/TAPE6.OUT...") tape6 = origen22.parse_tape6("TAPE6.OUT") out_mat = tape6["materials"][-1] out_mat.mass = 1000 out_mat.comp = {n: frac for n, frac in out_mat.comp.items() if frac != 0} if mat_id == "fuel": out_mat.atoms_per_molecule = 3 burnup = tape6["burnup_MWD"][-1] neutron_prod = tape6["neutron_production_rate"][-1] neutron_dest = tape6["neutron_destruction_rate"][-1] results = (mat_id, { "TIME": abs_time, "NEUT_PROD": neutron_prod, "NEUT_DEST": neutron_dest, "BUd": burnup, "material": list(out_mat.comp.items()), "phi_tot": phi_tot }) return results
def test_parse_tape6_sf97(): """Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwruo2_orlibj33/SF97-4.out""" r = origen22.parse_tape6("tape6_SF97_4.test") assert_true(0 < len(r)) assert_array_equal( r["time_sec"], [1.07e08, 1.11e08, 1.13e08, 1.15e08, 1.16e08, 1.16e08, 1.25e08] ) assert_array_equal( r["k_inf"], [1.17263, 1.16222, 1.15412, 1.14823, 1.14351, 1.14351, 1.14238] ) tab_keys = set(["table_{0}".format(n) for n in [5]]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ["nuclide", "element", "summary"]: if ttype in r[tk]: assert_true( set(r[tk][ttype]) <= set( [ "title", "units", "activation_products", "actinides", "fission_products", ] ) ) assert_array_equal( r["alpha_neutron_source"]["PU240"], [ 4.51852e05, 4.62660e05, 4.71046e05, 4.76390e05, 4.81151e05, 4.81151e05, 4.82556e05, ], ) assert_array_equal( r["spont_fiss_neutron_source"]["CM246"], [ 2.78744e06, 3.40763e06, 3.98241e06, 4.41669e06, 4.83645e06, 4.83645e06, 4.83365e06, ], ) assert_true("materials" in r) assert_equal(len(r["materials"]), len(r["time_sec"]))
def calc_transmutation(self): """Use ORIGEN as a backend to perform the transmutation calculation.""" K = self.K s = self.bt_s T_it = self.T_it # Make origen cross section library t9 = origen22.merge_tape9([self._xs, self._tape9]) origen22.write_tape9(t9) # Make input mass stream mat = Material({iso: 1E3 * T_it[iso][s] for iso in K}) origen22.write_tape4(mat) # Make origen input file irr_type = 'IRP' irr_time = self.burn_times[s+1] - self.burn_times[s] irr_value = self.specific_power t5kw = { 'decay_nlb': sorted(nlb for nlb in t9.keys() if t9[nlb]['_type'] == 'decay')[:3], 'xsfpy_nlb': sorted(nlb for nlb in t9.keys() if t9[nlb]['_type'] == 'xsfpy')[:3], 'out_table_nes': (True, False, False), 'cut_off': 1E-300, 'out_table_num': [5], } origen22.write_tape5_irradiation(irr_type, irr_time, irr_value, **t5kw) # Run origen rtn = subprocess.check_call("o2_therm_linux.exe", shell=True) # Parse origen output res = origen22.parse_tape6() #outvec = {key: sum([v[-1] for v in value]) * 1E-3 for key, value in res['table_5']['nuclide']['data'].items() if (key in K) and not np.isnan(value).any()} outvec = res['materials'][-1].comp nullvec = {k: 0.0 for k in K if k not in outvec} outvec.update(nullvec) # update the transmutation matrix sp1 = s + 1 for nuc in K: T_it[nuc][sp1] = outvec[nuc] self.T_it = T_it # update the burnup BU_t = self.BU_t deltaBU = irr_time * irr_value BU_t[sp1] = BU_t[s] + deltaBU self.BU_t = BU_t print " BU_t = {0}".format(BU_t[sp1])
def test_parse_tape6(): r = origen22.parse_tape6("tape6.test") assert_true(0 < len(r)) assert_array_equal(r["time_sec"], [0.0, 8.64e06]) assert_array_equal(r["flux"], [0.0, 1.71e17]) assert_array_equal(r["specific_power_MW"], [0.0, 5.50e-01]) assert_array_equal(r["burnup_MWD"], [0.0, 5.50e01]) assert_array_equal(r["k_inf"], [0.0, 0.08498]) assert_array_equal(r["neutron_production_rate"], [0.0, 2.97e-04]) assert_array_equal(r["neutron_destruction_rate"], [0.0, 3.50e-03]) assert_array_equal(r["total_burnup"], [0.0, 5.50e01]) assert_array_equal(r["average_flux"], [0.0, 1.71e17]) assert_array_equal(r["average_specific_power"], [0.0, 5.50e-01]) tab_keys = set( ["table_{0}".format(n) for n in list(range(1, 11)) + list(range(13, 25))] ) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ["nuclide", "element", "summary"]: if ttype in r[tk]: assert_true( set(r[tk][ttype]) <= set( [ "title", "units", "activation_products", "actinides", "fission_products", ] ) ) assert_array_equal(r["alpha_neutron_source"]["U235"], [7.509e-04, 2.442e-14]) assert_array_equal(r["spont_fiss_neutron_source"]["ES255"], [0.000e00, 1.917e05]) assert_true("materials" in r) assert_equal(len(r["materials"]), len(r["time_sec"]))
def test_parse_tape6_PWRM021(): "Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwrmox_orlibj33/PWRM0210.out" r = origen22.parse_tape6('tape6_PWRM0210.test') assert_true(0 < len(r)) assert_array_equal(r['time_sec'], [ 0.00E+00, 1.21E+07, 2.42E+07, 3.63E+07, 4.84E+07, 6.05E+07, 7.26E+07, 8.47E+07, 9.68E+07, 1.09E+08, 1.21E+08, 1.33E+08 ]) assert_array_equal(r['average_flux'], [ 0.00E+00, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14, 3.46E+14 ]) tab_keys = set(['table_{0}'.format(n) for n in [5]]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ['nuclide', 'element', 'summary']: if ttype in r[tk]: assert_true( set(r[tk][ttype]) <= set([ 'title', 'units', 'activation_products', 'actinides', 'fission_products' ])) assert_array_equal(r['alpha_neutron_source']['CM242'], [ 0.00000E+00, 8.50160E+08, 1.28411E+09, 1.48965E+09, 1.57830E+09, 1.60855E+09, 1.61128E+09, 1.60202E+09, 1.58856E+09, 1.57406E+09, 1.55987E+09, 1.54529E+09 ]) assert_array_equal(r['spont_fiss_neutron_source']['PU238'], [ 5.58385E+06, 5.52908E+06, 5.68992E+06, 5.94790E+06, 6.24106E+06, 6.53804E+06, 6.82350E+06, 7.09041E+06, 7.33580E+06, 7.55876E+06, 7.75904E+06, 7.93683E+06 ]) assert_true('materials' in r) assert_equal(len(r['materials']), len(r['time_sec']))
}, } } # 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 # Merge the base and overlay, and write out new_tape9 = origen22.merge_tape9([overlay_tape9, base_tape9]) origen22.write_tape9(new_tape9, 'TAPE9.INP') # Run and parse origen output rtn = check_call(['o2_therm_linux.exe']) tape6 = origen22.parse_tape6('TAPE6.OUT') h2_concentration.append( tape6['table_5']['summary']['activation_products']['H2'][-1]) print print "H2 Concentration: ", h2_concentration # Clean up import os for f in os.listdir('.'): if (f.endswith('.INP') or f.endswith('.OUT')) and f != 'BASE_TAPE9.INP': os.remove(f) # Try to plot the results try: import matplotlib.pyplot as plt
def _origen(origen_params): """Run ORIGEN on a state. Parameters ---------- origen_params : dict A dictionary containing the following parameters: abs_time : float The absolute time (relative to 0 days) that the transmutation occurs at. transmute_time : float Length of transmutation timestep - time relative to absolute time of last timestep. phi_tot : float Total neutron flux. mat_id : str or int The identifier of a material to start transmuting. Either "fuel" or a nuclide in ID form. mat : pyne.material.Material The material to be transmuted. pwd : str The directory to run ORIGEN in. origen_call : str The shell command for running ORIGEN. Returns ------- results : dict Dictionary with neutron production and destruction rates, burnup, and transmutation results. """ abs_time, transmute_time, phi_tot, mat_id, mat, pwd, origen_call = origen_params mat.mass = 1000 mat.attrs = {"units": "g"} with indir(pwd): if not os.path.isfile("TAPE6.OUT"): times_called = 0 while times_called < 3: times_called += 1 try: subprocess.check_call(origen_call) break except subprocess.CalledProcessError: print("Warning: ORIGEN2.2 in " + pwd + "failed. Retrying.") print("Parsing " + pwd + "/TAPE6.OUT...") tape6 = origen22.parse_tape6("TAPE6.OUT") out_mat = tape6["materials"][-1] out_mat.mass = 1000 out_mat.comp = {n: frac for n, frac in out_mat.comp.items() if frac != 0} if mat_id == "fuel": out_mat.atoms_per_molecule = 3 burnup = tape6["burnup_MWD"][-1] neutron_prod = tape6["neutron_production_rate"][-1] neutron_dest = tape6["neutron_destruction_rate"][-1] results = (mat_id, { "TIME": abs_time, "NEUT_PROD": neutron_prod, "NEUT_DEST": neutron_dest, "BUd": burnup, "material": list(out_mat.comp.items()), "phi_tot": phi_tot }) #if burnup < 0.0: # msg = 'Negative burnup found for {0}:\n{1}' # msg = msg.format(mat_id, pformat(results[1])) # raise ValueError(msg) return results
def transmute(self, x, t=None, phi=None, tol=None, cwd=None, xscache=None, o2exe=None, *args, **kwargs): """Transmutes a material into its daughters. Parameters ---------- x : Material or similar Input material for transmutation. 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. tol : float Tolerance level for chain truncation. cwd : str, optional Current working directory for origen runs. Defaults to this dir. xscache : XSCache, optional A cross section cache to generate cross sections with. o2exe : str, optional Name or path to ORIGEN 2.2 executable. Returns ------- y : Material The output material post-transmutation. """ if not isinstance(x, Material): x = Material(x) if t is not None: self.t = t if phi is not None: self.phi = phi if tol is not None: self.tol = tol if cwd is not None: self.cwd = os.path.abspath(cwd) if xscache is not None: self.xscache = xscache if o2exe is not None: self.o2exe = o2exe # prepare new tape9 nucs = set(x.comp.keys()) base_tape9 = self.base_tape9 decay_nlb, xsfpy_nlb = origen22.nlbs(base_tape9) new_tape9 = origen22.xslibs(nucs=nucs, xscache=self.xscache, nlb=xsfpy_nlb) t9 = origen22.merge_tape9([new_tape9, base_tape9]) # write out files origen22.write_tape4(x, outfile=os.path.join(self.cwd, 'TAPE4.INP')) origen22.write_tape5_irradiation('IRF', self.t/86400.0, self.xscache['phi_g'][0], outfile=os.path.join(self.cwd, 'TAPE5.INP'), decay_nlb=decay_nlb, xsfpy_nlb=xsfpy_nlb, cut_off=self.tol) origen22.write_tape9(t9, outfile=os.path.join(self.cwd, 'TAPE9.INP')) # run origen & get results f = tempfile.NamedTemporaryFile() try: subprocess.check_call([self.o2exe], cwd=self.cwd, stdout=f, stderr=f) except subprocess.CalledProcessError: f.seek(0) print("ORIGEN output:\n\n{0}".format(f.read())) raise finally: f.close() t6 = origen22.parse_tape6(tape6=os.path.join(self.cwd, 'TAPE6.OUT')) y = t6['materials'][-1] return y
def test_parse_tape6_PWRM021(): "Originally found at https://typhoon.jaea.go.jp/origen22/sample_pwrmox_orlibj33/PWRM0210.out" r = origen22.parse_tape6("tape6_PWRM0210.test") assert_true(0 < len(r)) assert_array_equal( r["time_sec"], [ 0.00e00, 1.21e07, 2.42e07, 3.63e07, 4.84e07, 6.05e07, 7.26e07, 8.47e07, 9.68e07, 1.09e08, 1.21e08, 1.33e08, ], ) assert_array_equal( r["average_flux"], [ 0.00e00, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, 3.46e14, ], ) tab_keys = set(["table_{0}".format(n) for n in [5]]) assert_true(tab_keys <= set(r)) for tk in tab_keys: for ttype in ["nuclide", "element", "summary"]: if ttype in r[tk]: assert_true( set(r[tk][ttype]) <= set( [ "title", "units", "activation_products", "actinides", "fission_products", ] ) ) assert_array_equal( r["alpha_neutron_source"]["CM242"], [ 0.00000e00, 8.50160e08, 1.28411e09, 1.48965e09, 1.57830e09, 1.60855e09, 1.61128e09, 1.60202e09, 1.58856e09, 1.57406e09, 1.55987e09, 1.54529e09, ], ) assert_array_equal( r["spont_fiss_neutron_source"]["PU238"], [ 5.58385e06, 5.52908e06, 5.68992e06, 5.94790e06, 6.24106e06, 6.53804e06, 6.82350e06, 7.09041e06, 7.33580e06, 7.55876e06, 7.75904e06, 7.93683e06, ], ) assert_true("materials" in r) assert_equal(len(r["materials"]), len(r["time_sec"]))
} } # 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 # Merge the base and overlay, and write out new_tape9 = origen22.merge_tape9([overlay_tape9, base_tape9]) origen22.write_tape9(new_tape9, 'TAPE9.INP') # Run and parse origen output rtn = check_call(['o2_therm_linux.exe']) tape6 = origen22.parse_tape6('TAPE6.OUT') h2_concentration.append(tape6['table_5']['summary']['activation_products']['H2'][-1]) print print "H2 Concentration: ", h2_concentration # Clean up import os for f in os.listdir('.'): if (f.endswith('.INP') or f.endswith('.OUT')) and f != 'BASE_TAPE9.INP': os.remove(f) # Try to plot the results try: import matplotlib.pyplot as plt
def run_origen(origen): run(origen) return parse_tape6()
def transmute(self, x, t=None, phi=None, tol=None, cwd=None, xscache=None, o2exe=None, *args, **kwargs): """Transmutes a material into its daughters. Parameters ---------- x : Material or similar Input material for transmutation. 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. tol : float Tolerance level for chain truncation. cwd : str, optional Current working directory for origen runs. Defaults to this dir. xscache : XSCache, optional A cross section cache to generate cross sections with. o2exe : str, optional Name or path to ORIGEN 2.2 executable. Returns ------- y : Material The output material post-transmutation. """ if not isinstance(x, Material): x = Material(x) if t is not None: self.t = t if phi is not None: self.phi = phi if tol is not None: self.tol = tol if cwd is not None: self.cwd = os.path.abspath(cwd) if xscache is not None: self.xscache = xscache if o2exe is not None: self.o2exe = o2exe # prepare new tape9 nucs = set(x.comp.keys()) base_tape9 = self.base_tape9 decay_nlb, xsfpy_nlb = origen22.nlbs(base_tape9) new_tape9 = origen22.xslibs(nucs=nucs, xscache=self.xscache, nlb=xsfpy_nlb) t9 = origen22.merge_tape9([new_tape9, base_tape9]) # write out files origen22.write_tape4(x, outfile=os.path.join(self.cwd, 'TAPE4.INP')) origen22.write_tape5_irradiation('IRF', self.t / 86400.0, self.xscache['phi_g'][0], outfile=os.path.join( self.cwd, 'TAPE5.INP'), decay_nlb=decay_nlb, xsfpy_nlb=xsfpy_nlb, cut_off=self.tol) origen22.write_tape9(t9, outfile=os.path.join(self.cwd, 'TAPE9.INP')) # run origen & get results f = tempfile.NamedTemporaryFile() try: subprocess.check_call([self.o2exe], cwd=self.cwd, stdout=f, stderr=f) except subprocess.CalledProcessError: f.seek(0) print("ORIGEN output:\n\n{0}".format(f.read())) raise finally: f.close() t6 = origen22.parse_tape6(tape6=os.path.join(self.cwd, 'TAPE6.OUT')) y = t6['materials'][-1] return y