def main(tally_id, score_id, batch_start, batch_end, name): # read in statepoint header data sp = statepoint.StatePoint('statepoint.ref.binary') # read in results sp.read_results() # extract reference mean mean_ref = extract_mean(sp, tally_id, score_id) # write gnuplot file write_src_gnuplot('testsrc_pin', 'Pin mesh', mean_ref, np.size(mean_ref, 0)) # preallocate arrays hists = np.zeros(batch_end - batch_start + 1) norms = np.zeros(batch_end - batch_start + 1) i = batch_start while i <= batch_end: # process statepoint sp = statepoint.StatePoint('statepoint.' + str(i) + '.binary') sp.read_results() # extract mean mean = extract_mean(sp, tally_id, score_id) # calculate L2 norm norm = np.linalg.norm(mean - mean_ref) # get history information n_inactive = sp.n_inactive current_batch = sp.current_batch n_particles = sp.n_particles gen_per_batch = sp.gen_per_batch n_histories = (current_batch - n_inactive) * n_particles * gen_per_batch # batch in vectors hists[i - batch_start] = n_histories norms[i - batch_start] = norm # print print 'Batch: ' + str(i) + ' Histories: ' + str( n_histories) + ' Norm: ' + str(norm) i += 1 # write out gnuplot file write_norm_gnuplot(name, hists, norms, np.size(hists))
def process_tallies(self): # get statepoint filename spfile = glob.glob('tmpdir/minicore_outputs/statepoint*')[0] # extract all means sp = statepoint.StatePoint(spfile) # plot sp.read_results() # extract distributions nfiss = self.extract_mean(sp, 1, 'nu-fission') flux2 = self.extract_mean(sp, 2, 'flux') flux1 = self.extract_mean(sp, 3, 'flux') # write out data self.write_gnuplot_data(nfiss, flux1, flux2) # run gnuplot Popen(['gnuplot','tmpdir/minicore_outputs/nfiss.plot']) Popen(['gnuplot','tmpdir/minicore_outputs/flux1.plot']) Popen(['gnuplot','tmpdir/minicore_outputs/flux2.plot']) self.emit(SIGNAL("new output plots"), ["tmpdir/minicore_outputs/nfiss.png", "tmpdir/minicore_outputs/flux1.png"])
#!/usr/bin/env python import sys # import statepoint sys.path.insert(0, '../../src/utils') import statepoint # read in statepoint file if len(sys.argv) > 1: sp = statepoint.StatePoint(sys.argv[1]) else: sp = statepoint.StatePoint('statepoint.09.binary') sp.read_results() # set up output string outstr = '' # write out k-combined outstr += 'k-combined:\n' outstr += "{0:12.6E} {1:12.6E}\n".format(sp.k_combined[0], sp.k_combined[1]) # write results to file with open('results_test.dat','w') as fh: fh.write(outstr)
def main(): print "Loading statepoint..." sp = statepoint.StatePoint('statepoint.300.binary') print "Parsing statepoint..." sp.read_results() print "\nAvailable Tallies:" for tally in sp.tallies: print "\tTally {}".format(tally.id) print "\t\tscores: {}".format(" ".join(tally.scores)) print "\t\tfilters: {}".format(" ".join(tally.filters.keys())) ## Loop through the mesh for tally 1 and create plots print "Extracting Mesh Values from Tally 1..." tallyid = 0 # tally 1 score = 0 # flux is zero see (order of tally.filters.keys()) # get mesh dimensions meshid = sp.tallies[tallyid].filters['mesh'].bins[0] for i, m in enumerate(sp.meshes): if m.id == meshid: mesh = m nx, ny, nz = mesh.dimension # loop through mesh and extract values thermal = {} fast = {} for x in range(1, nx + 1): for y in range(1, ny + 1): for z in range(1, nz + 1): val, err = sp.get_value(tallyid, [('mesh', (x, y, z)), ('energyin', 0)], score) thermal[(x, y, z)] = val val, err = sp.get_value(tallyid, [('mesh', (x, y, z)), ('energyin', 1)], score) fast[(x, y, z)] = val # write gnuplot datafile with axially-integrated values print "Making gnuplots ..." with open('meshdata.dat', 'w') as fh: for x in range(1, nx + 1): for y in range(1, ny + 1): thermalval = 0. fastval = 0. for z in range(1, nz + 1): thermalval += thermal[(x, y, z)] fastval += fast[(x, y, z)] fh.write("{} {} {} {}\n".format(x, y, thermalval, fastval)) # write gnuplot file and make plots with open('tmp.gnuplot', 'w') as fh: fh.write(r"""set terminal png size 800,400 set output 'fluxplot.png' set nokey set autoscale fix set multiplot layout 1,2 title "Pin Mesh Axially-Integrated Flux Tally" set title "Thermal" plot 'meshdata.dat' using 1:2:3 with image set title "Fast" plot 'meshdata.dat' using 1:2:4 with image """) os.system("gnuplot < tmp.gnuplot") # make 3d silo file print "Making 3D SILO File ..." sm.init_silo("fluxtally.silo") sm.init_mesh( 'tally_mesh', nx, ny, nz, -85.8774, -85.8774, -81.662, # lower left of mesh 1.63576, 1.63576, 8.1662) # width of mesh cells sm.init_var('flux_tally_thermal') for x in range(1, nx + 1): for y in range(1, ny + 1): for z in range(1, nz + 1): sm.set_value(float(thermal[(x, y, z)]), x, y, z) sm.finalize_var() sm.init_var('flux_tally_fast') for x in range(1, nx + 1): for y in range(1, ny + 1): for z in range(1, nz + 1): sm.set_value(float(fast[(x, y, z)]), x, y, z) sm.finalize_var() sm.finalize_mesh() sm.finalize_silo()