<jupyter_start><jupyter_text>Analyzing Prompt Neutrons<jupyter_code>### initializations and import libraries
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
%matplotlib inline
%pylab inline

from CGMFtk import histories as fh
### rcParams are the default parameters for matplotlib
import matplotlib as mpl

print ("Matplotbib Version: ", mpl.__version__)

mpl.rcParams['font.size'] = 18
mpl.rcParams['font.family'] = 'Helvetica', 'serif'
#mpl.rcParams['font.color'] = 'darkred'
mpl.rcParams['font.weight'] = 'normal'

mpl.rcParams['axes.labelsize'] = 18.
mpl.rcParams['xtick.labelsize'] = 18.
mpl.rcParams['ytick.labelsize'] = 18.
mpl.rcParams['lines.linewidth'] = 2.

font = {'family' : 'serif',
        'color'  : 'darkred',
        'weight' : 'normal',
        'size'   : 18,
        }

mpl.rcParams['xtick.major.pad']='10'
mpl.rcParams['ytick.major.pad']='10'

mpl.rcParams['image.cmap'] = 'inferno'<jupyter_output>Matplotbib Version:  3.1.3<jupyter_text>First we load in the history file<jupyter_code>hist = fh.Histories('98252sf.cgmf')<jupyter_output><empty_output><jupyter_text>Many average quantities for the pre-fission and prompt neutrons can be calculated using the histories class<jupyter_code># the average neutron multiplicity
print ('nubar (per fission event) = ',hist.nubartot())
print ('average number of neutrons per fragment = ',hist.nubar())<jupyter_output>nubar (per fission event) =  3.817616
average number of neutrons per fragment =  1.908808<jupyter_text>Or we might want a list of the multiplicity of each event<jupyter_code>nu = hist.getNutot()
print (nu[:10])
# hist.getNu() pulls the multiplicity for each fission fragment
# hist.getNuEvent() pulls the multiplicity for each event, not including pre-fission neutrons<jupyter_output>[4 3 6 5 4 3 3 3 4 4]<jupyter_text>Neutron energies in both the center of mass (of the compound nucleus) and the laboratory frame are available<jupyter_code>Elab = hist.getNeutronElab()
Ecm = hist.getNeutronEcm()<jupyter_output><empty_output><jupyter_text>These two functions provide a list of lists of neutron energies for each fragment.  Typically, more manipulation will be required to use these values for plotting.  For example, if we want to plot the neutron multiplicity and the total neutron energy of each event:<jupyter_code>Elabtot = []
ElabEvent = Elab[::2]+Elab[1::2]
for x in ElabEvent:
    Elabtot.append(np.sum(x))
print (len(nu))
print (len(Elabtot))
fig = plt.figure(figsize=(8,6))
bx = np.arange(min(nu),max(nu)+1)
by = np.arange(min(Elabtot),max(Elabtot)+1)

plt.hist2d(nu,Elabtot,bins=(bx,by))
plt.xlabel('Neutron Multiplicity')
plt.ylabel('Total Neutron Energy (MeV)')
plt.show()<jupyter_output><empty_output><jupyter_text>There are also routines to calculate the neutron average energies<jupyter_code># average neutron energies
print ('Neutron energies in the lab:')
print ('Average energy of all neutrons = ',hist.meanNeutronElab())
print ('Average energy of neutrons from fragments = ',hist.meanNeutronElabFragments())
print ('Average energy of neutrons from light fragment = ',hist.meanNeutronElabLF())
print ('Average energy of neutrons from heavy fragment = ',hist.meanNeutronElabHF())
print (' ')
print ('Neutron energies in the center of mass:')
print ('Average energy of neutrons from fragments = ',hist.meanNeutronEcmFragments())
print ('Average energy of neutrons from light fragment = ',hist.meanNeutronEcmLF())
print ('Average energy of neutrons from heavy fragment = ',hist.meanNeutronEcmHF())<jupyter_output>Neutron energies in the lab:
Average energy of all neutrons =  2.077427439009056
Average energy of neutrons from fragments =  2.077427439009056
Average energy of neutrons from light fragment =  2.3293141780172957
Average energy of neutrons from heavy fragment =  1.7574275095987781
 
Neutron energies in the center of mass:
Average energy of neutrons from fragments =  1.3025117701727997
Average energy of neutrons from light fragment =  1.3719594663675614
Average energy of neutrons from heavy fragment =  1.2142845853375386
{'fraction_non_alphanumeric': 0.10778296096243555, 'fraction_numerical': 0.0427203535477535, 'mean_word_length': 5.940374787052811, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '376907', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1319, 'n_words': 406, 'path': 'doc/rtd/nb_neutrons.ipynb', 'repo_name': 'moatazharb/CGMF', 'size': '4073'}