Allow MeshSource to take a 1D array of sources (#2980)

This commit is contained in:
Paul Romano 2024-05-03 13:30:49 -05:00 committed by GitHub
parent 6e57f1dc72
commit cfe210da22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 32 deletions

View file

@ -276,12 +276,12 @@ def test_mesh_source_independent(run_in_tmpdir, void_model, mesh_type):
# for each element, set a single-non zero source with particles
# traveling out of the mesh (and geometry) w/o crossing any other
# mesh elements
for i, j, k in mesh.indices:
for flat_index, (i, j, k) in enumerate(mesh.indices):
ijk = (i-1, j-1, k-1)
# zero-out all source strengths and set the strength
# on the element of interest
mesh_source.strength = 0.0
mesh_source.sources[ijk].strength = 1.0
mesh_source.sources[flat_index].strength = 1.0
sp_file = model.run()
@ -375,10 +375,7 @@ def test_mesh_source_file(run_in_tmpdir):
mesh.upper_right = (2, 3, 4)
mesh.dimension = (1, 1, 1)
mesh_source_arr = np.asarray([file_source]).reshape(mesh.dimension)
source = openmc.MeshSource(mesh, mesh_source_arr)
model.settings.source = source
model.settings.source = openmc.MeshSource(mesh, [file_source])
model.export_to_model_xml()