Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing DerivedShape.getArea() for cold=true #1831

Merged
merged 5 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions armi/reactor/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def getComponentArea(self, cold=False):
Parameters
----------
cold : bool, optional
Ignored for this component
If True, compute the area with as-input dimensions, instead of thermally-expanded.
"""
coldArea = self.p.area
if cold:
Expand All @@ -173,6 +173,13 @@ def getBoundingCircleOuterDiameter(self, Tc=None, cold=False):
This is the smallest it can possibly be. Since this is used to determine
the outer component, it will never be allowed to be the outer one.

Parameters
----------
Tc : float
Ignored for this component
cold : bool, optional
If True, compute the area with as-input dimensions, instead of thermally-expanded.

Notes
-----
Tc is not used in this method for this particular component.
Expand Down Expand Up @@ -451,8 +458,17 @@ def getComponentArea(self, cold=False):
Parameters
----------
cold : bool, optional
Ignored for this component
If True, compute the area with as-input dimensions, instead of thermally-expanded.
"""
if cold:
# At cold temp, the DerivedShape has the area of the parent minus the other siblings
parentArea = self.parent.getArea()
# NOTE: the assumption is there is only one DerivedShape in each Component
siblings = sum(
[c.getArea(cold=True) for c in self.parent if type(c) != DerivedShape]
)
return parentArea - siblings

if self.parent.derivedMustUpdate:
self.computeVolume()

Expand Down
28 changes: 27 additions & 1 deletion armi/reactor/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import math
import unittest

from armi.materials import air, alloy200
from armi.materials.material import Material
from armi.reactor import components
from armi.reactor import flags
Expand Down Expand Up @@ -44,7 +45,7 @@
ComponentType,
)
from armi.reactor.components import materials
from armi.materials import air, alloy200
from armi.reactor.tests.test_reactors import loadTestReactor


class TestComponentFactory(unittest.TestCase):
Expand Down Expand Up @@ -482,6 +483,31 @@ def test_computeVolume(self):
self.assertAlmostEqual(c.computeVolume(), 1386.5232044586771)


class TestDerivedShapeGetArea(unittest.TestCase):
def test_getAreaColdTrue(self):
"""Prove that the DerivedShape.getArea() works at cold=True."""
# load one-block test reactor
_o, r = loadTestReactor(
inputFileName="smallestTestReactor/armiRunSmallest.yaml"
)
b = r.core[0][0]

# ensure there is a DerivedShape in this Block
shapes = set([type(c) for c in b])
self.assertIn(Circle, shapes)
self.assertIn(DerivedShape, shapes)
self.assertIn(Helix, shapes)
self.assertIn(Hexagon, shapes)

# prove that getArea works on the block level
self.assertAlmostEqual(b.getArea(cold=True), b.getArea(cold=False), delta=1e-10)

# prove that getArea preserves the sum of all the areas, even if there is a DerivedShape
totalAreaCold = sum([c.getArea(cold=True) for c in b])
totalAreaHot = sum([c.getArea(cold=False) for c in b])
self.assertAlmostEqual(totalAreaCold, totalAreaHot, delta=1e-10)


class TestCircle(TestShapedComponent):
"""Test circle shaped component."""

Expand Down
2 changes: 2 additions & 0 deletions doc/release/0.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ API Changes

Bug Fixes
---------
#. Fixed ``DerivedShape.getArea`` for ``cold=True``. (`PR#1831 <https://github.com/terrapower/armi/pull/1831>`_)
#. Fixed error parsing command line integers in ``ReportsEntryPoint``. (`PR#1824 <https://github.com/terrapower/armi/pull/1824>`_)
#. TBD

Quality Work
------------
#. Removing code that causes a deprecation warning (converting ``axialUnitGrid`` to ``AxialGrid.fromNCells``) (`PR#1809 <https://github.com/terrapower/armi/pull/1809>`_)
#. TBD

Changes that Affect Requirements
--------------------------------
Expand Down
Loading