Hello,
I’m currently using OpenMC 0.14
I have different cells that I regrouped into group1_cell = [cell1, cell2,…]
Each cells is composed of different materials.
My objective would be to create an homogenized multigroup cross sections library for each groups of cells. I tried get_homogenized_mgxs while I’m not totally sure it’s for this use but got the error: AttributeError: ‘Library’ object has no attribute ‘get_homogenized_mgxs’
Here is an example of my code:
Group1 = [cell_501]
Group2 = [cell_503]
Group2 += [cell for cell in Group2_cells()]
root_cell = []
root_cell += [cell for cell in Group1]
root_cell += [cell for cell in Group2]
# outside with void cells
cell_997 = openmc.Cell(region= +s_2&-s_5&+s_4)
root_cell += [cell_997]
cell_998 = openmc.Cell(region= +s_5)
root_cell += [cell_998]
cell_999 = openmc.Cell(region= -s_4)
root_cell += [cell_999]
all_cell_univ = openmc.Universe()
all_cell_univ.add_cells(root_cell)
#stop
#2D cell
cell2D = openmc.Cell(fill=all_cell_univ, region = -s_0001&+s_0002)
# creating model and setting
model = openmc.Model()
model.materials = materials # set materials
# Create root Universe
root_universe = openmc.Universe(universe_id=0, name='root universe')
root_universe.add_cell(cell2D)
model.geometry = openmc.Geometry(root_universe) # set geometry
# OpenMC simulation parameters
batches = 20
inactive = 5
particles = 5_000
power = 110e6
# Instantiate a Settings object
settings = openmc.Settings()
settings.batches = batches
settings.inactive = inactive
settings.particles = particles
settings.output = {'tallies': False}
settings.verbosity = 4
# Create an initial uniform spatial source distribution over fissionable zones
bounds = [-100.0, -100.0, 5, 100, 100, 6]
uniform_dist = openmc.stats.Box(bounds[:3], bounds[3:], only_fissionable=True)
settings.source = openmc.Source(space=uniform_dist)
model.settings = settings
group_edges = np.array([0., 5E-02, 3E-01, 10E-01,
4.00E+00, 10E+00, 2.0E+02,
1E+05, 8E+05, 20.0e6
])
groups = openmc.mgxs.EnergyGroups(group_edges = group_edges)
mgxs_lib = openmc.mgxs.Library(model.geometry)
mgxs_lib.energy_groups = groups
# Specify multi-group cross section types to compute
mgxs_lib.mgxs_types = ['total',
'transport',
'nu-transport',
'absorption',
'capture',]
mgxs_lib.domain_type = 'material'
mgxs_lib.legendre_order = 5
all_mat = model.geometry.get_all_materials().values()
mgxs_lib.domains = all_mat
mgxs_lib.build_library()
# Create a "tallies.xml" file for the MGXS Library
tallies = openmc.Tallies()
mgxs_lib.add_to_tallies_file(tallies, merge=True)
model.tallies = tallies
# Run OpenMC
statepoint_filename = model.run(threads=1)
# Homogenize cross sections for the structure
mgxs_lib_group1 = mgxs_lib.get_homogenized_mgxs(Group1)
# save to h5 file
sp = openmc.StatePoint(statepoint_filename)
mgxs_lib.load_from_statepoint(sp)
mgxs_lib.build_hdf5_store(filename='mgxs.h5', directory='./')