Skip to content

Commit

Permalink
Merge 4823005 into 571e4f5
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Feb 7, 2024
2 parents 571e4f5 + 4823005 commit 1685f2e
Show file tree
Hide file tree
Showing 52 changed files with 1,082 additions and 1,035 deletions.
10 changes: 6 additions & 4 deletions armi/bookkeeping/report/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ def encode64(file_path):
from armi import runLog

runLog.warning(
"'.pdf' images cannot be embedded into this HTML report. {} will not be inserted.".format(
file_path
(
f"'.pdf' images cannot be embedded into this HTML report. {file_path} will not be"
" inserted."
)
)
return "Faulty PDF image inclusion: {} attempted to be inserted but no support is currently offered for such.".format(
file_path
return (
f"Faulty PDF image inclusion: {file_path} attempted to be inserted but no support is "
"currently offered for such."
)
with open(file_path, "rb") as img_src:
return r"data:image/{};base64,{}".format(
Expand Down
13 changes: 7 additions & 6 deletions armi/bookkeeping/report/newReports.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,13 @@ def render(self, level, idPrefix):
Parameters
----------
level : int
level of the nesting for this section, determines the size of the heading title for the Section
(The higher the level, the smaller the title font-size). Ranges from H1 - H4 in html terms.
level of the nesting for this section, determines the size of the heading title for the
Section (The higher the level, the smaller the title font-size). Ranges from H1 - H4 in
html terms.
idPrefix : String
used for href/id referencing for the left hand side table of contents to be paired with the item
that render() is called upon.
Used for href/id referencing for the left hand side table of contents to be paired with
the item that render() is called upon.
Returns
-------
Expand Down Expand Up @@ -440,10 +441,10 @@ class TimeSeries(ReportNode):
Example
-------
>>> series = TimeSeries("Plot of K-effective", "plot", ["k-effective"], "k-eff", "keff.png") # Adding to a plot with k-effective
>>> series = TimeSeries("Plot of K-effective", "plot", ["k-effective"], "k-eff", "keff.png")
>>> time = r.p.time # The current time node of the reactor.
>>> data = r.core.p.keff # The parameter k-effective value at that time.
>>> uncertainty = r.core.p.keffUnc # Since the parameter yields keff-uncontrolled value at the current time.
>>> uncertainty = r.core.p.keffUnc # The keff-uncontrolled at the current time.
>>> series.add("k-effective", time, data, uncertainty) # Adds this point to be plotted later.
>>> # Adding to a plot with multiple lines for fuel Burn-Up Plot.
Expand Down
131 changes: 67 additions & 64 deletions armi/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

r"""
"""
Interfaces are objects of code that interact with ARMI. They read information off the state,
perform calculations (or run external codes), and then store the results back in the state.
Expand Down Expand Up @@ -42,23 +42,23 @@ class STACK_ORDER: # noqa: invalid-class-name
"""
Constants that help determine the order of modules in the interface stack.
Each module defines an ``ORDER`` constant that specifies where in this order it
should be placed in the Interface Stack.
Each module defines an ``ORDER`` constant that specifies where in this order it should be placed
in the Interface Stack.
.. impl:: Define an ordered list of interfaces.
:id: I_ARMI_OPERATOR_INTERFACES0
:implements: R_ARMI_OPERATOR_INTERFACES
At each time node during a simulation, an ordered colletion of Interfaces
are run (referred to as the interface stack). But ARMI does not force the order upon the analyst.
Instead, each Interface registers where in that ordered list it belongs by
giving itself an order number (which can be an integer or a decimal).
This class defines a set of constants which can be imported and used
by Interface developers to define that Interface's position in the stack.
At each time node during a simulation, an ordered colletion of Interfaces are run (referred
to as the interface stack). But ARMI does not force the order upon the analyst. Instead,
each Interface registers where in that ordered list it belongs by giving itself an order
number (which can be an integer or a decimal). This class defines a set of constants which
can be imported and used by Interface developers to define that Interface's position in the
stack.
The constants defined are given names, based on common stack orderings
in the ARMI ecosystem. But in the end, these are just constant values,
and the names they are given are merely suggestions.
The constants defined are given names, based on common stack orderings in the ARMI
ecosystem. But in the end, these are just constant values, and the names they are given are
merely suggestions.
See Also
--------
Expand Down Expand Up @@ -158,12 +158,14 @@ def storePreviousIterationValue(self, val: _SUPPORTED_TYPES):

def isConverged(self, val: _SUPPORTED_TYPES) -> bool:
"""
Return boolean indicating if the convergence criteria between the current and previous iteration values are met.
Return boolean indicating if the convergence criteria between the current and previous
iteration values are met.
Parameters
----------
val : _SUPPORTED_TYPES
the most recent value for computing convergence critera. Is commonly equal to interface.getTightCouplingValue()
The most recent value for computing convergence critera. Is commonly equal to
interface.getTightCouplingValue()
Returns
-------
Expand All @@ -172,18 +174,19 @@ def isConverged(self, val: _SUPPORTED_TYPES) -> bool:
Notes
-----
- On convergence, this class is automatically reset to its initial condition to avoid retaining
or holding a stale state. Calling this method will increment a counter that when exceeded will
clear the state. A warning will be reported if the state is cleared prior to the convergence
criteria being met.
- For computing convergence of arrays, only up to 2D is allowed. 3D arrays would arise from considering
component level parameters. However, converging on component level parameters is not supported at this time.
- On convergence, this class is automatically reset to its initial condition to avoid
retaining or holding a stale state. Calling this method will increment a counter that when
exceeded will clear the state. A warning will be reported if the state is cleared prior to
the convergence criteria being met.
- For computing convergence of arrays, only up to 2D is allowed. 3D arrays would arise from
considering component level parameters. However, converging on component level parameters
is not supported at this time.
Raises
------
ValueError
If the previous iteration value has not been assigned. The ``storePreviousIterationValue`` method
must be called first.
If the previous iteration value has not been assigned. The
``storePreviousIterationValue`` method must be called first.
RuntimeError
Only support calculating norms for up to 2D arrays.
"""
Expand Down Expand Up @@ -212,8 +215,8 @@ def isConverged(self, val: _SUPPORTED_TYPES) -> bool:
"Currently only support up to 2D arrays for calculating convergence of arrays."
)

# Check if convergence is satisfied. If so, or if reached max number of iters, then
# reset the number of iterations
# Check if convergence is satisfied. If so, or if reached max number of iters, then reset
# the number of iterations
converged = self.eps < self.tolerance
if converged:
self._numIters = 0
Expand Down Expand Up @@ -285,16 +288,15 @@ def getInputFiles(cls, cs):

name: Union[str, None] = None
"""
The name of the interface. This is undefined for the base class, and must be
overridden by any concrete class that extends this one.
The name of the interface. This is undefined for the base class, and must be overridden by any
concrete class that extends this one.
"""

# TODO: This is a terrible name.
function = None
"""
The function performed by an Interface. This is not required be be defined
by implementations of Interface, but is used to form categories of
interfaces.
The function performed by an Interface. This is not required be be defined by implementations of
Interface, but is used to form categories of interfaces.
"""

class Distribute:
Expand All @@ -308,8 +310,8 @@ def __init__(self, r, cs):
"""
Construct an interface.
The ``r`` and ``cs`` arguments are required, but may be ``None``, where
appropriate for the specific ``Interface`` implementation.
The ``r`` and ``cs`` arguments are required, but may be ``None``, where appropriate for the
specific ``Interface`` implementation.
Parameters
----------
Expand Down Expand Up @@ -352,8 +354,8 @@ def distributable(self):
Notes
-----
Cases where this isn't possible include the database interface,
where the SQL driver cannot be distributed.
Cases where this isn't possible include the database interface, where the SQL driver cannot
be distributed.
"""
return self.Distribute.DUPLICATE

Expand Down Expand Up @@ -391,17 +393,20 @@ def attachReactor(self, o, r):
self.o = o

def detachReactor(self):
"""Delete the callbacks to reactor or operator. Useful when pickling, MPI sending, etc. to save memory."""
"""Delete the callbacks to reactor or operator. Useful when pickling, MPI sending, etc. to
save memory.
"""
self.o = None
self.r = None
self.cs = None

def duplicate(self):
"""
Duplicate this interface without duplicating some of the large attributes (like the entire reactor).
Duplicate this interface without duplicating some of the large attributes (like the entire
reactor).
Makes a copy of interface with detached reactor/operator/settings so that it can be attached to an operator
at a later point in time.
Makes a copy of interface with detached reactor/operator/settings so that it can be attached
to an operator at a later point in time.
Returns
-------
Expand Down Expand Up @@ -461,9 +466,9 @@ def _initializeParams(self):
Notes
-----
Parameters with defaults are not written to the database until they have been assigned SINCE_ANYTHING.
This is done to reduce database size, so that we don't write parameters to the DB that are related to
interfaces that are not not active.
Parameters with defaults are not written to the database until they have been assigned
SINCE_ANYTHING. This is done to reduce database size, so that we don't write parameters to
the DB that are related to interfaces that are not not active.
"""
for paramDef in parameters.ALL_DEFINITIONS.inCategory(self.name):
if paramDef.default not in (None, parameters.NoDefault):
Expand Down Expand Up @@ -507,11 +512,11 @@ def isRequestedDetailPoint(self, cycle=None, node=None):
Notes
-----
By default, detail points are either during the requested snapshots,
if any exist, or all cycles and nodes if none exist.
By default, detail points are either during the requested snapshots, if any exist, or all
cycles and nodes if none exist.
This is useful for peripheral interfaces (CR Worth, perturbation theory, transients)
that may or may not be requested during a standard run.
This is useful for peripheral interfaces (CR Worth, perturbation theory, transients) that
may or may not be requested during a standard run.
If both cycle and node are None, this returns True
Expand Down Expand Up @@ -557,12 +562,11 @@ def workerOperate(self, _cmd):
return False

def enabled(self, flag=None):
r"""
"""
Mechanism to allow interfaces to be attached but not running at the interaction points.
Must be implemented on the individual interface level hooks.
If given no arguments, returns status of enabled
If arguments, sets enabled to that flag. (True or False)
Must be implemented on the individual interface level hooks. If given no arguments, returns
status of enabled. If arguments, sets enabled to that flag. (True or False)
Notes
-----
Expand All @@ -576,7 +580,7 @@ def enabled(self, flag=None):
raise ValueError("Non-bool passed to assign {}.enable().".format(self))

def bolForce(self, flag=None):
r"""
"""
Run interactBOL even if this interface is disabled.
Parameters
Expand Down Expand Up @@ -610,26 +614,25 @@ def specifyInputs(cs) -> Dict[Union[str, settings.Setting], List[str]]:
"""
Return a collection of file names that are considered input files.
This is a static method (i.e. is not called on a particular instance of the
class), since it should not require an Interface to actually be constructed.
This would require constructing a reactor object, which is expensive.
This is a static method (i.e. is not called on a particular instance of the class), since it
should not require an Interface to actually be constructed. This would require constructing
a reactor object, which is expensive.
The files returned by an implementation should be those that one would want
copied to a target location when cloning a Case or CaseSuite. These can be
absolute paths, relative paths, or glob patterns that will be interpolated
relative to the input directory. Absolute paths will not be copied anywhere.
The files returned by an implementation should be those that one would want copied to a
target location when cloning a Case or CaseSuite. These can be absolute paths, relative
paths, or glob patterns that will be interpolated relative to the input directory. Absolute
paths will not be copied anywhere.
The returned dictionary will enable the source Settings object to
be updated to the new file location. While the dictionary keys are
recommended to be Setting objects, the name of the setting as a string,
e.g., "shuffleLogic", is still interpreted. If the string name does not
The returned dictionary will enable the source Settings object to be updated to the new file
location. While the dictionary keys are recommended to be Setting objects, the name of the
setting as a string, e.g., "shuffleLogic", is still interpreted. If the string name does not
point to a valid setting then this will lead to a failure.
Note
----
This existed before the advent of ARMI plugins. Perhaps it can be better served
as a plugin hook. Potential future work.
This existed before the advent of ARMI plugins. Perhaps it can be better served as a plugin
hook. Potential future work.
See Also
--------
Expand Down Expand Up @@ -679,8 +682,8 @@ class OutputReader:
Notes
-----
Should ideally not require r, eci, and fname arguments
and would rather just have an apply(reactor) method.
Should ideally not require r, eci, and fname arguments and would rather just have an
apply(reactor) method.
"""

def __init__(self, r=None, externalCodeInterface=None, fName=None, cs=None):
Expand Down
13 changes: 7 additions & 6 deletions armi/materials/inconel600.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class Inconel600(Material):
def __init__(self):
Material.__init__(self)
self.refDens = 8.47 # g/cc
# Only density measurement presented in the reference.
# Presumed to be performed at 21C since this was the reference temperature for linear expansion measurements.
# Only density measurement presented in the reference. Presumed to be performed at 21C since
# this was the reference temperature for linear expansion measurements.

def setDefaultMassFracs(self):
massFracs = {
Expand Down Expand Up @@ -202,11 +202,12 @@ def linearExpansion(self, Tk=None, Tc=None):
r"""
From http://www.specialmetals.com/documents/Inconel%20alloy%20600.pdf.
Using the correlation for linearExpansionPercent, the 2nd order polynomial is divided by 100 to convert
from percent strain to strain, then differentiated with respect to temperature to find the correlation
for instantaneous linear expansion.
Using the correlation for linearExpansionPercent, the 2nd order polynomial is divided by 100
to convert from percent strain to strain, then differentiated with respect to temperature to
find the correlation for instantaneous linear expansion.
i.e. for a linearExpansionPercent correlation of a*Tc**2 + b*Tc + c, the linearExpansion correlation is 2*a/100*Tc + b/100
i.e. for a linearExpansionPercent correlation of a*Tc**2 + b*Tc + c, the linearExpansion
correlation is 2*a/100*Tc + b/100
2*(3.722e-7/100.0)*Tc + 1.303e-3/100.0
Expand Down
9 changes: 5 additions & 4 deletions armi/materials/inconel625.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ def linearExpansion(self, Tk=None, Tc=None):
r"""
From http://www.specialmetals.com/assets/documents/alloys/inconel/inconel-alloy-625.pdf.
Using the correlation for linearExpansionPercent, the 2nd order polynomial is divided by 100 to convert
from percent strain to strain, then differentiated with respect to temperature to find the correlation
for instantaneous linear expansion.
Using the correlation for linearExpansionPercent, the 2nd order polynomial is divided by 100
to convert from percent strain to strain, then differentiated with respect to temperature to
find the correlation for instantaneous linear expansion.
i.e. for a linearExpansionPercent correlation of a*Tc**2 + b*Tc + c, the linearExpansion correlation is 2*a/100*Tc + b/100
i.e. for a linearExpansionPercent correlation of a*Tc**2 + b*Tc + c, the linearExpansion
correlation is 2*a/100*Tc + b/100
2*(5.083e-7/100.0)*Tc + 1.125e-3/100.0
Expand Down

0 comments on commit 1685f2e

Please sign in to comment.