Thanks wahid for your response and pointing out that I didn’t use the same domain size which is actually from another test run and I totally overlooked before posting the 2D example.
However, I can assure you I have got the posted figures for the same domain.
my_tallies = openmc.Tallies()
# Define the 1D z-axis mesh tally with a RegularMesh and define tally
mesh1Dz = openmc.RegularMesh().from_domain(
my_geometry,
dimension=[1, 1, 200]
)
meshfilter1Dz = openmc.MeshFilter(mesh1Dz)
tally1Dz = openmc.Tally(name='1D_tally')
tally1Dz.scores = ['flux']
tally1Dz.filters = [meshfilter1Dz]
my_tallies.append(tally1Dz)
# Create 2D mesh using RegularMesh and define tally
mesh2Dxz = openmc.RegularMesh().from_domain(
my_geometry,
dimension=[200, 1, 200]
)
meshfilter2Dxz = openmc.MeshFilter(mesh2Dxz)
tally2Dxz = openmc.Tally(name='2D_tally')
tally2Dxz.filters = [meshfilter2Dxz]
tally2Dxz.scores = ['flux']
my_tallies.append(tally2Dxz)
my_tallies.export_to_xml()
# tally 1D
tally1Dz = sp.get_tally(name='1D_tally')
tally1Dzflux = tally1Dz.get_slice(scores=['flux']).mean.flatten()/mesh1Dz.volumes[0][0][0]
zaxis = np.linspace(mesh1Dz.lower_left[2], mesh1Dz.upper_right[2], mesh1Dz.dimension[2])
# Plotting the 1D data
plt.figure()
plt.plot(zaxis, tally1Dzflux, color='red')
plt.xlabel('z position (cm)')
plt.ylabel('Flux [n/cm$^2$-s]')
plt.title("Flux Along Z-axis")
plt.grid(True)
plt.gca().yaxis.set_major_formatter(ScalarFormatter(useMathText=True))
plt.ticklabel_format(axis="y", style="sci", scilimits=(0,0))
plt.tight_layout()
plt.savefig("flux_along_z_axis.png")
plt.show()
# Accessing the flux tally and setting up the slice with the right shape
tally1Dz = sp.get_tally(name="2D_tally")
slice_tally = tally1Dz.get_slice(scores=['flux'])/mesh2Dxz.volumes[0][0][0]
slice_tally.mean.shape = (mesh2Dxz.dimension[0], mesh2Dxz.dimension[2]) # setting the resolution to the mesh dimensions
# Plotting the 2D data
fig, ax = plt.subplots()
cax = ax.imshow(slice_tally.mean,
extent=mesh2Dxz.bounding_box.extent['xz'],
origin='lower',
norm=LogNorm()) # Apply logarithmic normalization
fig.colorbar(cax, ax=ax, label='Flux (n/cm²-s)')
ax.set_xlabel("X Position (cm)")
ax.set_ylabel("Z Position (cm)")
ax.set_title("Flux Distribution in XZ Plane")
plt.savefig("flux_distribution_xz_plane.png", dpi=300)
plt.show()
Regarding power, the value is unknown and I have set the source strength in my settings as
# Source definition
am_be_source = openmc.Source()
am_be_source.space = openmc.stats.Box((44.2, 93.2, -31.5), (44.7, 93.7, -30))
am_be_source.angle = openmc.stats.Isotropic()
am_be_source.energy = openmc.stats.Discrete([4.3e6], [1])
am_be_source.time = openmc.stats.Uniform(0, 1)
am_be_source.strength = 10 * 2 * 10**6
pu_be_source_1 = openmc.Source()
pu_be_source_1.space = openmc.stats.Box((37.2, 128.2, -31.5), (37.7, 128.7, -30))
pu_be_source_1.angle = openmc.stats.Isotropic()
pu_be_source_1.energy = openmc.stats.Discrete([4.1e6], [1])
pu_be_source_1.time = openmc.stats.Uniform(0, 1)
pu_be_source_1.strength = 1.8 * 10**6
pu_be_source_2 = openmc.Source()
pu_be_source_2.space = openmc.stats.Box((51.2, 128.2, -31.5), (51.7, 128.7, -30))
pu_be_source_2.angle = openmc.stats.Isotropic()
pu_be_source_2.energy = openmc.stats.Discrete([4.1e6], [1])
pu_be_source_2.time = openmc.stats.Uniform(0, 1)
pu_be_source_2.strength = 1.8 * 10**6
pu_be_source_3 = openmc.Source()
pu_be_source_3.space = openmc.stats.Box((37.2, 93.2, -31.5), (37.7, 93.7, -30))
pu_be_source_3.angle = openmc.stats.Isotropic()
pu_be_source_3.energy = openmc.stats.Discrete([4.1e6], [1])
pu_be_source_3.time = openmc.stats.Uniform(0, 1)
pu_be_source_3.strength = 1.8 * 10**6
pu_be_source_4 = openmc.Source()
pu_be_source_4.space = openmc.stats.Box((51.2, 93.2, -31.5), (51.7, 93.7, -30))
pu_be_source_4.angle = openmc.stats.Isotropic()
pu_be_source_4.energy = openmc.stats.Discrete([4.1e6], [1])
pu_be_source_4.time = openmc.stats.Uniform(0, 1)
pu_be_source_4.strength = 1.8 * 10**6
# Combine all sources into one list
sources = [am_be_source, pu_be_source_1, pu_be_source_2, pu_be_source_3, pu_be_source_4]
I have messeged you the script thinking the script might help you to understand you better what I am doing and where I might be mistaking. So, if you can spare some of your time to look at that, I’d be grateful and TIA
By the way, thanks for referring to that post but I had already gone through that before posting my question as I was still uncleared