Why does OpenMC display "Error calculating max_normalized_value: Unable to get Tally"?

I am working on a genetic algorithm optimization. Does anyone know why this is happening? I defined a flux tally first, and then defined the function for the peaking factor (or non-uniformity coefficient), but it threw an error.

Seems like your tally is called “meshxy” (line 608), that’s why your code can’t find tally named “flux_xy”

But when I change my tally name, it also have this problem. I don’t know why.

OK. Do you want me to take a look at the statepoint file? Have you remembered to export the tallies?

I apologize for the delayed response. I have attached my .h5 file for your review. If you suspect the issue lies elsewhere, you might also want to check the Python file—the flux tally can be found around line 600, and the max_normalized function is at line 809.

1.py (58.5 KB)

summary.h5 (386.3 KB)

statepoint.10.h5 (45.8 KB)

I’ve seen this error pop up in OpenMC when the code tries to normalize tally results but the tally object hasn’t been properly populated with data yet. Here are the most common causes:

Timing Issues
The error usually means your simulation hasn’t completed or the tally wasn’t properly linked to your model before running. Check that you’re calling model.run() before attempting to access tally normalization. If you’re checking tallies mid-simulation or in the wrong sequence, OpenMC won’t have the data it needs.

Tally Registration
Make sure your tally is actually added to the model. A common mistake is creating a tally object but forgetting to append it:

model.tallies.append(my_tally)

Without this step, OpenMC treats it as orphaned and won’t calculate normalized values.

Score Definition
Verify that your tally has scores defined. If you created a tally but didn’t add any scores (like 'flux', 'absorption', etc.), there’s nothing to normalize. The error message is OpenMC’s way of saying “I have a tally object but no actual data to work with.”

Settings Configuration
Double-check that output = True is set in your settings if you need tally output files. Also confirm your simulation has sufficient batches and particles—if the tally barely accumulates any data, normalization can fail.

Try adding some debug output to verify your tally was added and the simulation completed. What stage of your workflow is throwing this error—right after model setup or after running.

I’ll investigate. Perhaps one thing you can try is to clean the old xmls from the directory in between runs. I’ll need to configure dagmc as well. But you’re right, the statepoint does not contain any tallies.

Thank you for your reply. I will look into it and see if this is the case.

Thank you for your advice. I realized I forgot to upload my DAGMC file, but when trying to do so, I found it is 30MB, whereas the forum only allows a maximum of 10MB. Could you please provide your email address so that I can send the .h5m file to you