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

Add method for setting input parameter unit for purposes of documentation #27352

Merged
merged 7 commits into from
Oct 7, 2024

Conversation

cticenhour
Copy link
Member

Reason

This change is intended to address corrective action CA 2021-1199 for BlackBear/Grizzly (and other MOOSE-based application to which a similar CA applies) and provide a new capability to framework and application developers who with to provide more context regarding intended units for a given parameter. This is not intended to provide automatic unit conversion for input parameters (but could likely be used as the API to tweak further in the future).

Design

Create setDocoUnit and getDocoUnit methods for setting a unit in the object source code and getting it for use in other code or, in this case, in the JSON output for use in MooseDocs. MooseDocs infrastructure to display this new parameter metadata should also be constructed in accordance with the other parameter metadata already presented.

Impact

New documentation for intended units in calculations will improve software quality. This is not a simulation enhancement but a user/developer quality-of-life one.

@cticenhour cticenhour self-assigned this Apr 11, 2024
@cticenhour cticenhour added T: task An enhancement to the software. C: Documentation labels Apr 11, 2024
@cticenhour
Copy link
Member Author

@bwspenc Here's a candidate implementation for you to try. This PR still needs finalization with respect to API and output metadata naming, as well as tests and some documentation, but I wanted to get it in your hands to try out.

An example of usage for ADMatDiffusion is given by:

InputParameters
ADMatDiffusion::validParams()
{
  auto params = ADMatDiffusionBase<Real>::validParams();
  params.addClassDescription(
      "Diffusion equation kernel that takes an isotropic diffusivity from a material property");
  params.setDocUnit("diffusivity", "m^2 / s");
  return params;
}

which then results in

Screenshot 2024-04-11 at 10 10 59 AM

I am considering changing the metadata label to "Assumed Units", but would welcome feedback.

@loganharbour
Copy link
Member

If we do this, I think that we also need to use the MooseUnit system somehow to also keep track of this unit so that it can properly be converted to other units if the primary units are declared in another way.

@cticenhour
Copy link
Member Author

I have gone back and forth on this, and @dschwen and I spoke about it previously. He can chime in with thoughts now that MooseUnit is in the framework. I am open to a re-write to integrate this into MooseUnit, but then that would open up the door to propagating units throughout the framework, which we've always stepped up to the line for but never quite committed to.

@cticenhour
Copy link
Member Author

Making sure that otherwise declared units are consistent (for error-checking if nothing else) would be a good thing here, I think, at minimum.

@loganharbour
Copy link
Member

Making sure that otherwise declared units are consistent (for error-checking if nothing else) would be a good thing here, I think, at minimum.

I agree. I just want to make sure that we design it s.t. it has the unit integration in mind for the future, hopefully not backing us out

@cticenhour cticenhour changed the title [WIP] Add method for setting input parameter unit for purposes of documentation Add method for setting input parameter unit for purposes of documentation Aug 30, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Aug 30, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Aug 30, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Aug 30, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Aug 30, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Aug 30, 2024
@moosebuild
Copy link
Contributor

Job Precheck on 053a050 wanted to post the following:

Your code requires style changes.

A patch was auto generated and copied here
You can directly apply the patch by running, in the top level of your repository:

curl -s https://mooseframework.inl.gov/docs/PRs/27352/clang_format/style.patch | git apply -v

Alternatively, with your repository up to date and in the top level of your repository:

git clang-format 97af19c98a76c47db2b4157c4e73c28f68f45595

cticenhour added a commit to cticenhour/moose that referenced this pull request Sep 18, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Sep 18, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Sep 18, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Sep 18, 2024
cticenhour added a commit to cticenhour/moose that referenced this pull request Sep 18, 2024
@moosebuild
Copy link
Contributor

Job Documentation on 6afa1c7 wanted to post the following:

View the site here

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

Job Coverage on 6afa1c7 wanted to post the following:

Framework coverage

636a45 #27352 6afa1c
Total Total +/- New
Rate 85.04% 85.04% -0.00% 77.78%
Hits 105635 105648 +13 14
Misses 18582 18587 +5 4

Diff coverage report

Full coverage report

Modules coverage

Coverage did not change

Full coverage reports

Reports

Warnings

  • framework new line coverage rate 77.78% is less than the suggested 90.0%

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

moosebuild commented Oct 1, 2024

Job Documentation, step Docs: sync website on 3d98b17 wanted to post the following:

View the site here

This comment will be updated on new commits.

@moosebuild
Copy link
Contributor

moosebuild commented Oct 2, 2024

Job Coverage, step Generate coverage on 3d98b17 wanted to post the following:

Framework coverage

999039 #27352 3d98b1
Total Total +/- New
Rate 85.05% 85.04% -0.00% 77.78%
Hits 106016 106029 +13 14
Misses 18641 18646 +5 4

Diff coverage report

Full coverage report

Modules coverage

Coverage did not change

Full coverage reports

Reports

Warnings

  • framework new line coverage rate 77.78% is less than the suggested 90.0%

This comment will be updated on new commits.

@cticenhour
Copy link
Member Author

Our internal discussions on this current design suggest there is a lot more to be done here in order to integrate this system into that of MooseUnit and use it for more than just documentation. We've decided that this is beyond the scope of work for this particular PR, given time constraints on SQA deliverables, and will proceed with reviewing and merging this version of the API and documentation integration. Future work will integrate MooseUnit features.

Tagging @bwspenc for a review.

@cticenhour cticenhour marked this pull request as ready for review October 2, 2024 14:58
Copy link
Contributor

@bwspenc bwspenc left a comment

Choose a reason for hiding this comment

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

Looks good to me. I made a couple of comments on really minor stuff that you can leave alone if you prefer.

framework/include/utils/InputParameters.h Show resolved Hide resolved
python/MooseDocs/extensions/appsyntax.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants