mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Ensure photon cross sections are loaded when FileSource contains photons (#3988)
Some checks are pending
Tests and Coverage / filter-changes (push) Waiting to run
Tests and Coverage / Python 3.13 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14t (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=, event=y (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=y, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / coverage (push) Blocked by required conditions
Tests and Coverage / Check CI status (push) Blocked by required conditions
dockerhub-publish-develop / main (push) Waiting to run
dockerhub-publish-develop-dagmc-libmesh / main (push) Waiting to run
dockerhub-publish-develop-dagmc / main (push) Waiting to run
dockerhub-publish-develop-libmesh / main (push) Waiting to run
Some checks are pending
Tests and Coverage / filter-changes (push) Waiting to run
Tests and Coverage / Python 3.13 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14 (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.14t (omp=n, mpi=n, dagmc=, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=n, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=n, libmesh=n, event=n (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=n, dagmc=, libmesh=, event=y (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=y, libmesh=, event= (push) Blocked by required conditions
Tests and Coverage / Python 3.12 (omp=y, mpi=y, dagmc=, libmesh=y, event= (push) Blocked by required conditions
Tests and Coverage / coverage (push) Blocked by required conditions
Tests and Coverage / Check CI status (push) Blocked by required conditions
dockerhub-publish-develop / main (push) Waiting to run
dockerhub-publish-develop-dagmc-libmesh / main (push) Waiting to run
dockerhub-publish-develop-dagmc / main (push) Waiting to run
dockerhub-publish-develop-libmesh / main (push) Waiting to run
This commit is contained in:
parent
24fdb84edc
commit
3247587d49
2 changed files with 32 additions and 1 deletions
|
|
@ -523,9 +523,16 @@ void FileSource::load_sites_from_file(const std::string& path)
|
|||
file_close(file_id);
|
||||
}
|
||||
|
||||
// Make sure particles in source file have valid types
|
||||
// Make sure particles in source file have valid types. If any particle is a
|
||||
// photon, electron, or positron, enable photon transport so that the
|
||||
// appropriate cross sections are loaded.
|
||||
for (const auto& site : this->sites_) {
|
||||
validate_particle_type(site.particle, "FileSource");
|
||||
if (site.particle == ParticleType::photon() ||
|
||||
site.particle == ParticleType::electron() ||
|
||||
site.particle == ParticleType::positron()) {
|
||||
settings::photon_transport = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,3 +145,27 @@ def test_source_file_transport(run_in_tmpdir):
|
|||
|
||||
# Try running OpenMC
|
||||
model.run()
|
||||
|
||||
|
||||
def test_source_file_photon_transport(run_in_tmpdir):
|
||||
# Create a source file containing a photon. Note that photon_transport is
|
||||
# not explicitly enabled in the settings -- it should be turned on
|
||||
# automatically because the source file contains a photon.
|
||||
particle = openmc.SourceParticle(E=1.0e6, particle='photon')
|
||||
openmc.write_source_file([particle], 'photon_source.h5')
|
||||
|
||||
# Create simple model to use the photon 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.FileSource(path='photon_source.h5')
|
||||
model.settings.particles = 10
|
||||
model.settings.batches = 3
|
||||
model.settings.run_mode = 'fixed source'
|
||||
|
||||
# Running OpenMC should succeed
|
||||
model.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue