@@ -54,19 +54,9 @@ class FuelHandler:
54
54
"""
55
55
56
56
def __init__ (self , operator ):
57
- # we need access to the operator to find the core, get settings, grab
58
- # other interfaces, etc.
57
+ # we need access to the operator to find the core, get settings, grab other interfaces, etc.
59
58
self .o = operator
60
59
self .moved = []
61
- self ._handleBackwardsCompatibility ()
62
-
63
- def _handleBackwardsCompatibility (self ):
64
- # prepSearch used to be part of the API but is deprecated. This will
65
- # trigger a warning if it's implemented.
66
- # We have to do this hack until we phase out old inputs.
67
- # This basically asks: "Did the custom subclass override prepSearch?"
68
- if self .prepSearch .__func__ is not FuelHandler .prepSearch :
69
- self .prepSearch ()
70
60
71
61
@property
72
62
def cycle (self ):
@@ -207,30 +197,28 @@ def prepCore(self):
207
197
"""Aux function to run before XS generation (do moderation, etc)."""
208
198
pass
209
199
210
- def prepSearch (self , * args , ** kwargs ):
200
+ @staticmethod
201
+ def _compareAssem (candidate , current ):
202
+ """Check whether the candidate assembly should replace the current ideal assembly.
203
+
204
+ Given a candidate tuple (diff1, a1) and current tuple (diff2, a2), decide whether the
205
+ candidate is better than the current ideal. This first compares the diff1 and diff2 values.
206
+ If diff1 is sufficiently less than diff2, a1 wins, returning True. Otherwise, False. If
207
+ diff1 and diff2 are sufficiently close, the assembly with the lesser assemNum wins. This
208
+ should result in a more stable comparison than on floating-point comparisons alone.
211
209
"""
212
- Optional method that can be implemented in preparation of shuffling.
210
+ if np .isclose (candidate [0 ], current [0 ], rtol = 1e-8 , atol = 1e-8 ):
211
+ return candidate [1 ].p .assemNum < current [1 ].p .assemNum
212
+ else :
213
+ return candidate [0 ] < current [0 ]
213
214
214
- Often used to prepare the scope of a shuffling branch search.
215
+ @staticmethod
216
+ def _getParamMax (a , paramName , blockLevelMax = True ):
217
+ """Get parameter with Block-level maximum."""
218
+ if blockLevelMax :
219
+ return a .getChildParamValues (paramName ).max ()
215
220
216
- Notes
217
- -----
218
- This was used historically to keep a long-lived fuel handler in sync
219
- with the reactor and can now technically be removed from the API, but
220
- many historical fuel management inputs still expect it to be called
221
- by the framework, so here it remains. New developments should
222
- avoid using it. Most code using it has been refactored to just use
223
- a ``_prepSearch`` private method.
224
-
225
- It now should not be used and will trigger a DeprecationWarning
226
- in the constructor. It's still here because old user-input code
227
- calls the parent's prepSearch, which is this.
228
- """
229
- warnings .warn (
230
- "`FuelHandler.prepSearch` is being deprecated from the framework. Please "
231
- "change your fuel management input to call this method directly." ,
232
- DeprecationWarning ,
233
- )
221
+ return a .p [paramName ]
234
222
235
223
def findAssembly (
236
224
self ,
@@ -295,24 +283,20 @@ def findAssembly(
295
283
296
284
maxParam : float or list, optional
297
285
a parameter to compare to maxVal for setting upper bounds of acceptable assemblies.
298
- If list,
299
- must correspond to parameters in maxVal in order.
286
+ If list, must correspond to parameters in maxVal in order.
300
287
301
288
minVal : float or list, optional
302
289
a value or a (parameter, multiplier) tuple for setting lower bounds
303
290
304
- For instance, if minParam = 'timeToLimit' and minVal=10, only assemblies with
305
- timeToLimit higher than 10 will be returned. (Of course, there is also maxParam and
306
- maxVal)
291
+ For instance, if minParam='timeToLimit' and minVal=10, only assemblies with timeToLimit
292
+ higher than 10 will be returned. (Of course, there is also maxParam and maxVal)
307
293
308
294
maxVal : float or list, optional
309
295
a value or a (parameter, multiplier) tuple for setting upper bounds
310
296
311
297
mandatoryLocations : list, optional
312
- a list of string-representations of locations in the core for limiting the search to
313
- several places
314
-
315
- Any locations also included in `excludedLocations` will be excluded.
298
+ A list of string-representations of locations in the core for limiting the search to
299
+ several places. Any locations also included in `excludedLocations` will be excluded.
316
300
317
301
excludedLocations : list, optional
318
302
a list of string-representations of locations in the core that will be excluded from
@@ -349,20 +333,19 @@ def findAssembly(
349
333
default: false.
350
334
351
335
findFromSfp : bool, optional
352
- if true, will look in the spent-fuel pool instead of in the core.
336
+ If true, will look in the spent-fuel pool instead of in the core.
353
337
354
338
maxNumAssems : int, optional
355
339
The maximum number of assemblies to return. Only relevant if findMany==True
356
340
357
341
circularRingFlag : bool, optional
358
- A flag to toggle on using rings that are based on distance from the center of the
359
- reactor
342
+ Toggle using rings that are based on distance from the center of the reactor
360
343
361
344
Notes
362
345
-----
363
- The call signature on this method may have gotten slightly out of hand as
364
- valuable capabilities were added in fuel management studies. For additional expansion,
365
- it may be worth reconsidering the design of these query operations ;) .
346
+ The call signature on this method may have gotten slightly out of hand as valuable
347
+ capabilities were added in fuel management studies. For additional expansion, it may be
348
+ worth reconsidering the design of these query operations.
366
349
367
350
Returns
368
351
-------
@@ -381,29 +364,8 @@ def findAssembly(
381
364
typeSpec=Flags.FEED | Flags.FUEL)
382
365
383
366
"""
384
-
385
- def compareAssem (candidate , current ):
386
- """Check whether the candidate assembly should replace the current ideal
387
- assembly.
388
-
389
- Given a candidate tuple (diff1, a1) and current tuple (diff2, a2), decide
390
- whether the candidate is better than the current ideal. This first compares
391
- the diff1 and diff2 values. If diff1 is sufficiently less than diff2, a1
392
- wins, returning True. Otherwise, False. If diff1 and diff2 are sufficiently
393
- close, the assembly with the lesser assemNum wins. This should result in a
394
- more stable comparison than on floating-point comparisons alone.
395
- """
396
- if np .isclose (candidate [0 ], current [0 ], rtol = 1e-8 , atol = 1e-8 ):
397
- return candidate [1 ].p .assemNum < current [1 ].p .assemNum
398
- else :
399
- return candidate [0 ] < current [0 ]
400
-
401
- def getParamWithBlockLevelMax (a , paramName ):
402
- if blockLevelMax :
403
- return a .getChildParamValues (paramName ).max ()
404
- return a .p [paramName ]
405
-
406
- assemList = [] # list for storing multiple results if findMany is true.
367
+ # list for storing multiple results if findMany is true.
368
+ assemList = []
407
369
408
370
# process input arguments
409
371
if targetRing is None :
@@ -452,7 +414,7 @@ def getParamWithBlockLevelMax(a, paramName):
452
414
compVal = compareTo * mult
453
415
elif param :
454
416
# assume compareTo is an assembly
455
- compVal = getParamWithBlockLevelMax (compareTo , param ) * mult
417
+ compVal = FuelHandler . _getParamMax (compareTo , param , blockLevelMax ) * mult
456
418
457
419
if coords :
458
420
# find the assembly closest to xt,yt if coords are given without considering params.
@@ -501,12 +463,16 @@ def getParamWithBlockLevelMax(a, paramName):
501
463
if isinstance (minVal , tuple ):
502
464
# tuple turned in. it's a multiplier and a param
503
465
realMinVal = (
504
- getParamWithBlockLevelMax (a , minVal [0 ]) * minVal [1 ]
466
+ FuelHandler ._getParamMax (a , minVal [0 ], blockLevelMax )
467
+ * minVal [1 ]
505
468
)
506
469
else :
507
470
realMinVal = minVal
508
471
509
- if getParamWithBlockLevelMax (a , minParam ) < realMinVal :
472
+ if (
473
+ FuelHandler ._getParamMax (a , minParam , blockLevelMax )
474
+ < realMinVal
475
+ ):
510
476
# this assembly does not meet the minVal specifications. Skip it.
511
477
innocent = False
512
478
break # for speed (not a big deal here)
@@ -521,12 +487,16 @@ def getParamWithBlockLevelMax(a, paramName):
521
487
if isinstance (maxVal , tuple ):
522
488
# tuple turned in. it's a multiplier and a param
523
489
realMaxVal = (
524
- getParamWithBlockLevelMax (a , maxVal [0 ]) * maxVal [1 ]
490
+ FuelHandler ._getParamMax (a , maxVal [0 ], blockLevelMax )
491
+ * maxVal [1 ]
525
492
)
526
493
else :
527
494
realMaxVal = maxVal
528
495
529
- if getParamWithBlockLevelMax (a , maxParam ) > realMaxVal :
496
+ if (
497
+ FuelHandler ._getParamMax (a , maxParam , blockLevelMax )
498
+ > realMaxVal
499
+ ):
530
500
# this assembly has a maxParam that's higher than maxVal and therefore
531
501
# doesn't qualify. skip it.
532
502
innocent = False
@@ -551,23 +521,25 @@ def getParamWithBlockLevelMax(a, paramName):
551
521
552
522
# Now find the assembly with the param closest to the target val.
553
523
if param :
554
- diff = abs (getParamWithBlockLevelMax (a , param ) - compVal )
524
+ diff = abs (
525
+ FuelHandler ._getParamMax (a , param , blockLevelMax ) - compVal
526
+ )
555
527
556
528
if (
557
529
forceSide == 1
558
- and getParamWithBlockLevelMax (a , param ) > compVal
559
- and compareAssem ((diff , a ), minDiff )
530
+ and FuelHandler . _getParamMax (a , param , blockLevelMax ) > compVal
531
+ and FuelHandler . _compareAssem ((diff , a ), minDiff )
560
532
):
561
533
# forceSide=1, so that means look in rings further out
562
534
minDiff = (diff , a )
563
535
elif (
564
536
forceSide == - 1
565
- and getParamWithBlockLevelMax (a , param ) < compVal
566
- and compareAssem ((diff , a ), minDiff )
537
+ and FuelHandler . _getParamMax (a , param , blockLevelMax ) < compVal
538
+ and FuelHandler . _compareAssem ((diff , a ), minDiff )
567
539
):
568
540
# forceSide=-1, so that means look in rings closer in from the targetRing
569
541
minDiff = (diff , a )
570
- elif compareAssem ((diff , a ), minDiff ):
542
+ elif FuelHandler . _compareAssem ((diff , a ), minDiff ):
571
543
# no preference of which side, just take the one with the closest param.
572
544
minDiff = (diff , a )
573
545
else :
0 commit comments