njoy / ENDFtk

Toolkit for reading and interacting with ENDF-6 formatted files
Other
33 stars 5 forks source link

Reading Angular distributions #144

Closed Mahdi-20 closed 2 years ago

Mahdi-20 commented 2 years ago

Dear Experts, I am a newbie to ENDFtk and I am trying to extract the Angular distributions for certain incident energy from a JENDL-4.0 ENDF file.

I used the following command to get all incident energies that works well:

tape = ef.tree.Tape.from_file('natC.txt') file2=mat.MF(4) section2=file2.MT(2) en2=section2.incident_energies.copy()

However, I used the following command to get the angular distributions:

angdis=section2.angular_distributions

but the output is :

<ENDFtk.sequence.any_view< variant< LegendreCoefficients&, TabulatedDistribution& >, random_access > object at 0x7f0f1d05fed8>

So, how can I access the LegendresCoeefficinets and TabulatedDistributions for an incident energy?

Any response is really appreciated.

whaeck commented 2 years ago

You're almost there with what you have. Your last line of python:

angdis=section2.angular_distributions

returns a sequence of the angular distribution data, one for each of the incident energy values in your en2 list. You only need to determine the index of the energy value that you want, and then retrieve it from the angdis list.

For example:

incident = 1e-5
index = en2.index( incident )  # retrieve the index for the incident energy = 1e-5
distribution = section2.angular_distributions[index] # this is should be the first one

distribution will then be an instance of either LegendreCoefficients or TabulatedDistribution.

As a side note: the use of the index( ... ) function on a python list may not be the best option here since you're looking for a floating point value, I used it for illustration purposes only.

It is also good to know that every instance of LegendreCoefficients or TabulatedDistribution also knows what its incident energy is. As such, you can also look for what you need this way (in this example I account for the fact that we need to do a floating point comparison):

energy = 1e-5
distribution = None

for entry in section2.angular_distributions :

    if abs( entry.incident_energy - energy ) < 1e-5 :

        distribution = entry
        break 
Mahdi-20 commented 2 years ago

@whaeck Thank you so much it worked. However, I am going to extract data similar to the following screenshot taken from [https://www-nds.iaea.org/exfor/servlet/X4sShowData?db=x4&op=get_plotdata&req=-1&ii=3856&File=X4R-1-10728_C4_0.zvd.dat.txt]

image

We can see the angles and corresponding partial cross-sections in (b/sr). I am wondering if I can get such data from the JENDL-4.0 ENDF file or not? Thanks.

nathangibson14 commented 2 years ago

Hi @Mahdi-20,

Right now, there isn't functionality to robustly extract the differential cross section in ENDFtk. That requires what we'd call "interpretation", which is taking the numbers from the ENDF file and combining them to make a desired quantity. We have hopes to create a library that will link to ENDFtk to do just that.

So what that means is you need to provide that interpretation piece yourself at this point. So, take a look at the manual (ENDF-102) for MF6 (or MF4 depending on the data you're working with), and see if you can reconstruct the cross section. For some representations, all the data you need is in MF6. For other data, you need to multiply by the cross section in MF3. For instance, with the LegendreCoefficients representation, you could put the values from ENDF into some Python function like legval to get the normalized angular distribution, then multiply by the MF3 cross section to get the differential cross section.

Hope that helps.

Mahdi-20 commented 2 years ago

Hi @nathangibson14 Thank you for clarifying this issue. I will try to do what you have mentioned. I have a very general question as well. We can obtain all data from the website: https://www-nds.iaea.org/exfor/endf.htm I want to be aware of the advantages of using ENDFtk over such websites while we are working with ENDF formatted data. In other words, what are the main goals of developing ENDFtk that I can benefit from? Thanks.

nathangibson14 commented 2 years ago

Hi @Mahdi-20,

The website you linked is a repository of ENDF-formatted data files. It does provide some basic tools to do things like extract a cross section at a given energy or make a plot, but it doesn't provide a full interface to the data.

ENDFtk takes ENDF files such as the ones you are retrieving from that repository and it allows you to interact with the data much more robustly. ENDFtk is intended to read and write ENDF-formatted data with a clean and fairly easy-to-use API (at least, as easy as the ENDF format can be!). This is much easier to do than to parse an ENDF file using only your eye and the ENDF manual. Some of the operations we frequently do with the tool (and other Python functionality) include:

And to reiterate, most of these uses do require additional functionality than what is in ENDFtk. These are intended to motivate the sorts of applications you can create with ENDFtk as your starting point.