diff --git a/armi/physics/neutronics/parameters.py b/armi/physics/neutronics/parameters.py index ef61fd680..78268b8ba 100644 --- a/armi/physics/neutronics/parameters.py +++ b/armi/physics/neutronics/parameters.py @@ -163,7 +163,7 @@ def _getNeutronicsBlockParams(): "pinMgFluxes", units=f"n/{units.CM}^2/{units.SECONDS}", description=""" - The block-level pin multigroup fluxes. pinMgFluxes[g][i] represents the flux in group g + The block-level pin multigroup fluxes. pinMgFluxes[i, g] represents the flux in group g for pin i. Flux units are the standard n/cm^2/s. The "ARMI pin ordering" is used, which is counter-clockwise from 3 o'clock. """, @@ -175,7 +175,7 @@ def _getNeutronicsBlockParams(): pb.defParam( "pinMgFluxesAdj", units=units.UNITLESS, - description="should be a blank 3-D array, but re-defined later (ng x nPins x nAxialSegments)", + description="should be a blank 3-D array, but re-defined later (nPins x ng x nAxialSegments)", categories=[parameters.Category.pinQuantities], saveToDB=False, default=None, @@ -184,7 +184,7 @@ def _getNeutronicsBlockParams(): pb.defParam( "pinMgFluxesGamma", units=f"#/{units.CM}^2/{units.SECONDS}", - description="should be a blank 3-D array, but re-defined later (ng x nPins x nAxialSegments)", + description="should be a blank 3-D array, but re-defined later (nPins x ng x nAxialSegments)", categories=[parameters.Category.pinQuantities, parameters.Category.gamma], saveToDB=False, default=None, diff --git a/armi/reactor/blocks.py b/armi/reactor/blocks.py index 7d9f4cb51..918108a5d 100644 --- a/armi/reactor/blocks.py +++ b/armi/reactor/blocks.py @@ -351,13 +351,10 @@ def setPinMgFluxes(self, fluxes, adjoint=False, gamma=False): """ Store the pin-detailed multi-group neutron flux. - The [g][i] indexing is transposed to be a list of lists, one for each pin. This makes it - simple to do depletion for each pin, etc. - Parameters ---------- - fluxes : 2-D list of floats - The block-level pin multigroup fluxes. fluxes[g][i] represents the flux in group g for + fluxes : np.ndarray + The block-level pin multigroup fluxes. fluxes[i, g] represents the flux in group g for pin i. Flux units are the standard n/cm^2/s. The "ARMI pin ordering" is used, which is counter-clockwise from 3 o'clock. adjoint : bool, optional @@ -367,28 +364,16 @@ def setPinMgFluxes(self, fluxes, adjoint=False, gamma=False): Outputs ------- - self.p.pinMgFluxes : 2-D array of floats - The block-level pin multigroup fluxes. pinMgFluxes[g][i] represents the flux in group g + self.p.pinMgFluxes : np.ndarray + The block-level pin multigroup fluxes. pinMgFluxes[i, g] represents the flux in group g for pin i. Flux units are the standard n/cm^2/s. The "ARMI pin ordering" is used, which is counter-clockwise from 3 o'clock. """ - pinFluxes = [] - - G, nPins = fluxes.shape - - for pinNum in range(1, nPins + 1): - thisPinFlux = [] - - if self.hasFlags(Flags.FUEL): - pinLoc = self.p.pinLocation[pinNum - 1] - else: - pinLoc = pinNum - - for g in range(G): - thisPinFlux.append(fluxes[g][pinLoc - 1]) - pinFluxes.append(thisPinFlux) + if self.hasFlags(Flags.FUEL): + pinFluxes = fluxes[(np.array(self.p.pinLocation) - 1)] + else: + pinFluxes = fluxes[:] - pinFluxes = np.array(pinFluxes) if gamma: if adjoint: raise ValueError("Adjoint gamma flux is currently unsupported.") diff --git a/armi/reactor/tests/test_blocks.py b/armi/reactor/tests/test_blocks.py index d7b7f2a0c..d9e1b51a1 100644 --- a/armi/reactor/tests/test_blocks.py +++ b/armi/reactor/tests/test_blocks.py @@ -1715,13 +1715,29 @@ def test_pinMgFluxes(self): .. warning:: This will likely be pushed to the component level. """ - fluxes = np.ones((33, 10)) + fluxes = np.random.rand(10, 33) + p, g = np.random.randint(low=0, high=[10, 33]) + + # Test without pinLocation + self.block.pinLocation = None self.block.setPinMgFluxes(fluxes) self.block.setPinMgFluxes(fluxes * 2, adjoint=True) self.block.setPinMgFluxes(fluxes * 3, gamma=True) - self.assertEqual(self.block.p.pinMgFluxes[0][2], 1.0) - self.assertEqual(self.block.p.pinMgFluxesAdj[0][2], 2.0) - self.assertEqual(self.block.p.pinMgFluxesGamma[0][2], 3.0) + self.assertEqual(self.block.p.pinMgFluxes.shape, (10, 33)) + self.assertEqual(self.block.p.pinMgFluxes[p, g], fluxes[p, g]) + self.assertEqual(self.block.p.pinMgFluxesAdj.shape, (10, 33)) + self.assertEqual(self.block.p.pinMgFluxesAdj[p, g], fluxes[p, g] * 2) + self.assertEqual(self.block.p.pinMgFluxesGamma.shape, (10, 33)) + self.assertEqual(self.block.p.pinMgFluxesGamma[p, g], fluxes[p, g] * 3) + + # Test with pinLocation + self.block.setType(self.block.getType(), Flags.FUEL) + self.block.p.pinLocation = np.random.choice(10, size=10, replace=False) + 1 + self.block.setPinMgFluxes(fluxes) + self.assertEqual(self.block.p.pinMgFluxes.shape, (10, 33)) + self.assertEqual( + self.block.p.pinMgFluxes[p, g], fluxes[self.block.p.pinLocation[p] - 1, g] + ) def test_getComponentsInLinkedOrder(self): comps = self.block.getComponentsInLinkedOrder() diff --git a/doc/release/0.4.rst b/doc/release/0.4.rst index 73dd36408..e427faf9a 100644 --- a/doc/release/0.4.rst +++ b/doc/release/0.4.rst @@ -33,6 +33,7 @@ API Changes #. Allowing for unknown Flags when opening a DB. (`PR#1844 `_) #. Removing ``assemblyLists.py`` and the ``AssemblyList`` class. (`PR#1891 `_) #. Removing ``Assembly.rotatePins`` and ``Block.rotatePins``. Prefer ``Assembly.rotate`` and ``Block.rotate``. (`PR#1846 `) #. TBD Bug Fixes