Hello. Thanks for any help in advance. I am trying to plot axial fission distribution for a MSR. I have successfully plotted a 2D radial fission distribution.
Here is my code for axial view:
tallies=openmc.Tallies()
mesh_axial = openmc.RegularMesh()
mesh_axial.dimension = [10, 1, 10]
mesh_axial.lower_left = [-90, -90, -100]
mesh_axial.upper_right = [90, +90, 100]
mesh_f_axial = openmc.MeshFilter(mesh_axial)
tally_axial = openmc.Tally(name=‘axial’)
tally_axial.filters = [mesh_f_axial]
tally_axial.scores = [‘fission’]
tallies.append(tally_axial)
settings=DefineSetting()
model = openmc.Model(geometry=geometry,materials=materials, settings=settings)
model.tallies = tallies
statepoint_filename = model.run()
sp = openmc.StatePoint(statepoint_filename)
the above code runs a successful openmc run and generates that settings, statepoint, tallies, etc.
import numpy as np
import matplotlib.pyplot as plt
Load the last statepoint file and keff value
with openmc.StatePoint(statepoint_filename) as sp:
# Get the OpenMC pin power tally data
mesh_tally = sp.get_tally(name=‘axial’)
fission_rates = mesh_tally.get_values(scores=[‘fission’])
Reshape array to 2D for plotting
fission_rates.shape = mesh_axial.dimension
Normalize to the average pin power
fission_rates /= np.mean(fission_rates[fission_rates > 0.])
Force zeros to be NaNs so their values are not included when matplotlib calculates
the color scale
fission_rates[fission_rates == 0.] = np.nan
Plot the pin powers and the fluxes
plt.figure()
plt.imshow(fission_rates, interpolation=‘none’, cmap=‘jet’, origin=‘lower’)
plt.colorbar()
plt.title(‘Fission distribution axial’)
plt.savefig(“FissionAxial”)
plt.show()
the above code generates the following error:
TypeError: Invalid shape (10, 1, 10) for image data
I’ve tried some other variations, but I’m clearing flailing - I don’t understand what the mesh definitions are providing to the plotting routine.
Thanks again for help! Brian