-
Notifications
You must be signed in to change notification settings - Fork 71
Added parameters to keep all statepoints in transient solves. #1313
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
base: devel
Are you sure you want to change the base?
Changes from all commits
828d464
02825d4
12070c9
4b679ca
911d3ed
4d1a188
9dde623
cfd7c4c
a9e228b
6d89d2c
f4642de
1b8b26a
e585cac
55beaf6
2e8bfa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -445,6 +445,20 @@ class OpenMCProblemBase : public CardinalProblem, public PostprocessorInterface | |||||
| std::to_string(_fixed_point_iteration) + ".h5"; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Return path to write current timestep's statepoint to in transient solves. | ||||||
| * @return statepoint path | ||||||
| */ | ||||||
| const std::string transientStatepointPath(); | ||||||
|
|
||||||
| /** | ||||||
| * Formats `path_output` so that it is ready to be passed to | ||||||
| * openmc::settings::path_output | ||||||
| * @param[in] path_output unformatted path | ||||||
| * @return formatted absolute path | ||||||
| */ | ||||||
| const std::string formattedOutputPath(const std::string & path_output); | ||||||
|
TheBEllis marked this conversation as resolved.
|
||||||
|
|
||||||
| /// Whether to print diagnostic information about model setup and the transfers | ||||||
| const bool & _verbose; | ||||||
|
|
||||||
|
|
@@ -567,6 +581,12 @@ class OpenMCProblemBase : public CardinalProblem, public PostprocessorInterface | |||||
| /// Directory in which OpenMC settings xml files are located | ||||||
| const std::string & _xml_directory; | ||||||
|
|
||||||
| /// Directory to write statepoint file to | ||||||
| const std::string & _statepoint_directory; | ||||||
|
|
||||||
| /// Parameter determines whether statepoints from all timesteps should be saved in separtate directories to avoid them being overwritten | ||||||
|
aprilnovak marked this conversation as resolved.
|
||||||
| const bool _keep_transient_statepoint; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. capturing by reference is recommended by MOOSE convention when possible because it'll be compatible with controls and other systems |
||||||
|
|
||||||
| /// Conversion unit to transfer between kg/m3 and g/cm3 | ||||||
| static constexpr Real _density_conversion_factor{0.001}; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -98,6 +98,17 @@ OpenMCProblemBase::validParams() | |||||
| "The number of generations to use with the method of iterated fission probabilities."); | ||||||
| params.addParam<FileName>( | ||||||
| "xml_directory", "./", "The directory in which to look for OpenMC XML files."); | ||||||
|
|
||||||
| params.addParam<FileName>( | ||||||
| "statepoint_directory", | ||||||
| "./", | ||||||
| "The directory to write statepoint files to. Sets openmc::settings::path_output."); | ||||||
|
|
||||||
| params.addParam<bool>("keep_transient_statepoint", | ||||||
| false, | ||||||
| "Whether or not statepoints from all timesteps should be kept, and written " | ||||||
| "to seperate directories."); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| return params; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -116,7 +127,9 @@ OpenMCProblemBase::OpenMCProblemBase(const InputParameters & params) | |||||
| _calc_kinetics_params(getParam<bool>("calc_kinetics_params")), | ||||||
| _reset_seed(getParam<bool>("reset_seed")), | ||||||
| _initial_seed(openmc::openmc_get_seed()), | ||||||
| _xml_directory(getParam<FileName>("xml_directory")) | ||||||
| _xml_directory(getParam<FileName>("xml_directory")), | ||||||
| _statepoint_directory(getParam<FileName>("statepoint_directory")), | ||||||
| _keep_transient_statepoint(getParam<bool>("keep_transient_statepoint")) | ||||||
| { | ||||||
| if (isParamValid("tally_type")) | ||||||
| mooseError("The tally system used by OpenMCProblemBase derived classes has been deprecated. " | ||||||
|
|
@@ -233,6 +246,22 @@ OpenMCProblemBase::OpenMCProblemBase(const InputParameters & params) | |||||
| catchOpenMCError(err, "set the number of batches"); | ||||||
| } | ||||||
|
|
||||||
| if (isParamSetByUser("statepoint_directory") && !_keep_transient_statepoint) | ||||||
| { | ||||||
| /// path_output must end with a "/", otherwise statepoint will not output correctly | ||||||
| openmc::settings::path_output = formattedOutputPath(_statepoint_directory); | ||||||
|
|
||||||
| /// Need to remove trailing "/" to do "is_regular_file" | ||||||
| std::filesystem::path p = openmc::settings::path_output; | ||||||
| p = p.filename().empty() ? p.parent_path() : p; | ||||||
|
|
||||||
| if (std::filesystem::is_regular_file(p)) | ||||||
| mooseError("Cannot create directory " + openmc::settings::path_output + | ||||||
| ", as a file with the same name already exists"); | ||||||
|
|
||||||
| std::filesystem::create_directory(openmc::settings::path_output); | ||||||
| } | ||||||
|
|
||||||
| // The OpenMC wrapping doesn't require material properties itself, but we might | ||||||
| // define them on some blocks of the domain for other auxiliary kernel purposes | ||||||
| setMaterialCoverageCheck(false); | ||||||
|
|
@@ -375,6 +404,19 @@ OpenMCProblemBase::externalSolve() | |||||
| // update tallies as needed before starting the OpenMC run | ||||||
| executeEditors(); | ||||||
|
|
||||||
| if (_keep_transient_statepoint) | ||||||
| { | ||||||
| openmc::settings::path_output = transientStatepointPath(); | ||||||
|
|
||||||
| /// Need to remove trailing "/" to do "is_regular_file" | ||||||
| std::filesystem::path p = openmc::settings::path_output; | ||||||
| p = p.filename().empty() ? p.parent_path() : p; | ||||||
| if (std::filesystem::is_regular_file(p)) | ||||||
| mooseError("Cannot create directory " + openmc::settings::path_output + | ||||||
| ", as a file with the same name already exists"); | ||||||
| std::filesystem::create_directory(openmc::settings::path_output); | ||||||
| } | ||||||
|
|
||||||
| if (_reset_seed) | ||||||
| { | ||||||
| openmc_hard_reset(); | ||||||
|
|
@@ -1030,4 +1072,66 @@ OpenMCProblemBase::sendNuclideDensitiesToOpenMC() | |||||
| uo->setValue(); | ||||||
| } | ||||||
|
|
||||||
| const std::string | ||||||
| OpenMCProblemBase::transientStatepointPath() | ||||||
| { | ||||||
| if (!isTransient()) | ||||||
| { | ||||||
| mooseWarning("keep_transient_statepoint is set to True, but selected Executioner is Steady. " | ||||||
| "Keeping original statepoint path."); | ||||||
| return openmc::settings::path_output; | ||||||
| } | ||||||
|
|
||||||
| // Get path of current input file | ||||||
| std::filesystem::path running_path = | ||||||
| std::filesystem::absolute(getMooseApp().getLastInputFileName()).parent_path(); | ||||||
|
|
||||||
| std::filesystem::path transient_statepoint_path; | ||||||
|
|
||||||
| // If user has not set statepoint_directory parameter, or has defined it as './', | ||||||
| // use a default | ||||||
| if (std::filesystem::weakly_canonical(_statepoint_directory) == | ||||||
| std::filesystem::weakly_canonical(running_path)) | ||||||
| transient_statepoint_path = "./statepoint_folder"; | ||||||
| else | ||||||
| { | ||||||
| transient_statepoint_path = _statepoint_directory; | ||||||
|
|
||||||
| // Removes trailing "/" from transient_statepoint_path, if user has left any, ready to append | ||||||
| // suffix | ||||||
| transient_statepoint_path = transient_statepoint_path.filename().empty() | ||||||
| ? transient_statepoint_path.parent_path() | ||||||
| : transient_statepoint_path; | ||||||
| } | ||||||
|
|
||||||
| std::string timestep_suffix = "_ts_" + std::to_string(timeStep()) + "/"; | ||||||
|
|
||||||
| transient_statepoint_path += timestep_suffix; | ||||||
|
|
||||||
| const std::string transient_statepoint_path_str = | ||||||
| formattedOutputPath(transient_statepoint_path.string()); | ||||||
|
|
||||||
| return transient_statepoint_path_str; | ||||||
| } | ||||||
|
|
||||||
| const std::string | ||||||
| OpenMCProblemBase::formattedOutputPath(const std::string & output_path) | ||||||
| { | ||||||
| std::filesystem::path p = output_path; | ||||||
| p = p.lexically_normal(); | ||||||
|
|
||||||
| if (p.is_relative()) | ||||||
| { | ||||||
| std::filesystem::path input_file_path = | ||||||
| std::filesystem::absolute(getMooseApp().getLastInputFileName()).parent_path(); | ||||||
|
|
||||||
| p = std::filesystem::weakly_canonical(input_file_path / p); | ||||||
| } | ||||||
|
|
||||||
| if (p.string().back() != '/') | ||||||
| p += "/"; | ||||||
|
|
||||||
| return p.string(); | ||||||
| } | ||||||
|
|
||||||
| #endif | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [Mesh] | ||
| [sphere] | ||
| type = FileMeshGenerator | ||
| file = ../meshes/sphere.e | ||
| [] | ||
| [] | ||
|
|
||
| [Problem] | ||
| type = OpenMCCellAverageProblem | ||
| statepoint_directory = "./custom_dir" | ||
| batches = 50 | ||
| [] | ||
|
|
||
| [Executioner] | ||
| type = Transient | ||
| num_steps = 1 | ||
| [] | ||
|
|
||
| [Postprocessors] | ||
| [k] | ||
| type = KEigenvalue | ||
| [] | ||
| [] | ||
|
|
||
| [Outputs] | ||
| csv = true | ||
| [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [Mesh] | ||
| [sphere] | ||
| type = FileMeshGenerator | ||
| file = ../meshes/sphere.e | ||
| [] | ||
| [] | ||
|
|
||
| [Problem] | ||
| type = OpenMCCellAverageProblem | ||
| statepoint_directory = "./existing_file" | ||
| batches = 50 | ||
| [] | ||
|
|
||
| [Executioner] | ||
| type = Transient | ||
| num_steps = 1 | ||
| [] | ||
|
|
||
| [Postprocessors] | ||
| [k] | ||
| type = KEigenvalue | ||
| [] | ||
| [] | ||
|
|
||
| [Outputs] | ||
| csv = true | ||
| [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,28 @@ | |
| "in settings.xml and they are both specified." | ||
| capabilities = 'openmc' | ||
| [] | ||
|
|
||
| [check_statepoint_exists_in_directory] | ||
| type = CheckFiles | ||
| input = openmc_custom_dir.i | ||
| check_files = 'custom_dir/statepoint.50.h5' | ||
| # This test has very few particles, and OpenMC will error if there aren't enough source particles | ||
| # in the fission bank on a process | ||
| max_parallel = 8 | ||
| requirement = "A statepoint file must be written to the parameter defined directory when the batches parameter matches the batches " | ||
| "in settings.xml and they are both specified." | ||
| capabilities = 'openmc' | ||
| [] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please make sure each test has a |
||
|
|
||
|
|
||
| [check_statepoint_exists_in_directory_w_existing_filename] | ||
| type = RunException | ||
| input = openmc_custom_dir_filename.i | ||
| expect_err = 'a file with the same name already exists' | ||
| # This test has very few particles, and OpenMC will error if there aren't enough source particles | ||
| # in the fission bank on a process | ||
| max_parallel = 8 | ||
| requirement = "The user defined directory has the same name as an existing file. Expect test to throw due to attempting to create directory with the same name as the file." | ||
| capabilities = 'openmc' | ||
| [] | ||
| [] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <geometry> | ||
| <cell id="1" material="1" region="-1" universe="1" /> | ||
| <cell id="2" material="2" region="-2" universe="1" /> | ||
| <cell id="3" material="3" region="-3" universe="1" /> | ||
| <cell id="4" material="4" region="1 2 3 4 -5 6 -7 8 -9" universe="1" /> | ||
| <surface coeffs="0.0 0.0 0.0 1.5" id="1" type="sphere" /> | ||
| <surface coeffs="0.0 0.0 4.0 1.5" id="2" type="sphere" /> | ||
| <surface coeffs="0.0 0.0 8.0 1.5" id="3" type="sphere" /> | ||
| <surface boundary="reflective" coeffs="-2.5" id="4" name="minimum x" type="x-plane" /> | ||
| <surface boundary="reflective" coeffs="2.5" id="5" name="maximum x" type="x-plane" /> | ||
| <surface boundary="reflective" coeffs="-2.5" id="6" name="minimum y" type="y-plane" /> | ||
| <surface boundary="reflective" coeffs="2.5" id="7" name="maximum y" type="y-plane" /> | ||
| <surface boundary="reflective" coeffs="-2.0" id="8" type="z-plane" /> | ||
| <surface boundary="reflective" coeffs="10.0" id="9" type="z-plane" /> | ||
| </geometry> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <materials> | ||
| <material depletable="true" id="1"> | ||
| <density units="g/cc" value="10.0" /> | ||
| <nuclide ao="9.051308944870946e-05" name="U234" /> | ||
| <nuclide ao="0.010126612654073502" name="U235" /> | ||
| <nuclide ao="0.9897364895065476" name="U238" /> | ||
| <nuclide ao="4.63847499302226e-05" name="U236" /> | ||
| <nuclide ao="1.999242" name="O16" /> | ||
| <nuclide ao="0.000758" name="O17" /> | ||
| </material> | ||
| <material depletable="true" id="2"> | ||
| <density units="g/cc" value="10.0" /> | ||
| <nuclide ao="0.0004523305496680539" name="U234" /> | ||
| <nuclide ao="0.05060678290832386" name="U235" /> | ||
| <nuclide ao="0.948709083169038" name="U238" /> | ||
| <nuclide ao="0.00023180337297007338" name="U236" /> | ||
| <nuclide ao="1.999242" name="O16" /> | ||
| <nuclide ao="0.000758" name="O17" /> | ||
| </material> | ||
| <material depletable="true" id="3"> | ||
| <density units="g/cc" value="10.0" /> | ||
| <nuclide ao="0.0009040745407538578" name="U234" /> | ||
| <nuclide ao="0.10114794158928406" name="U235" /> | ||
| <nuclide ao="0.8974846777145036" name="U238" /> | ||
| <nuclide ao="0.00046330615545845175" name="U236" /> | ||
| <nuclide ao="1.999242" name="O16" /> | ||
| <nuclide ao="0.000758" name="O17" /> | ||
| </material> | ||
| <material depletable="true" id="4"> | ||
| <density units="g/cc" value="1.0" /> | ||
| <nuclide ao="1.99968852" name="H1" /> | ||
| <nuclide ao="0.00031148" name="H2" /> | ||
| <nuclide ao="0.999621" name="O16" /> | ||
| <nuclide ao="0.000379" name="O17" /> | ||
| <nuclide ao="5.4e-05" name="U234" /> | ||
| <nuclide ao="0.007204" name="U235" /> | ||
| <nuclide ao="0.992742" name="U238" /> | ||
| </material> | ||
| </materials> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| [Mesh] | ||
| [sphere] | ||
| type = FileMeshGenerator | ||
| file = ../meshes/sphere.e | ||
| [] | ||
| [] | ||
|
|
||
| [Problem] | ||
| type = OpenMCCellAverageProblem | ||
| keep_transient_statepoint = true | ||
| batches = 50 | ||
| [] | ||
|
|
||
| [Executioner] | ||
| type = Transient | ||
| num_steps = 2 | ||
| [] | ||
|
|
||
| [Postprocessors] | ||
| [k] | ||
| type = KEigenvalue | ||
| [] | ||
| [] | ||
|
|
||
| [Outputs] | ||
| csv = true | ||
| [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [Mesh] | ||
| [sphere] | ||
| type = FileMeshGenerator | ||
| file = ../meshes/sphere.e | ||
| [] | ||
| [] | ||
|
|
||
| [Problem] | ||
| type = OpenMCCellAverageProblem | ||
| keep_transient_statepoint = true | ||
| statepoint_directory = "./mystatepoints/" | ||
| batches = 50 | ||
| [] | ||
|
|
||
| [Executioner] | ||
| type = Transient | ||
| num_steps = 2 | ||
| [] | ||
|
|
||
| [Postprocessors] | ||
| [k] | ||
| type = KEigenvalue | ||
| [] | ||
| [] | ||
|
|
||
| [Outputs] | ||
| csv = true | ||
| [] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version='1.0' encoding='utf-8'?> | ||
| <settings> | ||
| <run_mode>eigenvalue</run_mode> | ||
| <particles>100</particles> | ||
| <batches>50</batches> | ||
| <inactive>10</inactive> | ||
| <source strength="1.0"> | ||
| <space type="fission"> | ||
| <parameters>-5.0 -5.0 0 5.0 5.0 12.0</parameters> | ||
| </space> | ||
| </source> | ||
| <temperature_default>600.0</temperature_default> | ||
| <temperature_method>nearest</temperature_method> | ||
| <temperature_multipole>false</temperature_multipole> | ||
| <temperature_range>294.0 1600.0</temperature_range> | ||
| </settings> |
Uh oh!
There was an error while loading. Please reload this page.