Skip to content

Commit

Permalink
Change component spatialLocator to CoordinateLocation (#334)
Browse files Browse the repository at this point in the history
Changed the assignment of automatic spatialLocators of components to be
a CoordinateLocation. Also changed test_plotting to make sure the svg
files got deleted.
  • Loading branch information
chris10mckenz committed Jul 16, 2021
1 parent c6dcd98 commit 1460486
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion armi/reactor/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ def autoCreateSpatialGrids(self):
if c.getDimension("mult") > 1:
c.spatialLocator = spatialLocators
elif c.getDimension("mult") == 1:
c.spatialLocator = grid[0, 0, 0]
c.spatialLocator = grids.CoordinateLocation(0.0, 0.0, 0.0, grid)

def getPinCenterFlatToFlat(self, cold=False):
"""Return the flat-to-flat distance between the centers of opposing pins in the outermost ring."""
Expand Down
30 changes: 17 additions & 13 deletions armi/utils/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from armi.reactor.tests import test_reactors
from armi.tests import ISOAA_PATH, TEST_ROOT
from armi.reactor.flags import Flags
from armi.utils.directoryChangers import TemporaryDirectoryChanger


class TestPlotting(unittest.TestCase):
Expand Down Expand Up @@ -90,25 +91,28 @@ def test_plotBlockFlux(self):
os.remove("bList2.png") # created during the call.

def test_plotHexBlock(self):
first_fuel_block = self.r.core.getFirstBlock(Flags.FUEL)
first_fuel_block.autoCreateSpatialGrids()
plotting.plotBlockDiagram(first_fuel_block, "blockDiagram23.svg", True)
self._checkExists("blockDiagram23.svg")
with TemporaryDirectoryChanger():
first_fuel_block = self.r.core.getFirstBlock(Flags.FUEL)
first_fuel_block.autoCreateSpatialGrids()
plotting.plotBlockDiagram(first_fuel_block, "blockDiagram23.svg", True)
self.assertTrue(os.path.exists("blockDiagram23.svg"))

def test_plotCartesianBlock(self):
from armi import settings
from armi.reactor import blueprints, reactors

cs = settings.Settings(
os.path.join(TEST_ROOT, "tutorials", "c5g7-settings.yaml")
)
with TemporaryDirectoryChanger():
cs = settings.Settings(
os.path.join(TEST_ROOT, "tutorials", "c5g7-settings.yaml")
)

blueprint = blueprints.loadFromCs(cs)
r = reactors.factory(cs, blueprint)
for name, bDesign in blueprint.blockDesigns.items():
b = bDesign.construct(cs, blueprint, 0, 1, 1, "AA", {})
plotting.plotBlockDiagram(b, "{}.svg".format(name), True)
self._checkExists("uo2.svg")
blueprint = blueprints.loadFromCs(cs)
r = reactors.factory(cs, blueprint)
for name, bDesign in blueprint.blockDesigns.items():
b = bDesign.construct(cs, blueprint, 0, 1, 1, "AA", {})
plotting.plotBlockDiagram(b, "{}.svg".format(name), True)
self.assertTrue(os.path.exists("uo2.svg"))
self.assertTrue(os.path.exists("mox.svg"))

def _checkExists(self, fName):
self.assertTrue(os.path.exists(fName))
Expand Down

0 comments on commit 1460486

Please sign in to comment.