Skip to content

Conversation

@loganharbour
Copy link
Member

@loganharbour loganharbour commented Jun 26, 2024

Things still to do

  • Actually verify the test, or setup actual verification?
  • Also add a test with the openmc-only operator?
  • Clean up the python imports in depletion.py
  • Add more comments, maybe a little documentation
  • Setup a proper clean exit of the CardinalOperator that checks to see if MOOSE is also done, otherwise error
  • Clean up the state cleanup before running (hdf5 and tallies)

@loganharbour
Copy link
Member Author

FYI @aprilnovak and @pshriwise; still a mess but it works!

@moosebuild
Copy link
Collaborator

moosebuild commented Jun 26, 2024

Job Documentation on 5e3baba wanted to post the following:

View the site here

This comment will be updated on new commits.

Copy link
Collaborator

@pshriwise pshriwise left a comment

Choose a reason for hiding this comment

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

This looks really good!! Thank you for creating this @loganharbour. Mostly line changes here and a couple questions about integrating it into a Cardinal install.

Comment on lines 25 to 26
super().__init__(*args, **kwargs)

self._control = None
self.cardinal_cmd = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's move these attribute initializations before the super().__init__ call so we don't get an AttributeError from CardinalOperator.__del__ if the parent constructor fails.

Suggested change
super().__init__(*args, **kwargs)
self._control = None
self.cardinal_cmd = None
self._control = None
self.cardinal_cmd = None
super().__init__(*args, **kwargs)

nuclides = [n for n in t.nuclides]
names_path = f'{uo_path}/names'
self._control.setControllableVectorString(names_path, nuclides)
break
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can remove this now, right?

Suggested change
break

Comment on lines +213 to +244
if self._control is None:
self.start_cardinal()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggesting the tiniest of refactors: This pattern appears often. Do we want to put it into a method like ensure_cardinal?


# All of these imports are awful and we'll figure
# out a better way to do it before merging
try:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems fair to me to expect users to have installed the OpenMC Python package used with Cardinal, but it doesn't look like your typical installation as that's going to occur from the submodule. Offhand thoughts:

  • (optionally) Install the OpenMC Python API as part of the Cardinal build
  • Include setting of PYTHONPATH to the OpenMC submodule in Cardinal's installation docs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be awesome if we automatically installed the Python API when installing Cardinal -- it's listed in this issue: #592

try:
from cardinal_operator import CardinalOperator
except:
cardinal_contrib = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'python'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

see above, this could also be solved by requiring the PYTHONPATH to be set to CARDINAL_HOME/python in the installation notes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A warning similar to the one about NEKRS_HOME could be provided perhaps.

@moosebuild
Copy link
Collaborator

moosebuild commented Oct 29, 2024

Job Documentation, step Sync to remote on 791f7ac wanted to post the following:

View the site here

This comment will be updated on new commits.

@aprilnovak
Copy link
Collaborator

@loganharbour would you please rebase this off devel and then update this? Now that #923 was merged, is it time to return to this PR?

@pshriwise
Copy link
Collaborator

Looks like we'll need the endf package in the testing environment for OpenMC. @loganharbour is that easy to add?

@loganharbour
Copy link
Member Author

Looks like we'll need the endf package in the testing environment for OpenMC. @loganharbour is that easy to add?

A bit. I've needed to find a way to allow custom installs for apps. I'll get to that tomorrow

@aprilnovak
Copy link
Collaborator

I'm trying to run this locally so I can learn how to use this feature. Do I need to pip install the new python code?

ajnovak2@ajnovak2-serv-01:~/cardinal/test/tests/depletion$ python depletion.py
Traceback (most recent call last):
  File "/home/ajnovak2/cardinal/test/tests/depletion/depletion.py", line 3, in <module>
    from MooseControl import MooseControl
ModuleNotFoundError: No module named 'MooseControl'

Is it as simple as?

cd cardinal/python
pip install .

@loganharbour
Copy link
Member Author

I'm trying to run this locally so I can learn how to use this feature. Do I need to pip install the new python code?

ajnovak2@ajnovak2-serv-01:~/cardinal/test/tests/depletion$ python depletion.py
Traceback (most recent call last):
  File "/home/ajnovak2/cardinal/test/tests/depletion/depletion.py", line 3, in <module>
    from MooseControl import MooseControl
ModuleNotFoundError: No module named 'MooseControl'

Is it as simple as?

cd cardinal/python
pip install .
export PYTHONPATH=/path/to/cardinal/contrib/moose:$PYTHONPATH

@aprilnovak
Copy link
Collaborator

aprilnovak commented Jun 10, 2025

Actually I think I got a bit farther now. I tried setting export RUNAPP_COMMAND="cardinal-opt -i openmc.i". The simulation starts running but then ends with

MooseControl.app: *** ERROR ***
MooseControl.app: CLI_ARGS:1: (UserObjects/openmc_filter1/filter_id):
MooseControl.app:     Filter 1 does not exist and create_filter is false

I think this is probably due to some source code changes in Cardinal which have happened over the last couple of months from the new Tallies syntax. It seems that the filters have not yet been created by the time the OpenMCDomainFilterEditor is trying to use them.

@aprilnovak
Copy link
Collaborator

This test case seems to have originally been working after the [Tallies] syntax was added. @nuclearkevin can you identify anything which might have changed since June of last year when this PR was opened? Perhaps we need to add some task dependencies so that the Filters get executed before these editor UOs?

@pshriwise
Copy link
Collaborator

Actually I think I got a bit farther now. I tried setting export RUNAPP_COMMAND="cardinal-opt -i openmc.i". The simulation starts running but then ends with

MooseControl.app: *** ERROR ***
MooseControl.app: CLI_ARGS:1: (UserObjects/openmc_filter1/filter_id):
MooseControl.app:     Filter 1 does not exist and create_filter is false

I think this is probably due to some source code changes in Cardinal which have happened over the last couple of months from the new Tallies syntax. It seems that the filters have not yet been created by the time the OpenMCDomainFilterEditor is trying to use them.

This is strange to me b/c the create_filter parameter is set to true for all filter editors created by the CardinalOperator class. Is this reflected in the contents of the server.i file that's produced by that object?

@nuclearkevin
Copy link
Contributor

This is strange to me b/c the create_filter parameter is set to true for all filter editors created by the CardinalOperator class. Is this reflected in the contents of the server.i file that's produced by that object?

It appears as if server.i sets create_filter = true. This is what I get when I run the depletion example:

cardinal-opt
-i
openmc.i
Controls/web_server/type=WebServerControl
Controls/web_server/execute_on="TIMESTEP_BEGIN TIMESTEP_END"
UserObjects/openmc_mat1/type=OpenMCNuclideDensities
UserObjects/openmc_mat1/material_id=1
UserObjects/openmc_mat1/names="U234 U235 U238 O16 O17 U236"
UserObjects/openmc_mat1/densities="4.989113525358761e-06 0.000558182473562055 0.02240526017807056 0.04592456500869191 1.7412009289815074e-05 2.55674383288874e-06"
UserObjects/openmc_mat2/type=OpenMCNuclideDensities
UserObjects/openmc_mat2/material_id=2
UserObjects/openmc_mat2/names="He3 He4"
UserObjects/openmc_mat2/densities="4.808563327759458e-10 0.00024042768553164014"
UserObjects/openmc_mat3/type=OpenMCNuclideDensities
UserObjects/openmc_mat3/material_id=3
UserObjects/openmc_mat3/names="Cr50 Cr52 Cr53 Cr54 Fe54 Fe56 Fe57 Fe58 Sn112 Sn114 Sn115 Sn116 Sn117 Sn118 Sn119 Sn120 Sn122 Sn124 Zr90 Zr91 Zr92 Zr94 Zr96"
UserObjects/openmc_mat3/densities="3.296179086851863e-06 6.356393983859786e-05 7.207577897639481e-06 1.7941072349310136e-06 6.812040282197712e-06 0.00010693480683272309 2.469584661632909e-06 3.286524014540826e-07 4.512345343746015e-06 3.070250173679606e-06 1.5816575713225518e-06 6.763901433813293e-05 3.572667675644065e-05 0.00011266935877799354 3.995997624250037e-05 0.00015155988781410216 2.153844568759417e-05 2.693460658525746e-05 0.021876516442070146 0.004770741147746929 0.0072921764132952375 0.007389971148193187 0.001190558805034355"
UserObjects/openmc_mat4/type=OpenMCNuclideDensities
UserObjects/openmc_mat4/material_id=4
UserObjects/openmc_mat4/names="B10 B11 H1 H2 O16 O17"
UserObjects/openmc_mat4/densities="8.133537263121287e-06 3.2903482227904384e-05 0.051288285482012676 7.988881769415422e-06 0.024612879876383137 9.331818232259238e-06"
UserObjects/openmc_tally1/type=OpenMCTallyEditor
UserObjects/openmc_tally1/create_tally = true
UserObjects/openmc_tally1/tally_id=1
UserObjects/openmc_tally1/scores=""
UserObjects/openmc_tally1/nuclides=""
UserObjects/openmc_tally1/filter_ids=""
UserObjects/openmc_tally1/multiply_density=false
UserObjects/openmc_filter1/type=OpenMCDomainFilterEditor
UserObjects/openmc_filter1/create_filter = true
UserObjects/openmc_filter1/filter_id="1"
UserObjects/openmc_filter1/filter_type="material"
UserObjects/openmc_filter1/bins="1"

@nuclearkevin
Copy link
Contributor

Ah, I know what's going on. create_filter = true should be create_filter=true and create_tally = true should be create_tally=true. Spaces in CLI arguments...

@pshriwise
Copy link
Collaborator

Ah, I know what's going on. create_filter = true should be create_filter=true and create_tally = true should be create_tally=true. Spaces in CLI arguments...

Ah good catch!

Co-authored-by: Kevin Sawatzky <66632997+nuclearkevin@users.noreply.github.com>
Co-authored-by: Patrick Shriwise <pshriwise@gmail.com>
@pshriwise
Copy link
Collaborator

A couple of Python modules missing in the test env it seems (openmc and endf). Is it possible to add these to the CIVET environment @loganharbour?

@loganharbour
Copy link
Member Author

A couple of Python modules missing in the test env it seems (openmc and endf). Is it possible to add these to the CIVET environment @loganharbour?

Yep. Is that it?

@pshriwise
Copy link
Collaborator

Yep. Is that it?

I think so. Thoughts on using PYTHONPATH for openmc so we capture any updates in future PRs?

The endf package is pretty stable and can be installed from PyPI.

@aprilnovak
Copy link
Collaborator

Trying to run this still - getting farther, but hitting this:

MooseControl.app: *** ERROR ***
MooseControl.app: Unable to open file "/home/ajnovak2/cardinal/test/tests/depletion/Controls/web_server/type=WebServerControl". Check to make sure that it exists and that you have read permission.
MooseControl.app:
MooseControl.app: Stack frames: 10
MooseControl.app: 0: libMesh::print_trace(std::ostream&)
MooseControl.app: 1: moose::internal::mooseErrorRaw(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
MooseControl.app: 2: void mooseError<char const*>(char const*&&)
MooseControl.app: 3: MooseUtils::checkFileReadable(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool, bool)
MooseControl.app: 4: Parser::parse()
MooseControl.app: 5: Moose::createMooseApp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, char**)
MooseControl.app: 6: cardinal-opt(+0x5611) [0x56478d22b611]
MooseControl.app: 7: /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fed6f251d90]
MooseControl.app: 8: __libc_start_main
MooseControl.app: 9: cardinal-opt(+0x58c5) [0x56478d22b8c5]

@loganharbour are there some files missing from this PR, or something needs to be updated still?

@loganharbour
Copy link
Member Author

It looks like arguments aren't being passed right to MooseControl; it looks like it's missing the path to the input file?

@aprilnovak
Copy link
Collaborator

Can you help with debugging? I'm not sure on how these files are meant to look since I think this is the only example case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants