Ejemplo n.º 1
0
    def test_edgeAssemblies(self):
        r"""
        Sanity check on adding edge assemblies.
        """
        converter = geometryConverters.EdgeAssemblyChanger()
        converter.addEdgeAssemblies(self.r.core)

        # must be added after geom transform
        for b in self.o.r.core.getBlocks():
            b.p.power = 1.0

        numAssems = len(self.r.core.getAssemblies())
        converter.scaleParamsRelatedToSymmetry(self.r)

        a = self.r.core.getAssembliesOnSymmetryLine(
            locations.BOUNDARY_0_DEGREES)[0]
        self.assertTrue(all(b.p.power == 2.0 for b in a),
                        "Powers were not scaled")

        converter.removeEdgeAssemblies(self.r.core)
        self.assertTrue(numAssems > len(self.r.core.getAssemblies()))
        converter.addEdgeAssemblies(self.r.core)
        self.assertTrue(numAssems == len(self.r.core.getAssemblies()))
        # make sure it can be called twice.
        converter.addEdgeAssemblies(self.r.core)
        self.assertTrue(numAssems == len(self.r.core.getAssemblies()))
Ejemplo n.º 2
0
    def _performGeometryTransformations(self, makePlots=False):
        """
        Apply geometry conversions to make reactor work in neutronics

        There are two conditions where things must happen:

        1. If you are doing finite-difference, you need to add the edge assemblies (fast).
           For this, we just modify the reactor in place

        2. If you are doing detailed axial expansion, you need to average out the axial mesh (slow!)
           For this we need to create a whole copy of the reactor and use that.

        In both cases, we need to undo the modifications between reading the output
        and applying the result to the data model.

        See Also
        --------
        _undoGeometryTransformations
        """
        if any(self.geomConverters):
            raise RuntimeError(
                "The reactor has been transformed, but not restored to the original.\n"
                + "Geometry converter is set to {} \n.".format(
                    self.geomConverters) +
                "This is a programming error and requires further investigation."
            )
        neutronicsReactor = self.r
        if self.options.detailedAxialExpansion:
            converter = self.geomConverters.get("axial")
            if not converter:
                converter = uniformMesh.NeutronicsUniformMeshConverter(
                    None,
                    calcReactionRates=self.options.
                    calcReactionRatesOnMeshConversion,
                )
                neutronicsReactor = converter.convert(self.r)
                if makePlots:
                    converter.plotConvertedReactor()
                self.geomConverters["axial"] = converter

        if self.edgeAssembliesAreNeeded():
            converter = self.geomConverters.get(
                "edgeAssems", geometryConverters.EdgeAssemblyChanger())
            converter.addEdgeAssemblies(neutronicsReactor.core)
            self.geomConverters["edgeAssems"] = converter

        self.r = neutronicsReactor
Ejemplo n.º 3
0
    def _modifyGeometry(self, container, gridDesign):
        """Perform post-load geometry conversions like full core, edge assems."""
        # all cases should have no edge assemblies. They are added ephemerally when needed
        from armi.reactor.converters import geometryConverters  # circular imports

        runLog.header(
            "=========== Applying Geometry Modifications ===========")
        converter = geometryConverters.EdgeAssemblyChanger()
        converter.removeEdgeAssemblies(container)

        # now update the spatial grid dimensions based on the populated children
        # (unless specified on input)
        if not gridDesign.latticeDimensions:
            runLog.info(
                "Updating spatial grid pitch data for {} geometry".format(
                    container.geomType))
            if container.geomType == geometry.HEX:
                container.spatialGrid.changePitch(container[0][0].getPitch())
            elif container.geomType == geometry.CARTESIAN:
                xw, yw = container[0][0].getPitch()
                container.spatialGrid.changePitch(xw, yw)
Ejemplo n.º 4
0
    def test_findNeighbors(self):

        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(1, 1)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(
            a, duplicateAssembliesOnReflectiveBoundary=True)
        locs = [a.getLocation() for a in neighbs]
        self.assertEqual(len(neighbs), 6)
        self.assertIn("A2001", locs)
        self.assertIn("A2002", locs)
        self.assertEqual(locs.count("A2001"), 3)

        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(1, 1)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(
            a, duplicateAssembliesOnReflectiveBoundary=True)
        locs = [a.getLocation() for a in neighbs]
        self.assertEqual(locs, ["A2001", "A2002"] * 3, 6)

        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(2, 2)
        a = self.r.core.childrenByLocator[loc]

        neighbs = self.r.core.findNeighbors(
            a, duplicateAssembliesOnReflectiveBoundary=True)
        locs = [a.getLocation() for a in neighbs]
        self.assertEqual(len(neighbs), 6)
        self.assertEqual(
            locs, ["A3002", "A3003", "A3012", "A2001", "A1001", "A2001"])

        # try with edge assemblies
        # With edges, the neighbor is the one that's actually next to it.
        converter = geometryConverters.EdgeAssemblyChanger()
        converter.addEdgeAssemblies(self.r.core)
        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(2, 2)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(
            a, duplicateAssembliesOnReflectiveBoundary=True)
        locs = [a.getLocation() for a in neighbs]
        self.assertEqual(len(neighbs), 6)
        # in this case no locations that aren't actually in the core should be returned
        self.assertEqual(
            locs, ["A3002", "A3003", "A3004", "A2001", "A1001", "A2001"])
        converter.removeEdgeAssemblies(self.r.core)

        # try with full core
        self.r.core.growToFullCore(self.o.cs)
        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(3, 4)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(a)
        self.assertEqual(len(neighbs), 6)
        locs = [a.getLocation() for a in neighbs]
        for loc in ["A2002", "A2003", "A3003", "A3005", "A4005", "A4006"]:
            self.assertIn(loc, locs)

        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(2, 2)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(a)
        locs = [a.getLocation() for a in neighbs]
        for loc in ["A1001", "A2001", "A2003", "A3002", "A3003", "A3004"]:
            self.assertIn(loc, locs)

        # Try the duplicate option in full core as well
        loc = self.r.core.spatialGrid.getLocatorFromRingAndPos(2, 2)
        a = self.r.core.childrenByLocator[loc]
        neighbs = self.r.core.findNeighbors(
            a, duplicateAssembliesOnReflectiveBoundary=True)
        locs = [a.getLocation() for a in neighbs]
        self.assertEqual(len(neighbs), 6)
        self.assertEqual(
            locs, ["A3002", "A3003", "A3004", "A2003", "A1001", "A2001"])