Style fixes

This commit is contained in:
Paul Romano 2026-03-11 17:46:39 -05:00
parent 2c24698437
commit 5af848f6fd
3 changed files with 22 additions and 20 deletions

View file

@ -618,11 +618,6 @@ class Integrator(ABC):
External source rates for the depletion system.
.. versionadded:: 0.15.3
keff_search_control : openmc.deplete._KeffSearchControl
Instance of _KeffSearchControl class to perform keff search during
transport-depletion simulation.
.. versionadded:: 0.15.4
""")
@ -1115,7 +1110,7 @@ class Integrator(ABC):
and modify ``openmc.lib`` objects accordingly (e.g., adjust control
rod position via ``openmc.lib.cells[...].translation``, material
density via ``openmc.lib.materials[...].set_densities(...)``, etc.).
**Important**: The function must modify ``openmc.lib`` objects, not
``openmc.model`` objects.
x0: float
@ -1124,7 +1119,7 @@ class Integrator(ABC):
Initial upper bound for the keff search.
bracket : list[float]
Bracket interval [x_min, x_max] that constrains the allowed parameter
values during the keff search. This is a required parameter
values during the keff search. This is a required parameter
that defines the absolute bounds for the search. The bracket must contain
exactly 2 elements with bracket[0] < bracket[1]. These values are passed
directly to the ``x_min`` and ``x_max`` optional arguments in
@ -1186,8 +1181,8 @@ class Integrator(ABC):
"""
self._keff_search_control = _KeffSearchControl(
self.operator,
function,
self.operator,
function,
x0,
x1,
bracket,

View file

@ -79,14 +79,17 @@ def model():
return openmc.Model(geometry, materials, settings)
def translate_cell(position):
cell_trans = [cell for cell in openmc.lib.cells.values() if cell.name == 'trans_cell'][0]
openmc.lib.cells[cell_trans.id].translation = [0, 0, position]
def rotate_cell(angle):
cell_rot = [cell for cell in openmc.lib.cells.values() if cell.name == 'rot_cell'][0]
openmc.lib.cells[cell_rot.id].rotation = [0, 0, angle]
def adjust_material_density(density_factor):
f = [material for material in openmc.lib.materials.values() if material.name == 'f'][0]
nuclides = openmc.lib.materials[f.id].nuclides
@ -96,12 +99,12 @@ def adjust_material_density(density_factor):
densities[nuc_idx] = new_density
openmc.lib.materials[f.id].set_densities(nuclides, densities)
@pytest.mark.parametrize("function, x0, x1, bracket, ref_result", [
(translate_cell, -11, -5, [-15,0], 'depletion_with_translation'),
(rotate_cell, -80, -50, [-90,0], 'depletion_with_rotation'),
(adjust_material_density, 0.5, 2, [0.3, 3.0], 'depletion_with_refuel')
])
@pytest.mark.parametrize("function, x0, x1, bracket, ref_result", [
(translate_cell, -11, -5, (-15, 0), 'depletion_with_translation'),
(rotate_cell, -80, -50, (-90, 0), 'depletion_with_rotation'),
(adjust_material_density, 0.5, 2, (0.3, 3.0), 'depletion_with_refuel')
])
def test_keff_search_control(run_in_tmpdir, model, function, x0, x1, bracket, ref_result):
chain_file = Path(__file__).parents[2] / 'chain_simple.xml'
@ -114,10 +117,10 @@ def test_keff_search_control(run_in_tmpdir, model, function, x0, x1, bracket, re
x0=x0,
x1=x1,
bracket=bracket,
output=True,
k_tol=1e-1,
output=True,
k_tol=1e-1,
sigma_final=5e-2)
integrator.integrate()
# Get path to test and reference results

View file

@ -69,18 +69,21 @@ def integrator(operator):
return openmc.deplete.PredictorIntegrator(
operator, [1,1], 0.0, timestep_units = 'd')
def translate_cell(position):
"""Helper function to translate a cell"""
cell = [c for c in openmc.lib.cells.values() if c.name == 'universe_cell'][0]
openmc.lib.cells[cell.id].translation = [0, 0, position]
return position
def rotate_cell(angle):
"""Helper function to rotate a cell"""
cell = [c for c in openmc.lib.cells.values() if c.name == 'universe_cell'][0]
openmc.lib.cells[cell.id].rotation = [0, 0, angle]
return angle
def adjust_fuel_density(density_factor):
"""Helper function to adjust fuel density"""
fuel = [m for m in openmc.lib.materials.values() if m.name == 'fuel'][0]
@ -90,6 +93,7 @@ def adjust_fuel_density(density_factor):
openmc.lib.materials[fuel.id].set_densities(nuclides, new_densities)
return density_factor
@pytest.mark.parametrize("function, x0, x1, bracket, test_value", [
(translate_cell, -1.0, 1.0, [-5.0, 5.0], 0.5),
(rotate_cell, -45.0, 45.0, [-90.0, 90.0], 10.0),
@ -110,12 +114,12 @@ def test_integrator_add_keff_search_control(run_in_tmpdir, model, operator, inte
k_tol=0.1,
output=False,
)
assert integrator.keff_search_control.x0 == x0
assert integrator.keff_search_control.x1 == x1
assert integrator.keff_search_control.function == test_function
assert integrator.keff_search_control.search_kwargs['x_min'] == bracket[0]
assert integrator.keff_search_control.search_kwargs['x_max'] == bracket[1]
assert integrator.keff_search_control.search_kwargs['x_max'] == bracket[1]
assert integrator.keff_search_control.search_kwargs['k_tol'] == 0.1
assert integrator.keff_search_control.search_kwargs['output'] == False
assert not integrator.keff_search_control.search_kwargs['output']
openmc.lib.finalize()