11""" Tests for KeffSearchControl class """
22
3+ from hmac import new
34from pathlib import Path
45import shutil
56import sys
@@ -89,14 +90,16 @@ def rotate_cell(angle):
8990def adjust_material_density (density_factor ):
9091 f = [material for material in openmc .lib .materials .values () if material .name == 'f' ][0 ]
9192 nuclides = openmc .lib .materials [f .id ].nuclides
92- current_densities = openmc .lib .materials [f .id ].densities
93- new_densities = [d * density_factor for d in current_densities ]
94- openmc .lib .materials [f .id ].set_densities (nuclides , new_densities )
93+ densities = openmc .lib .materials [f .id ].densities
94+ nuc_idx = nuclides .index ('U235' )
95+ new_density = densities [nuc_idx ] * density_factor
96+ densities [nuc_idx ] = new_density
97+ openmc .lib .materials [f .id ].set_densities (nuclides , densities )
9598
9699@pytest .mark .parametrize ("function, x0, x1, bracket, ref_result" , [
97100 (translate_cell , - 11 , - 5 , [- 15 ,0 ], 'depletion_with_translation' ),
98101 (rotate_cell , - 80 , - 50 , [- 90 ,0 ], 'depletion_with_rotation' ),
99- (adjust_material_density , 0.5 , 1. 2 , [0.2 , 1.5 ], 'depletion_with_refuel' )
102+ (adjust_material_density , 0.5 , 2 , [0.3 , 3.0 ], 'depletion_with_refuel' )
100103 ])
101104
102105def test_keff_search_control (run_in_tmpdir , model , function , x0 , x1 , bracket , ref_result ):
@@ -106,10 +109,14 @@ def test_keff_search_control(run_in_tmpdir, model, function, x0, x1, bracket, re
106109
107110 integrator = openmc .deplete .PredictorIntegrator (
108111 op , [1 ], 174. , timestep_units = 'd' )
109- integrator .add_keff_search_control (function , x0 , x1 , bracket ,
112+ integrator .add_keff_search_control (
113+ function = function ,
114+ x0 = x0 ,
115+ x1 = x1 ,
116+ bracket = bracket ,
110117 output = True ,
111- k_tol = 1e-2 ,
112- sigma_final = 5e-3 )
118+ k_tol = 1e-1 ,
119+ sigma_final = 5e-2 )
113120
114121 integrator .integrate ()
115122
0 commit comments