Skip to content

Commit

Permalink
Add warning when ring scheduler given questionable input (#501)
Browse files Browse the repository at this point in the history
This now adjusts ring schedules that are beyond the edge of the core and crashes if the jumpRing is outside the core. New tests were added to
demonstrate the expected behavior more rigorously. This may impact some external shuffling inputs, but if it does those may not be doing what the user expected.
  • Loading branch information
ntouran authored Feb 11, 2022
1 parent 7d1eb8d commit 4316eb7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 18 deletions.
42 changes: 35 additions & 7 deletions armi/physics/fuelCycle/fuelHandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@
import os
import re
import warnings
import logging

import numpy

from armi import interfaces
from armi import runLog
from armi.utils.customExceptions import InputError
from armi.reactor.flags import Flags
from armi.operators import RunTypes
from armi.utils import directoryChangers, pathTools
from armi import utils
from armi.utils import plotting

runLog = logging.getLogger(__name__)


class FuelHandlerInterface(interfaces.Interface):
"""
Expand Down Expand Up @@ -1174,18 +1176,44 @@ def buildRingSchedule(
findAssembly
"""
maxRingInCore = self.r.core.getNumRings()
if dischargeRing > maxRingInCore:
runLog.warning(
f"Discharge ring {dischargeRing} is outside the core (max {maxRingInCore}). "
"Changing it to be the max ring"
)
dischargeRing = maxRingInCore
if chargeRing > maxRingInCore:
runLog.warning(
f"Charge ring {chargeRing} is outside the core (max {maxRingInCore}). "
"Changing it to be the max ring."
)
chargeRing = maxRingInCore

# process arguments
if dischargeRing is None:
# default to convergent
# No discharge ring given, so we default to converging from outside to inside
# and therefore discharging from the center
dischargeRing = 1
if chargeRing is None:
chargeRing = self.r.core.getNumRings()

if chargeRing > dischargeRing and not jumpRingTo:
# Charge ring not specified. Since we default to convergent shuffling, we
# must insert the fuel at the periphery.
chargeRing = maxRingInCore
if jumpRingFrom is not None and not (1 < jumpRingFrom < maxRingInCore):
raise ValueError(f"JumpRingFrom {jumpRingFrom} is not in the core.")
if jumpRingTo is not None and not (1 < jumpRingTo < maxRingInCore):
raise ValueError(f"JumpRingTo {jumpRingTo} is not in the core.")

if chargeRing > dischargeRing and jumpRingTo is None:
# a convergent shuffle with no jumping. By setting
# jumpRingTo to be 1, no jumping will be activated
# in the later logic.
jumpRingTo = 1
elif not jumpRingTo:
elif jumpRingTo is None:
# divergent case. Disable jumping by putting jumpring
# at periphery.
if self.r:
jumpRingTo = self.r.core.getNumRings()
jumpRingTo = maxRingInCore
else:
jumpRingTo = 18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,20 +497,28 @@ def test_buReducingAssemblyRotation(self):

def test_buildRingSchedule(self):
fh = fuelHandlers.FuelHandler(self.o)
schedule, widths = fh.buildRingSchedule(17, 1, jumpRingFrom=14)

# test 1
self.assertEqual(
schedule, [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, 15, 16, 17]
)
self.assertEqual(widths, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
# simple divergent
schedule, widths = fh.buildRingSchedule(1, 9)
self.assertEqual(schedule, [9, 8, 7, 6, 5, 4, 3, 2, 1])

# test 2
# simple with 1 jump
schedule, widths = fh.buildRingSchedule(9, 1, jumpRingFrom=6)
self.assertEqual(schedule, [5, 4, 3, 2, 1, 6, 7, 8, 9])
self.assertEqual(widths, [0, 0, 0, 0, 0, 0, 0, 0, 0])

# 1 jump plus auto-correction to core size
schedule, widths = fh.buildRingSchedule(1, 17, jumpRingFrom=5)
self.assertEqual(
schedule, [17, 16, 15, 14, 13, 12, 11, 10, 6, 7, 8, 9, 5, 4, 3, 2, 1]
)
self.assertEqual(widths, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
self.assertEqual(schedule, [6, 7, 8, 9, 5, 4, 3, 2, 1])
self.assertEqual(widths, [0, 0, 0, 0, 0, 0, 0, 0, 0])

# crash on invalid jumpring
with self.assertRaises(ValueError):
schedule, widths = fh.buildRingSchedule(1, 17, jumpRingFrom=0)

# test 4: Mid way jumping
schedule, widths = fh.buildRingSchedule(1, 9, jumpRingTo=6, jumpRingFrom=3)
self.assertEqual(schedule, [9, 8, 7, 4, 5, 6, 3, 2, 1])

def test_buildConvergentRingSchedule(self):
fh = fuelHandlers.FuelHandler(self.o)
Expand Down

0 comments on commit 4316eb7

Please sign in to comment.