Extracting tallies from mix_materials

Hello everyone,

recently i’ve been trying to create a breeding blanket with FLiBe and some other nuclides inside. My goal was to compute the number of (n,gamma) reactions in only one of this nuclide, but when I create the material with mix_materials it looks like I’ve lost the information on the single ones, so I can’t tally the reactions only in the exact nuclide that I want.

I tried with MaterialsFilter but this doesn’t work maybe for the reasons I just wrote.

Thank you for the help!!

Hi @Lorenzo_B

Could you provide the script you are using?

Thanks,

Travis

Hello, sorry for being late. Thank you in advance

Material definition

flibe = openmc.Material(name = ‘flibe’) # FLiBe breeder, made of Li2BeF4

flibe.add_element(‘Li’, 2.0)

flibe.add_element(‘Be’, 1.0)

flibe.add_element(‘F’, 4.0)

flibe.set_density(‘g/cm3’, 1.94)

Lu176 = openmc.Material(name = ‘Lu’)

Lu176.add_nuclide(‘Lu176’,1)

Lu176.set_density(‘g/cm3’,9.84)

breeder = openmc.Material.mix_materials([flibe,Lu176],[0.99, 0.01],‘wo’)

Tally definition

tally = openmc.Tally(name = ‘tally’)

tally.filters = [openmc.MaterialFilter(Lu176)]

tally.scores = [‘(n,gamma)’]

tallies_file.append(tally)

Obviously I have reported only the relevant part of the codes. This gives me an error on the tally after running, that says “Could not find material 11 specified on tally filter” (where material 11 is lutetium).

I can assume that maybe the information on the single nuclide (or element) is lost when I do the mixture material.

Thank you very much for helping!!

p.s. sorry if the code is not well written, those are my first approaches to OpenMC :slight_smile:

The issue isn’t with the mix_materials command. The problem is with what’s being passed to the material XML.

After you create all the materials in the Python script, you need to add every material you want available in the simulation into a Materials object, like this:

materials = openmc.Materials([flibe, Lu176, breeder])

You can then export the materials directly to XML with:

materials.export_to_xml()

Or, you can include them in a model setup:

model = openmc.Model()
model.settings = settings
model.geometry = geometry
model.materials = materials
model.tallies = tallies
model.export_to_model_xml()

Keep in mind that if a model XML file is created, the simulation will use that file instead of materials.xml. Make sure all the required information is included in the model XML.

On another note for material creation I suggest you look into the material object openmc.Material — OpenMC Documentation as it provides some very useful functions. One that you are already using mix_materials, other useful ones are add_elements_from_formula and add_components.

Thank you very much for your response.

As I said, not all the code was added, but obviously the line materials.export_to_xml() is present. The error printed refers to the impossibility of finding the material only after the mixing_material is created, because I dont have any problems with all the other materials.

I would try the other hypotesis that you recommend me, since I still think that using mix_materials loses the information on the single element.

If I’m wrong, please let me know, this can be very helpful!!

Thank you very much,

Lorenzo

Are you trying to tally the nuclide or the material Lu176? If you are only using the mix material in the simulation and you want to tally the Lu176 nuclide then your tally needs to be nuclide specification instead of material specification. Like seen below

tallies = openmc.Tallies()
tally = openmc.Tally(name = ‘tally’)
tally.nuclides = [‘Lu176’]
tally.scores = [‘(n,gamma)’]
tallies_file.append(tally)

YESS!! this works! I had the same intuition few hours before your answer, im glad it works so well and that you confirm it. Thank you! Wishing the best, Lorenzo