Add properties to settings w/ documentation, c++ loading of filename, and python round-trip test#3808
Add properties to settings w/ documentation, c++ loading of filename, and python round-trip test#3808gonuke wants to merge 32 commits intoopenmc-dev:developfrom
Conversation
lewisgross1296
left a comment
There was a problem hiding this comment.
I like the settings approach, probably best to have it in one place, as opposed to every cell that has properties.
Might be a future issue/PR, but we should discuss how to handle if there are cells with instances in the properties file that are not distribcell in our current model. (e.g. programmatically added tallies from Cardinal)
with documentation and loading from c++ and python round trip test
5aeb316 to
5852ec0
Compare
|
Hmmm... seems like my version of clang-format is too new and it is aligning comments differently that v15 (although the style guide does call for aligning comments) |
|
Recently, I've been installing |
|
Looked around / thinking about testing. It seems like this is the only OpenMC test that uses Our tests could also take advantage of I can imagine the following tests being useful (and maybe more?)
|
That's what I get for trying to do this on my Mac :) |
|
It looks like I need to figure out how to place a dummy |
This context managet may be of help Lines 8 to 25 in 83a30f6 |
Perhaps, but it's already using a temp directory fixture. I could use both but not sure how they interact. I could also just use The fixture is a little mysterious because it refers to a |
|
Oh, I misunderstood. I thought you were trying to reference an already-present properties file. I don't quite understand why we need the file to exist though, it looks like that's only checked on the C++ side. I think comparison of the |
Yeah - that's probably the problem. I was getting wrapped around on the type of the filename and not sure what will resolve to true. |
src/summary.cpp
Outdated
| // Read material properties | ||
| for (const auto& mat : model::materials) { | ||
| mat->import_properties_hdf5(materials_group); | ||
| mat->import_properties_hdf5( |
There was a problem hiding this comment.
Commenting on what I think may be a pre-existing issue here and looking for guidance:
Above, we call Cell::set_density which populates the density multiplier vector based on the density of the material filling that cell. Here, we read the density of the material from the file, which may change the baseline density of the material from what it was at the time we called Cell::set_density and possibly invalidate the density multipliers of the cells? In a separate effort, should we perhaps change the order of these imports?
Looping @nuclearkevin in for a take as well.
There was a problem hiding this comment.
A simple change to mitigate (but not entirely prevent) this is to have two read_density flags: read_cell_densities and read_material_densities, and document that one will override the other.
There was a problem hiding this comment.
My preference would be to either read all domain densities or none and fix the ordering (again, in a separate PR if need be). My understanding is that some cells may have density multipliers and others may not, so the additional option could leave us in a confusing state where some densities are original and some from the properties file.
There was a problem hiding this comment.
I misunderstood your early comment. I thought you were worried about one of them overwriting the other, but I see that the concern is more subtle.
|
I can't quite figure out why this test is failing? It seems like one of the python version tests was cancelled and that caused CI to be determined as failed. Can someone relaunch tests? |
aaee4fc to
a0ace4e
Compare
a0ace4e to
cde42e1
Compare
| def _create_properties_file_element(self, root): | ||
| if self.properties_file is not None: | ||
| element = ET.Element("properties") | ||
| element.text = str(self.properties_file) |
There was a problem hiding this comment.
Something went wrong in the latest update @gonuke, I think it's here (i.e there's nothing called properties_file in the XML now.) I just re-tried and my settings looks like this
<settings>
<properties>/home/lgross/cnerg/gcmr/multiphysics_depletion/BOL_mp_depl/180/properties.h5</properties>
</settings>
which leads to this behavior
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%
############### %%%%%%%%%%%%%%%%%%%%%%%%
################## %%%%%%%%%%%%%%%%%%%%%%%
################### %%%%%%%%%%%%%%%%%%%%%%%
#################### %%%%%%%%%%%%%%%%%%%%%%
##################### %%%%%%%%%%%%%%%%%%%%%
###################### %%%%%%%%%%%%%%%%%%%%
####################### %%%%%%%%%%%%%%%%%%
####################### %%%%%%%%%%%%%%%%%
###################### %%%%%%%%%%%%%%%%%
#################### %%%%%%%%%%%%%%%%%
################# %%%%%%%%%%%%%%%%%
############### %%%%%%%%%%%%%%%%
############ %%%%%%%%%%%%%%%
######## %%%%%%%%%%%%%%
%%%%%%%%%%%
| The OpenMC Monte Carlo Code
Copyright | 2011-2025 MIT, UChicago Argonne LLC, and contributors
License | https://docs.openmc.org/en/latest/license.html
Version | 0.15.3-dev282
Commit Hash | 0e9eea39a8243b2223bb345d01fd091906a629f8
Date/Time | 2026-03-05 10:59:29
MPI Processes | 1
OpenMP Threads | 96
Reading model XML file 'model.xml' ...
ERROR: Node "filepath" is not a member of the "properties" XML node
I think you either want to use element.setAttribute to set filepath or have the code just look for the properties element
There was a problem hiding this comment.
I'm kind of confused why the test didn't fail though
There was a problem hiding this comment.
Actually
// read properties from file
if (check_for_node(root, "properties")) {
properties_file = get_node_value(root, "properties");
if (!file_exists(properties_file)) {
fatal_error(fmt::format("File '{}' does not exist.", properties_file));
}
}The test looks for a node called properties, which is why it works. Perhaps now we just call it properties instead of properties_file now that we only supply a file
There was a problem hiding this comment.
Is your executable up to date?
There was a problem hiding this comment.
nvm I forgot to do make install after make and before installing the python api
EDIT: It's running now... I'll report back when it completes and hopefully it will be statistically equivalent to cardinal / OpenMC depletion. Also it printed
Importing properties from
/home/lgross/cnerg/gcmr/multiphysics_depletion/BOL_mp_depl/180/properties.h5...
There was a problem hiding this comment.
Still going :/ looks more promising so far. Probably will know by tomorrow
59/1 1.03796 1.04088 +/- 0.00175


Description
This adds the path of the
properties.h5file as a new entry in the simulation settings. This file path can be used for loading properties from a file other than the default.This will replace #3807 that has been withdrawn.
Fixes # (issue)
Checklist