#!/usr/bin/env python3 import os import pypact as pp filename = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', 'reference', 'test31.out') with pp.Reader(filename) as output: print(output.json_serialize())
"alpha heat (kW)", "beta heat (kW)", "gamma heat (kW)", "cumulative time (secs)", "is irradiation", ] def fmt(items): str = "{:>20}".format(items[0]) for i in items: str += ", {:>20}".format(i) return "{}\n".format(str) with pp.Reader(runname) as output: with open("csvexample.csv", "wt") as f: f.write(fmt(headers)) for t in output: for n in t.nuclides: # if you changed the headers you must change this too!! # f.write( fmt( [ n.name, n.activity, n.grams, n.alpha_heat, n.beta_heat, n.gamma_heat,
def use_outfile(filename): """ Reads the .out file with pypact """ with pp.Reader("{}.out".format(filename)) as output: return process_output(output)
def test_reader_output(self): with pp.Reader(self.filename_test91out) as o: self._assert_test91(o)
import pypact as pp YEAR_IN_SECS = 3.15576e+07 # read output file from first run to get fuel for second run fuel = [] with pp.Reader('first.out') as data: # get the last entry only for n in data[-1].nuclides: fuel.append(("{}{}{}".format(n.element, n.isotope, n.state), n.atoms)) # write an input file for second run ipt = pp.InputData() # options ipt.enableSystemMonitor() ipt.overwriteExisting() ipt.enableJSON() ipt.readXSData(group=709) ipt.readDecayData() ipt.approxGammaSpectrum() ipt.setDensity(1.0) # use fuel to add nuclides ipt.setFuel() for n, a in fuel: ipt.addIsotope(n, a) # irradiation schedule ipt.addIrradiation(0.0, 1.3e14)
# if you change this you must also # change the list at the bottom! headers = [ 'nuclides', 'activity (Bq)', 'grams', 'alpha heat (kW)', 'beta heat (kW)', 'gamma heat (kW)', 'cumulative time (secs)', 'is irradiation' ] def fmt(items): str = "{:>20}".format(items[0]) for i in items: str += ", {:>20}".format(i) return "{}\n".format(str) with pp.Reader('{}.out'.format(runname)) as output: with open('{}.csv'.format(runname), 'wt') as f: f.write(fmt(headers)) for t in output: for n in t.nuclides: name = '{}{}{}'.format(n.element, n.isotope, n.state) # if you changed the headers you must change this too!! # f.write( fmt([ name, n.activity, n.grams, n.alpha_heat, n.beta_heat, n.gamma_heat, t.currenttime, t.isirradiation() ]))