Closed albeanth closed 2 years ago
setOptionsFromCs(self,cs)
to each class that needs specific CaseSettings
attributes. Just like is done for Core
.
https://github.com/terrapower/armi/blob/22399244a88e67fc09996981081f7d5aab7032b4/armi/reactor/blueprints/reactorBlueprint.py#L143-L147My hesitation is with the TODO statement. Makes me think it may not be the best idea...?
ArmiObject
and all its children direct access to all of the attributes within CaseSettings
.
@ntouran @albeanth
I am not sure I am in favor of this change. It just seems like... we've made it this long without needing this access. So it must be possible to do what we need without adding it now.
In particular, I believe this is entirely driven by the need to add the before-mentioned inputHeightsConsideredHot
Setting.
In my opinion, we could save a LOT of effort implementing the change proposed by this Issue by simply making one breaking change:
All temperatures in Settings file will be considered "cold".
This is a breaking change, but certainly it's one we expect to make at some point anyway, right?
Super high level: the state objects of the reactor subpackages should not ever need any information about the initial input at all. The entire state should be reflected as state variables, regardless of how it shows up. This way, models can work made from inputs, made programmatically, made by machine learning, made from databases. I will try to understand the need for this request in #657.
Meanwhile, of the options proposed, I strongly prefer adding another setting to the existing setOptionsFromCs
on the core and then using getAncestor
to get it. We maybe can move the .core
property from Block
to ArmiObject
to make it more convenient. Then you can access thing.core._mySpecialSetting
.
the parent.parent.parent
class of options won't work because the hierarchy of an ARMI reactor isn't always consistent. We're adding more options to have blocks with components that have extra children, and component groups (#525) and other related things. You don't want to hard-code a tree structure assumption into an arbitrary tree.
We once had cs
available on all ArmiObject
subclasses. It ended up leading to massive performance issues and memory leaks. For example when you do a mpi broadcast of the reactor, the system deepcopies everything, and so we ended up with thousands of copies of the cs
in RAM and then sent over the network. It was horrifying and painful and ground our supercomputers to a halt. Everyone complained. We spent months understanding and re-optimizing the situation. We vowed never again to put those kinds of attributes on the reactor model. (notably weakrefs are another potentially interesting solution to this class of problem).
I'd also prefer to not make the breaking change at this time. We should shake down this new feature in production more before committing fully to it. We could make that change in the near future, as long as there's no design-specific things that can't be turned completely off by other users.
@ntouran I appreciate the thorough feedback! Getting context on not subclassing ArmiOject
is really interesting. After working with @john-science, I ended up finding a workaround for #657 that didn't require giving ArmiObject
children access to the attributes of CaseSetting
.
We can use the new inputHeightsConsideredHot
setting to more thoroughly test out the cold/hot temperature requirement and revisit the breaking change sometime in the future. Thanks, again!
The Issue
Accessing attributes of
CaseSettings
from within children ofArmiObject
orComposite
is not straightforward; specifically from within instances ofComponent
,Block
, andAssembly
. As of now, when aReactor
object is built from the blueprints, a subset ofCaseSettings
get stored in https://github.com/terrapower/armi/blob/22399244a88e67fc09996981081f7d5aab7032b4/armi/reactor/reactors.py#L224-L232A few ideas
inputHeightsConsideredHot
(being introducing in #657) , one could usec.parent.parent.parent._inputHeightsConsideredHot
(if the variableself._inputHeightsConsideredHot
was added to setOptionsFromCs).getAncestor
. As an example, this returns theCore
object from ablock
. https://github.com/terrapower/armi/blob/22399244a88e67fc09996981081f7d5aab7032b4/armi/reactor/blocks.py#L161-L166