Source energy distribution for neutron of different energy group.

Hello, I have a problem that I need guidance. I have a small mash defined at the beginning of a cylinder which measured current tally going into the cylinder in (0.0,0.5,10,5531,10000000) energy group.

Now, in the second experiment, I want to use the current tally measured as an external source at the beginning on the cylinder and measure the current at the end of the cylinder.

for that what will be my source energy distribution? is it Discrete, Watt or Tabular? and also how to define it?

Mesh Index (1, 1, 1)
Incoming Energy [0.0, 0.500000)
Outgoing Current on Left 1.19340E-03 +/- 6.72234E-06
Incoming Current on Left 1.28025E-03 +/- 7.25241E-06
Outgoing Current on Right 1.28144E-03 +/- 7.25641E-06
Incoming Current on Right 1.19119E-03 +/- 6.66488E-06
Outgoing Current on Back 9.43860E-06 +/- 5.86211E-07
Incoming Current on Back 5.43860E-06 +/- 4.51917E-07
Outgoing Current on Front 6.98246E-06 +/- 4.90627E-07
Incoming Current on Front 1.70877E-05 +/- 7.65402E-07
Outgoing Current on Bottom 7.57895E-06 +/- 5.17014E-07
Incoming Current on Bottom 9.61404E-06 +/- 5.84255E-07
Outgoing Current on Top 1.03158E-05 +/- 6.09085E-07
Incoming Current on Top 5.57895E-06 +/- 4.52841E-07
Incoming Energy [0.500000, 10.0000)
Outgoing Current on Left 2.07509E-04 +/- 2.72063E-06
Incoming Current on Left 2.32386E-04 +/- 2.89966E-06
Outgoing Current on Right 2.32386E-04 +/- 2.93557E-06
Incoming Current on Right 2.07053E-04 +/- 2.70260E-06
Outgoing Current on Back 1.40351E-06 +/- 2.22906E-07
Incoming Current on Back 5.26316E-07 +/- 1.34888E-07
Outgoing Current on Front 1.36842E-06 +/- 2.20357E-07
Incoming Current on Front 2.98246E-06 +/- 3.20592E-07
Outgoing Current on Bottom 1.50877E-06 +/- 2.30350E-07
Incoming Current on Bottom 1.57895E-06 +/- 2.45413E-07
Outgoing Current on Top 1.61404E-06 +/- 2.32266E-07
Incoming Current on Top 1.26316E-06 +/- 2.06608E-07
Incoming Energy [10.0000, 5531.00)
Outgoing Current on Left 4.33123E-04 +/- 4.13747E-06
Incoming Current on Left 4.83228E-04 +/- 4.22931E-06
Outgoing Current on Right 4.83018E-04 +/- 4.28115E-06
Incoming Current on Right 4.32912E-04 +/- 4.13387E-06
Outgoing Current on Back 3.71930E-06 +/- 3.51365E-07
Incoming Current on Back 6.66667E-07 +/- 1.51486E-07
Outgoing Current on Front 2.84211E-06 +/- 3.21933E-07
Incoming Current on Front 6.10526E-06 +/- 4.41460E-07
Outgoing Current on Bottom 3.26316E-06 +/- 3.29130E-07
Incoming Current on Bottom 3.40351E-06 +/- 3.38726E-07
Outgoing Current on Top 3.43860E-06 +/- 3.36526E-07
Incoming Current on Top 3.08772E-06 +/- 3.17606E-07
Incoming Energy [5531.00, 1.00000E+07)
Outgoing Current on Left 9.57825E-04 +/- 5.89838E-06
Incoming Current on Left 1.01193E-03 +/- 6.34678E-06
Outgoing Current on Right 1.01291E-03 +/- 6.34456E-06
Incoming Current on Right 9.55544E-04 +/- 5.83558E-06
Outgoing Current on Back 9.40351E-06 +/- 5.68673E-07
Incoming Current on Back 1.05263E-06 +/- 1.95629E-07
Outgoing Current on Front 4.45614E-06 +/- 3.90961E-07
Incoming Current on Front 1.84561E-05 +/- 8.19384E-07
Outgoing Current on Bottom 6.59649E-06 +/- 4.99935E-07
Incoming Current on Bottom 6.21053E-06 +/- 4.57759E-07
Outgoing Current on Top 7.29825E-06 +/- 5.18882E-07
Incoming Current on Top 5.29825E-06 +/- 4.28524E-07

As shown above I am getting current tally on four energy group and I am converting them into n/cm2/s according to (tally valuepowerv / E fissionKeffmash volume).

The tally value is giving me as (0-0.5), (0.5-10), (10-5531) and (5531-10000000) range value. The Which I separate converted into n/cm2/s. I am considering the first value of each energy “Outgoing Current on Left”, Now if I want to use the total number of the neutron as a source particle how to define the energy of that said source?

Any guidance is appreciated. Thanks.

Hi Sharif,

You’d want to use openmc.stats.Tabular for this. The first argument should be a list of the energy points, [0.0, 0.5, 10.0, 5531., 10e6]. The second argument should be the probabilities for each energy bin, but note that they need to be given per eV, so you may need to divide by the width of the energy bin first. Since the number of probabilities has to match the number of energies, you can just list a zero for the last one. Finally, for the third argument (interpolation), you will want to pass ‘histogram’ so that you have a histogram distribution.

Best regards,
Paul

Hello, Dr, Can you please share a sample example of the python code for source energy? I am trying to define it like

source.energy = openmc.stats.Tabular([0.0, 0.5, 10.0, 5531.0, 10e6], […], interpolation=‘histogram’,)

I have flux of those energy range on a small mesh area. How to define the probability of such?

An example would be really helpful Dr. Thanks.

Hello Dr. Paul,

I believe the probability should add up to 1.0? I have the total flux of all the energy range. If I add them up and divide each value with the sum, I get the probability of each energy range. That all add up to 1.

As an example.

I have 5.38e12, 9.67e11, 1.99e12, 4.54e12 n/cm2/s for each energy group (0-0.5), (0.5-10), (10-5531), (5531-10000000). Now, all these add up to 1.2877e13 and the probability of each group as 0.417799, 0.075095, 0.154539, 0.352567. These all add up to 1.0. But Dr. you said "they need to be given per eV, so you may need to divide by the width of the energy bin first. " now, if I divide 0.417799, 0.075095, 0.154539, 0.352567 with (0.5, 9.5, 5521, 9994469) respectavely, the values does not add up to 1.0.

Is this the way to do it? Let me know. Thank you dr, for all your help.

Yes, that is correct – the probability values per eV will not add up to 1.0. Only those values multiplied by the bin widths should add up to one.

Alexandre :pray: was just showing me this thread and walked me through how to make a source from a spectrum tally. I refactored the code into a method that could potentially be added to the EnergyFilter class in openmc/filter.py file. This makes it quite convenient when generating Tabular.

    def get_tabular(self, values):
        """Creates a openmc.stats.Tabular distribution using the EnergyFilter
        bins and the provided values. Intended use is to help convert a
        spectrum tally into a source.

        Parameters
        ----------
        values : np.array
            Array of numeric values, typically a tally.mean from a spectrum tally

        Returns
        -------
        openmc.stats.Tabular
            Tabular distribution with histogram interpolation
        """

        spectrum_probability = values / sum(values)

        proberbility_per_ev = spectrum_probability / np.diff(self.bins).flatten()

        return openmc.stats.Tabular(
            x = self.bins,
            p=proberbility_per_ev,
            interpolation='histogram'
        )

example usage with spectrum tally

cell_tally = results.get_tally(name='cell_spectra_tally')

tab = energy_filter.get_tabular(values=cell_tally.mean.flatten())

source = openmc.Source()
source.energy = tab
1 Like

Thank you, Jon, for bringing this up. Yes, I utilized this method to define an energy spectrum obtained from another simulation or extracted from literature as input. The spectrum is in the form of probability per energy bin. By multiplying this probability by the corresponding energy bin and integrating the data, we obtain a result of 1.

1 Like