Hybrid Multigroup Transport#
This fixed-source problem combines native H-1 composition with one-group neutron multigroup data on the same material.
The 1 eV source lies inside the multigroup interval from 0.1 to 10 eV, while the 1 MeV source uses native H-1 physics outside that interval.
Multigroup scattering represents the outgoing group at its 5.05 eV midpoint.
The tally uses physical energy boundaries because particle energy remains in eV during hybrid transport.
The example requires MCDC_LIB to identify a native-data library containing H1-293.6K.h5.
Full Input#
1import numpy as np
2
3import mcdc
4
5simulation = mcdc.Simulation("Hybrid multigroup sphere")
6
7# Material with native H-1 data and a low-energy multigroup treatment
8# MCDC_LIB must contain H1-293.6K.h5.
9material = mcdc.Material(
10 nuclide_composition={"H1": 5.0e-2},
11 neutron_multigroup=mcdc.NeutronMultigroupData(
12 capture=np.array([0.2]),
13 scatter=np.array([[0.8]]),
14 speed=np.array([1.383e6]),
15 energy_grid=np.array([0.1, 10.0]),
16 energy_representation="midpoint",
17 ),
18)
19
20# Spherical domain
21boundary = mcdc.Surface.Sphere(radius=5.0, boundary_condition="vacuum")
22cell = mcdc.Cell(region=-boundary, fill=material)
23simulation.set_model([cell])
24
25# The low-energy source uses multigroup physics
26multigroup_source = mcdc.Source(
27 position=[0.0, 0.0, 1.0],
28 isotropic=True,
29 energy=1.0,
30 probability=0.5,
31)
32
33# The high-energy source lies outside the multigroup grid and uses native physics
34native_source = mcdc.Source(
35 position=[0.0, 0.0, -1.0],
36 isotropic=True,
37 energy=1.0e6,
38 probability=0.5,
39)
40simulation.set_sources([multigroup_source, native_source])
41
42# Hybrid tallies use physical energy boundaries in eV
43mesh = mcdc.MeshStructured(z=np.array([-5.0, 0.0, 5.0]))
44tally = mcdc.Tally(
45 name="hybrid_flux",
46 mesh=mesh,
47 particle_type="neutron",
48 energy=np.array([0.0, 0.1, 10.0, 1.0e5, 20.0e6]),
49 scores=["flux", "collision"],
50)
51simulation.set_tallies([tally])
52
53simulation.settings.N_particle = 1_000
54simulation.settings.N_batch = 5
55simulation.settings.output_name = "hybrid_multigroup"
56
57simulation.run()
Post-processing#
1import h5py
2import matplotlib.pyplot as plt
3import numpy as np
4
5with h5py.File("hybrid_multigroup.h5", "r") as output:
6 tally = output["tallies/hybrid_flux"]
7 z = tally["grid/z"][:]
8 energy = tally["grid/energy"][:]
9 flux = tally["flux/mean"][:]
10
11dz = z[1:] - z[:-1]
12z_midpoint = 0.5 * (z[:-1] + z[1:])
13flux = np.reshape(flux, (len(energy) - 1, len(z) - 1)) / dz
14
15figure, axis = plt.subplots()
16for index in range(len(energy) - 1):
17 axis.plot(
18 z_midpoint,
19 flux[index],
20 marker="o",
21 label=f"{energy[index]:.1e}–{energy[index + 1]:.1e} eV",
22 )
23
24axis.set_xlabel("z [cm]")
25axis.set_ylabel("Flux")
26axis.grid()
27axis.legend()
28figure.tight_layout()
29figure.savefig("hybrid_multigroup_flux.png", dpi=150)
How to Run#
From inside examples/hybrid_multigroup:
python input.py
python process-output.py
The transport calculation writes hybrid_multigroup.h5 and the post-processing script writes hybrid_multigroup_flux.png.