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

Fix minor conservation issue + new diagnostic summary for conservation #1338

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

albeanth
Copy link
Member

@albeanth albeanth commented Jul 5, 2023

What is the change?

Downstream testing illustrated some minor conservation issues with non-axial expansion target components (e.g., clad, wire, or duct within a fuel block) during thermal expansion. This PR addresses this and also introduces two things:

  1. minor cleanup of simplifying some repeated and unnecessary code.
  2. diagnostics that allows users and devs to identify mass conservation issues (these were used in place of the existing runLogs so their utility has been illustrated, at least in my opinion!).

Some additional details on item 2. There are two tables that get printed.

  • massConservationReport: prints the pre- and post-axial expansion assembly mass (as well as the difference) by material and by component if the difference if greater than 1e-9 grams. This 1e-9 g threshold was chosen semi-arbitrarily as the differences between pre- and post-axial expansion were found in downstream testing to range from 0.0 to on the order of 1e-10 g.
  • detailedMassConservationReport: prints the following component-level information for an assembly: grow fraction, bottom, top, height, and mass for pre- and post-axial expansion. The post-pre component mass is also printed. This summary table gets printed only for debug runs.

Closes #1048.

Why is the change being made?

The axial expansion changer should not lose mass post thermal expansion. This PR fixes that. There are some cases where this is inevitable and these should be documented in the ARMI docs (in a subsequent PR).


Checklist

  • This PR has only one purpose or idea.
  • Tests have been added/updated to verify that the new/changed code works.
  • The release notes (location doc/release/0.X.rst) are up-to-date with any important changes.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in setup.py.

@albeanth albeanth marked this pull request as ready for review July 6, 2023 15:12
@albeanth
Copy link
Member Author

albeanth commented Jul 6, 2023

The mass conservation tables look like the following:

massConservationReport

Is assembly-wide and shows the pre- and post-axial expansion mass values for the unique materials and components.

[xtra] <igniter fuel Assembly A0000 at LoadQueue>           pre-exp        post-exp    round(post - pre, 9)
       --------------------------------------------  --------------  --------------  ----------------------
       HT9                                           9.10087881e+04  9.10089401e+04          1.52037573e-01
       UZr                                           1.40720557e+05  1.40720557e+05          0.00000000e+00

       grid                                          6.97388334e+03  6.97388334e+03         -0.00000000e+00
       shield                                        2.12942247e+04  2.12942247e+04          0.00000000e+00
       clad                                          3.39860068e+04  3.39860068e+04          0.00000000e+00
       wire                                          1.84110362e+03  1.84110362e+03         -0.00000000e+00
       duct                                          2.69135695e+04  2.69137216e+04          1.52037573e-01
       fuel                                          1.40720557e+05  1.40720557e+05          0.00000000e+00

detailedMassConservationReport

Breaks downs the massConservationReport by component and can be useful to see how/if mass is being conserved in the assembly post-axial expansion.

Block                                              Component               GrowFrac    (prev) c.bottom    (prev) c.top    (prev) c.height    (post) c.bottom    (post) c.top    (post) c.height     (prev) mass     (post) mass    (post - pre) mass
-------------------------------------------------  ----------------  --------------  -----------------  --------------  -----------------  -----------------  --------------  -----------------  --------------  --------------  -------------------
<grid plate B0000-000 at ExCore XS: A BU GP: A>    <Hexagon: grid>   1.00493359e+00     0.00000000e+00  2.50000000e+01     2.50000000e+01     0.00000000e+00  2.51233397e+01     2.51233397e+01  6.97388334e+03  6.97388334e+03      -1.81898940e-12
<axial shield B0000-001 at ExCore XS: A BU GP: A>  <Circle: shield>  1.00700345e+00     2.51233397e+01  5.25000000e+01     2.75000000e+01     2.51233397e+01  5.28159346e+01     2.76925949e+01  2.12942247e+04  2.12942247e+04       0.00000000e+00
                                                   <Circle: clad>    1.00520603e+00     2.51233397e+01  5.28159346e+01     2.75000000e+01     2.51233397e+01  5.27665056e+01     2.76431659e+01  5.34065821e+03  5.35020789e+03       9.54967709e+00
                                                   <Helix: wire>     1.00520603e+00     2.51233397e+01  5.28159346e+01     2.75000000e+01     2.51233397e+01  5.27665056e+01     2.76431659e+01  2.89316283e+02  2.89833612e+02       5.17328946e-01
                                                   <Hexagon: duct>   1.00493359e+00     2.51233397e+01  5.28159346e+01     2.75000000e+01     2.51233397e+01  5.27590134e+01     2.76356737e+01  3.62350518e+03  3.63096851e+03       7.46333195e+00
<fuel B0000-002 at ExCore XS: B BU GP: A>          <Circle: fuel>    1.01341384e+00     5.28159346e+01  8.00000000e+01     2.75000000e+01     5.28159346e+01  8.06848152e+01     2.78688806e+01  4.69068524e+04  4.69068524e+04       3.63797881e-11
                                                   <Circle: clad>    1.00520603e+00     5.28159346e+01  8.06848152e+01     2.75000000e+01     5.27665056e+01  8.04096715e+01     2.76431659e+01  5.34065821e+03  5.38426628e+03       4.36080648e+01
                                                   <Helix: wire>     1.00520603e+00     5.28159346e+01  8.06848152e+01     2.75000000e+01     5.27665056e+01  8.04096715e+01     2.76431659e+01  2.89316283e+02  2.91678637e+02       2.36235361e+00
                                                   <Hexagon: duct>   1.00493359e+00     5.28159346e+01  8.06848152e+01     2.75000000e+01     5.27590134e+01  8.03946871e+01     2.76356737e+01  3.62350518e+03  3.65408255e+03       3.05773746e+01
<fuel B0000-003 at ExCore XS: C BU GP: A>          <Circle: fuel>    1.01341384e+00     8.06848152e+01  1.07500000e+02     2.75000000e+01     8.06848152e+01  1.08553696e+02     2.78688806e+01  4.69068524e+04  4.69068524e+04       3.63797881e-11
                                                   <Circle: clad>    1.00520603e+00     8.06848152e+01  1.08553696e+02     2.75000000e+01     8.04096715e+01  1.08052837e+02     2.76431659e+01  5.34065821e+03  5.38426628e+03       4.36080648e+01
                                                   <Helix: wire>     1.00520603e+00     8.06848152e+01  1.08553696e+02     2.75000000e+01     8.04096715e+01  1.08052837e+02     2.76431659e+01  2.89316283e+02  2.91678637e+02       2.36235361e+00
                                                   <Hexagon: duct>   1.00493359e+00     8.06848152e+01  1.08553696e+02     2.75000000e+01     8.03946871e+01  1.08030361e+02     2.76356737e+01  3.62350518e+03  3.65408255e+03       3.05773746e+01
<fuel B0000-004 at ExCore XS: C BU GP: A>          <Circle: fuel>    1.01341384e+00     1.08553696e+02  1.35000000e+02     2.75000000e+01     1.08553696e+02  1.36422576e+02     2.78688806e+01  4.69068524e+04  4.69068524e+04       3.63797881e-11
                                                   <Circle: clad>    1.00520603e+00     1.08553696e+02  1.36422576e+02     2.75000000e+01     1.08052837e+02  1.35696003e+02     2.76431659e+01  5.34065821e+03  5.38426628e+03       4.36080648e+01
                                                   <Helix: wire>     1.00520603e+00     1.08553696e+02  1.36422576e+02     2.75000000e+01     1.08052837e+02  1.35696003e+02     2.76431659e+01  2.89316283e+02  2.91678637e+02       2.36235361e+00
                                                   <Hexagon: duct>   1.00493359e+00     1.08553696e+02  1.36422576e+02     2.75000000e+01     1.08030361e+02  1.35666035e+02     2.76356737e+01  3.62350518e+03  3.65408255e+03       3.05773746e+01
<plenum B0000-005 at ExCore XS: D BU GP: A>        <Circle: clad>    1.00520603e+00     1.36422576e+02  1.50000000e+02     1.50000000e+01     1.35696003e+02  1.50774094e+02     1.50780905e+01  2.91308630e+03  2.77271243e+03      -1.40373871e+02
                                                   <Helix: wire>     1.00520603e+00     1.36422576e+02  1.50774094e+02     1.50000000e+01     1.35696003e+02  1.50774094e+02     1.50780905e+01  1.57808882e+02  1.50204492e+02      -7.60438979e+00
                                                   <Hexagon: duct>   1.00493359e+00     1.36422576e+02  1.50774094e+02     1.50000000e+01     1.35666035e+02  1.50740038e+02     1.50740038e+01  1.97645737e+03  1.88172716e+03      -9.47302080e+01
<aclp plenum B0000-006 at ExCore XS: A BU GP: A>   <Circle: clad>    1.00520603e+00     1.50774094e+02  1.75000000e+02     2.50000000e+01     1.50774094e+02  1.75904245e+02     2.51301508e+01  4.85514383e+03  4.85514383e+03       2.72848411e-12
                                                   <Helix: wire>     1.00520603e+00     1.50774094e+02  1.75904245e+02     2.50000000e+01     1.50774094e+02  1.75904245e+02     2.51301508e+01  2.63014803e+02  2.63014803e+02       5.68434189e-14
                                                   <Hexagon: duct>   1.00493359e+00     1.50774094e+02  1.75904245e+02     2.50000000e+01     1.50740038e+02  1.75863378e+02     2.51233397e+01  3.85490024e+03  3.85594532e+03       1.04508710e+00
<plenum B0000-007 at ExCore XS: A BU GP: A>        <Circle: clad>    1.00520603e+00     1.75904245e+02  2.00000000e+02     2.50000000e+01     1.75904245e+02  2.01034395e+02     2.51301508e+01  4.85514383e+03  4.85514383e+03       2.72848411e-12
                                                   <Helix: wire>     1.00520603e+00     1.75904245e+02  2.01034395e+02     2.50000000e+01     1.75904245e+02  2.01034395e+02     2.51301508e+01  2.63014803e+02  2.63014803e+02       5.68434189e-14
                                                   <Hexagon: duct>   1.00493359e+00     1.75904245e+02  2.01034395e+02     2.50000000e+01     1.75863378e+02  2.00986718e+02     2.51233397e+01  3.29409561e+03  3.29498866e+03       8.93049530e-01
<duct B0000-008 at ExCore XS: A BU GP: A>          <Hexagon: duct>   1.00493359e+00     2.01034395e+02  2.25000000e+02     2.50000000e+01     2.00986718e+02  2.26110058e+02     2.51233397e+01  3.29409561e+03  3.28784427e+03      -6.25134671e+00
<SodiumBlock B0000-009 at ExCore XS: A BU GP: A>

Copy link
Member

@keckler keckler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments throughout the code, and have one more here:

In the PR description you say

Downstream testing illustrated some minor conservation issues with non-axial expansion target components (e.g., clad, wire, or duct within a fuel block) during thermal expansion. This PR addresses this

It is unclear to me exactly what has changed to fix the problem that you were seeing (partly because I don't know the exact problem you were seeing).

Is the fix related to the change of c.height = growFrac * blockHeight to c.height = growFrac * prevCompHeight?

Comment on lines 129 to 130
self.massConservationReport = None
self.detailedMassConservationReport = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't appear that there is any need to store these items on self, since they're only really used in one method of this class.

I think that trashing these dicts after each call to axiallyExpandAssembly() would be both safe and more memory efficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put them on self in 29c345e simply to accommodate testing. I could use the mock logs to rebuild them if you'd prefer... But that seemed clunky to me and the easier solution was just to make them class variables.

Copy link
Member Author

@albeanth albeanth Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, if we kept them as class instances, we could empty them after they are populated and used. Maybe a compromise of sorts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so this should be resolved with 027db32. All of the logging now lives in its own class and only gets populated if the runLog verbosity is either extra or debug. The dicts that get populated will go out of scope with the rest of the expansion changer and should follow suit with the expansion data, etc.

armi/reactor/converters/axialExpansionChanger.py Outdated Show resolved Hide resolved
armi/reactor/converters/axialExpansionChanger.py Outdated Show resolved Hide resolved
armi/reactor/converters/axialExpansionChanger.py Outdated Show resolved Hide resolved
@albeanth
Copy link
Member Author

albeanth commented Jul 7, 2023

Is the fix related to the change of c.height = growFrac * blockHeight to c.height = growFrac * prevCompHeight?

@keckler, yes, exactly.

@albeanth
Copy link
Member Author

albeanth commented Jul 7, 2023

The mass conservation tables look like the following:

massConservationReport

Is assembly-wide and shows the pre- and post-axial expansion mass values for the unique materials and components.
...

Just a note, I did confirm that the summary tables are identical post 027db32.

Copy link
Member

@keckler keckler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that change, I think it streamlines this a lot!

armi/reactor/converters/axialExpansionChanger.py Outdated Show resolved Hide resolved
@john-science john-science added the enhancement New feature or request label Jul 10, 2023
self.massConservationReport["(prev) mass"],
)
]
self.massConservationReport["round(post - prev, 9)"] = diff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this "self.massConservationReport"? Isn't this just a local variable? Is it used outside this method?

It appears to be a new variable that is local, but is initialized in the constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it on self to accommodate some unit testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer returning it if its not actually needing to be an attribute.

we would have WAY more attributes if we did this every time we wanted to test.

@albeanth albeanth marked this pull request as draft July 13, 2023 21:50
@albeanth
Copy link
Member Author

Is the fix related to the change of c.height = growFrac * blockHeight to c.height = growFrac * prevCompHeight?

@keckler, yes, exactly.

This is breaking downstream testing... Converting to draft while I debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Axial Expansion Changer + verbosity: debug
5 participants