Plotting cylindrical mesh flux

Hi!

I am having problems plotting a slice of my cylindrical mesh.

I define the mesh like so:

mesh_bins_r = 100
mesh_bins_theta = 1
mesh_bins_z = 1

mesh = omc.CylindricalMesh.from_domain(domain=my_geometry,
dimension=[mesh_bins_r, mesh_bins_theta, mesh_bins_z])
mesh_filter = omc.MeshFilter(mesh)

And then I would like to plot a flux map, but I think there is a problem with going from polar to cartesian coordinates. I was going for something like this:

with omc.StatePoint(f’statepoint_file.h5’) as sp:
flux_tally = sp.get_tally(name=“flux tally”)

tally_mesh = flux_tally.find_filter(omc.MeshFilter).mesh
tally_mesh_extent = tally_mesh.bounding_box.extent[‘xy’]

flux_mean = flux_tally.get_reshaped_data(value=‘mean’, expand_dims=True).squeeze()

plt.figure(figsize=(10, 6))
plt.imshow(
flux_mean.T,
origin=“lower”,
extent=tally_mesh_extent,
norm=LogNorm(),
)
plt.title(“Flux Mean”)
plt.show()

The source code from this openmc_cylindrical_mesh_plotter package might help

1 Like

Thank you! I think I got it working now :smile: