Skip to content

Commit

Permalink
address comments from @yardasol
Browse files Browse the repository at this point in the history
  • Loading branch information
abachma2 committed May 30, 2024
1 parent f07eb28 commit 96eb863
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 52 deletions.
4 changes: 2 additions & 2 deletions openmcyclus/DepleteReactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ def enter_notify(self):
'''
Calls the enter_notify method of the parent class.
Also defines a list for the input commodity preferences if
not are provided by the user.
none are provided by the user.
Establish the openmc.deplete.MicroXs and openmc.Materials
Establish the openmc.deplete.MicroXSxz and openmc.Materials
objects for use in simulation.
'''
super().enter_notify()
Expand Down
41 changes: 2 additions & 39 deletions openmcyclus/depletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update_materials(self, comp_list, materials):
--------
material_ids: list of strs
material id numbers for the OpenMC model
mats: openmc.Materials()
materials: openmc.Materials()
updated material object
'''

Expand All @@ -83,45 +83,8 @@ def update_materials(self, comp_list, materials):
m = nuclide - Z * int(1e7) - A * int(1e4)
nucname = openmc.data.gnds_name(Z, A, m)
material.add_nuclide(nucname, percent, percent_type='wo')
mats = materials

return material_ids, mats

def run_depletion(self, flux, materials, microxs):
'''
Run the IndependentOperator class in OpenMC to perform
transport-independent depletion. This method is only
used in the test suite, and not in the OpenMCyclus
archetype
Parameters:
-----------
flux: float
flux through nuclear fuel
materials: openmc.Materials()
material definitions to deplete
microxs: openmc.deplete.MicroXS
microscopic cross section data
Outputs:
--------
depletion_results.h5: database
HDF5 data base with the results of the depletion simulation
'''
ind_op = od.IndependentOperator(materials,
[np.array([flux])] * len(materials),
[microxs] * len(materials),
str(self.path + self.chain_file))
ind_op.output_dir = self.path
integrator = od.PredictorIntegrator(
ind_op,
np.ones(self.timesteps) * 30,
power=self.power *
1e6,
timestep_units='d')
integrator.integrate()

return
return material_ids, materials

def get_spent_comps(self, material_ids, microxs):
'''
Expand Down
53 changes: 42 additions & 11 deletions tests/unit_tests/test_depletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ def setUp(self):
self.materials = openmc.Materials().from_xml("./examples/materials.xml")
self.micro_xs = od.MicroXS.from_csv("./examples/micro_xs.csv")

def run_depletion(self, flux):
'''
Run the IndependentOperator class in OpenMC to perform
transport-independent depletion.
Parameters:
-----------
flux: float
flux through nuclear fuel
materials: openmc.Materials()
material definitions to deplete
microxs: openmc.deplete.MicroXS
microscopic cross section data
Outputs:
--------
depletion_results.h5: database
HDF5 data base with the results of the depletion simulation
'''
ind_op = od.IndependentOperator(self.materials,
[np.array([flux])] * len(self.materials),
[self.micro_xs] * len(self.materials),
str(self.deplete.path + self.deplete.chain_file))
ind_op.output_dir = self.path
integrator = od.PredictorIntegrator(
ind_op,
np.ones(self.deplete.timesteps) * 30,
power=self.deplete.power *
1e6,
timestep_units='d')
integrator.integrate()

return

def test_update_materials(self):
'''
Test that the provided compositions get written to the
Expand All @@ -33,18 +67,15 @@ def test_update_materials(self):
material_ids, materials = self.deplete.update_materials(
comps, self.materials)
assert materials[0].nuclides == [
openmc.material.NuclideTuple(
'U235', 0.05, 'wo'), openmc.material.NuclideTuple(
'U238', 0.95, 'wo')]
openmc.material.NuclideTuple('U235', 0.05, 'wo'),
openmc.material.NuclideTuple('U238', 0.95, 'wo')]
assert materials[1].nuclides == [
openmc.material.NuclideTuple(
'Cs137', 0.1, 'wo'), openmc.material.NuclideTuple(
'Kr85', 0.80, 'wo'), openmc.material.NuclideTuple(
'Xe135', 0.10, 'wo')]
openmc.material.NuclideTuple('Cs137', 0.1, 'wo'),
openmc.material.NuclideTuple('Kr85', 0.80, 'wo'),
openmc.material.NuclideTuple('Xe135', 0.10, 'wo')]
assert materials[2].nuclides == [
openmc.material.NuclideTuple(
'Pu239', 0.10, 'wo'), openmc.material.NuclideTuple(
'Pu241', 0.90, 'wo')]
openmc.material.NuclideTuple('Pu239', 0.10, 'wo'),
openmc.material.NuclideTuple('Pu241', 0.90, 'wo')]
assert material_ids == [5, 6, 7]

def test_run_depletion(self):
Expand All @@ -53,7 +84,7 @@ def test_run_depletion(self):
This test makes sure that the depletion runs with the correct
output file created.
'''
self.deplete.run_depletion(10.3, self.materials, self.micro_xs)
self.run_depletion(10.3, self.materials, self.micro_xs)
assert os.path.isfile('examples/depletion_results.h5')
os.system('rm examples/depletion_results.h5')

Expand Down

0 comments on commit 96eb863

Please sign in to comment.