Merge pull request #2228 from paulromano/sourcefile-fix

Fix reading source file with time attribute
This commit is contained in:
Gavin Ridley 2022-10-05 14:43:20 -04:00 committed by GitHub
commit 9a86c9c065
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View file

@ -527,6 +527,7 @@ hid_t h5banktype()
H5Tinsert(banktype, "r", HOFFSET(SourceSite, r), postype);
H5Tinsert(banktype, "u", HOFFSET(SourceSite, u), postype);
H5Tinsert(banktype, "E", HOFFSET(SourceSite, E), H5T_NATIVE_DOUBLE);
H5Tinsert(banktype, "time", HOFFSET(SourceSite, time), H5T_NATIVE_DOUBLE);
H5Tinsert(banktype, "wgt", HOFFSET(SourceSite, wgt), H5T_NATIVE_DOUBLE);
H5Tinsert(banktype, "delayed_group", HOFFSET(SourceSite, delayed_group),
H5T_NATIVE_INT);

View file

@ -75,3 +75,25 @@ def test_wrong_source_attributes(run_in_tmpdir):
with pytest.raises(RuntimeError) as excinfo:
openmc.run()
assert 'platypus, axolotl, narwhal' in str(excinfo.value)
def test_source_file_transport(run_in_tmpdir):
# Create a source file with a single particle
particle = openmc.SourceParticle()
openmc.write_source_file([particle], 'source.h5')
# Created simple model to use source file
model = openmc.Model()
al = openmc.Material()
al.add_element('Al', 1.0)
al.set_density('g/cm3', 2.7)
sph = openmc.Sphere(r=10.0, boundary_type='vacuum')
cell = openmc.Cell(fill=al, region=-sph)
model.geometry = openmc.Geometry([cell])
model.settings.source = openmc.Source(filename='source.h5')
model.settings.particles = 10
model.settings.batches = 3
model.settings.run_mode = 'fixed source'
# Try running OpenMC
model.run()