Problem reading statepoint file when using a particle filter set to photon

Hi,

I’m currently trying to read in tally results from the statepoint file using openmc.statepoint. I have noticed that if I set the particle filter to photon in my python script I can’t read the data back into the program as it complains about “ZeroDivisionError: integer division or modulo by zero”. When checking the statepoint file with HDFView I can see that the filter bin for the particle filter is missing and give an error stating its set to 0 dimensions, the same occurs when trying to access the tally results (I’ve included screenshots of all the errors). This explains the error as there is no data for it to divide by.

Oddly if I do not set the the particle filter via python and instead manually set it via the tallies.xml file with the bin being the 2 to represent a photon filter the statepoint file is properly generated but I cannot read the file back in either due to the python code expecting a string aka ‘photon’ and not a number. It give the error (full error in screenshot):

`
File “/home/mmavis/.local/lib/python3.7/site-packages/openmc/filter.py”, line 586, in
particles = [b.decode() for b in group[‘bins’][()]]
AttributeError: ‘numpy.int32’ object has no attribute ‘decode’

`

Below is the python code I’m using to set the filter:

#mesh filter
mesh_filter = openmc.MeshFilter(mesh)
mesh_height = pitch
mesh_width = pitch
mesh_tally = openmc.Tally(1,name=‘tallies_on_mesh’)
energy_bins = openmc.mgxs.GROUP_STRUCTURES[‘VITAMIN-J-175’]
energy_filter = openmc.EnergyFilter(energy_bins)
particle_filter = openmc.ParticleFilter(‘photon’) #doesn’t work
mesh_tally.filters = [mesh_filter,energy_filter,particle_filter]
tally_to_plot = ‘flux’
mesh_tally.scores = [tally_to_plot]
tallies.append(mesh_tally)
tallies.export_to_xml()

and here is the statepoint code:

sp = openmc.StatePoint(‘statepoint.’+str(batches)+’.h5’)
flux_tally = sp.get_tally(scores=[tally_to_plot])
tally_results = flux_tally.get_pandas_dataframe()

If you need anymore information I’ll try my best to supply it. (I’m not the best at explaining things)

Thanks for any help,
Matt

Hi Matt,

I don’t see anything obviously wrong with your input. If you’re able to share your input script, I can try running it to see if I run into the same thing or if it works ok. I will note that we recently changed ParticleFilter to accept a string for the particle name (as you’re using) rather than an arbitrary integer that represented a particle type. To use strings, you should make sure you’re using the latest develop branch of OpenMC. If you’ve used git to clone the repo then you should 1) git pull 2) recompile and 3) reinstall.

Best regards,
Paul

Hi Paul,

I can give you the full script but you will need to use my branch of OpenMC to run it as I have added to the source code for OpenMC so it can produce a source based on a MCR2S output file. https://github.com/MattMavis/openmc/tree/MCR2S is the repository.
The script is in the volume folder called volume_test_photon.py. You will need to run openmc with the .xml files inside the test folder though all of these can be generated except the settings.xml as I have not implemented a way for the pythonapi to output the right settings yet and commonfile which is the mcr2s output file from which the source is generated.

Just a note, the code additions are very rudimentary at the moment and still probably needs a little more development.

I hope this made sense.

Thanks,
Matt

Hi Paul,

After a bit of digging through the source code I noticed that my filter_particle.cpp file had not updated with the recent changed but my python files had. I have now gone ahead and updated them and the program is now working as intended.

That would do it; glad to hear you got it figured out!

Hi,

I don’t know if this is the best place to put this (it probably isn’t), but I have noticed something odd when running my code. Basically if any of the materials had He in them they would not produce any data and would be missing from the flux mesh tally I generated. It turns out that the He cross section data for photons produced via the openmc-get-photon-data was either not correct or malformed during conversion. Replacing the file with a fresh He.h5 file created via the IncidentPhoton.from.endf function seemed to fix this. I don’t know if this was a one off problem but I thought I’d put it here just in case someone encounters this problem as well.

Thanks,
Matt