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_nlbs(): exp = (1, 2, 3), (42, 43, 44) t9 = { 42: { '_type': 'xsfpy', '_subtype': 'activation_products' }, 43: { '_type': 'xsfpy', '_subtype': 'actinides' }, 44: { '_type': 'xsfpy', '_subtype': 'fission_products' }, 1: { '_type': 'decay' }, 2: { '_type': 'decay' }, 3: { '_type': 'decay' }, } obs = origen22.nlbs(t9) assert_equal(exp, obs)
def test_nlbs(): exp = (1, 2, 3), (42, 43, 44) t9 = {42: {'_type': 'xsfpy', '_subtype': 'activation_products'}, 43: {'_type': 'xsfpy', '_subtype': 'actinides'}, 44: {'_type': 'xsfpy', '_subtype': 'fission_products'}, 1: {'_type': 'decay'}, 2: {'_type': 'decay'}, 3: {'_type': 'decay'}, } obs = origen22.nlbs(t9) assert_equal(exp, obs)
def test_nlbs(): exp = (1, 2, 3), (42, 43, 44) t9 = { 42: {"_type": "xsfpy", "_subtype": "activation_products"}, 43: {"_type": "xsfpy", "_subtype": "actinides"}, 44: {"_type": "xsfpy", "_subtype": "fission_products"}, 1: {"_type": "decay"}, 2: {"_type": "decay"}, 3: {"_type": "decay"}, } obs = origen22.nlbs(t9) assert_equal(exp, obs)
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 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