Skip to content

Commit

Permalink
fixed hard coding of shape
Browse files Browse the repository at this point in the history
  • Loading branch information
shimwell committed Nov 27, 2023
1 parent 9fb2ec3 commit eccc915
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/openmc_regular_mesh_plotter/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def plot_mesh_tally(
default_imshow_kwargs.update(kwargs)

if isinstance(tally, typing.Sequence):
data = np.zeros(shape=(40,40))
for one_tally in tally:

for counter, one_tally in enumerate(tally):
new_data = _get_tally_data(
scaling_factor,
mesh,
Expand All @@ -157,6 +157,8 @@ def plot_mesh_tally(
score,
slice_index
)
if counter == 0:
data = np.zeros(shape=new_data.shape)
data=data+new_data
else: # single tally
data = _get_tally_data(
Expand Down
5 changes: 4 additions & 1 deletion tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ def test_plot_two_mesh_tallies(model):

mesh = openmc.RegularMesh().from_domain(geometry, dimension=[1, 20, 30])
mesh_filter = openmc.MeshFilter(mesh)

mesh_tally_1 = openmc.Tally(name="mesh-tal-1")
mesh_tally_1.filters = [mesh_filter]
mesh_tally_1.scores = ["flux"]

mesh_tally_2 = openmc.Tally(name="mesh-tal-2")
mesh_tally_2.filters = [mesh_filter]
mesh_tally_2.scores = ["heating"]

tallies = openmc.Tallies([mesh_tally_1, mesh_tally_2])

model.tallies = tallies
Expand All @@ -179,7 +182,7 @@ def test_plot_two_mesh_tallies(model):
plot.figure.savefig("t.png")

plot = plot_mesh_tally(
tally=tally_result,
tally=[tally_result_1, tally_result_2],
basis="yz",
axis_units="m",
# slice_index=9, # max value of slice selected
Expand Down

0 comments on commit eccc915

Please sign in to comment.