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 30 commits intoopenmc-dev:developfrom
Conversation
| properties_file : Pathlike | ||
| Location of the properties file to load cell temperatures/densities | ||
| and materials | ||
| random_ray : dict |
There was a problem hiding this comment.
Looking at discussion on #3807, I think I agree with Patrick that we should have a properties sub-element of settings with it's own subelements that should be booleans of whether to load temperatures, densities, and perhaps something like check_mats (default to true). I don't expect most people to be loading materials from the properties file, it's just exists as a check to make sure you're not loading properties from some model that doesn't really match your current one. We are the special case where our properties.h5 specifically does not include the zoned materials we make after generating properties. I think I agree there should also be a filepath subelement of properties that defaults to properties.h5 but can be changed to something else.
There was a problem hiding this comment.
Working on this - ran out of time figuring out the XML stuff for this - stay tuned
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 :) |
include/openmc/xml_interface.h
Outdated
| std::string get_node_value(pugi::xml_node node, const char* name, | ||
| bool lowercase = false, bool strip = false); | ||
|
|
||
| std::string get_node_path(pugi::xml_node node, const char* name, |
There was a problem hiding this comment.
@pshriwise - we thought this would be nice to have, but I've just realized that returning an error code - as we may want to do - is not compatible with the function signature. Interested in design guidance:
a) skip this and just test for valid file after this call
b) figure out how to make this function do all the things.
I'm inclined to (a) for now and let this be a separate issue down the road.
There was a problem hiding this comment.
Seems like you landed where I did on this. It's probably still useful in some form, but isn't high priority and isn't worth the distraction in this PR. 👍🏻
|
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/material.cpp
Outdated
| if (read_densities_from_properties) { | ||
| hid_t material_group = open_group(group, "material " + std::to_string(id_)); | ||
| double density; | ||
| read_attribute(material_group, "atom_density", density); | ||
| this->set_density(density, "atom/b-cm"); | ||
| close_group(material_group); | ||
| } |
There was a problem hiding this comment.
Not critical but a slight style preference here for readability
| if (read_densities_from_properties) { | |
| hid_t material_group = open_group(group, "material " + std::to_string(id_)); | |
| double density; | |
| read_attribute(material_group, "atom_density", density); | |
| this->set_density(density, "atom/b-cm"); | |
| close_group(material_group); | |
| } | |
| if (!read_densities_from_properties) return; | |
| hid_t material_group = open_group(group, "material " + std::to_string(id_)); | |
| double density; | |
| read_attribute(material_group, "atom_density", density); | |
| this->set_density(density, "atom/b-cm"); | |
| close_group(material_group); |
There was a problem hiding this comment.
I have this lingering desire to have a single point of return from functions. I don't remember where in my past I got that bias... I've fixed this per your suggestion, though.
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.
src/summary.cpp
Outdated
| for (const auto& c : model::cells) { | ||
| c->import_properties_hdf5(cells_group); | ||
| c->import_properties_hdf5(cells_group, read_temperatures_from_properties, | ||
| read_densities_from_properties); |
There was a problem hiding this comment.
This is perhaps outside the scope of this PR and can be handled in a separate issue/PR, but is this the place where we'd have to safeguard against distribcell offsets not in our model that exist in the properties file?
I think that there's a possibility that a cell in model::cells does not have distribcell offsets in the model but does have them in the properties file. I'm not sure we should skip those cells because they might have a temperature we want but it also might error if we try to load them (e.g. vector range check 0 error message)
There was a problem hiding this comment.
I'll call it outside the scope for now. It seems like something best debugged and improved once this fundamental capability has been implemented.
|
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? |


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