-
Notifications
You must be signed in to change notification settings - Fork 21
Expand sesame2spiner input syntax #623
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e669fc5
Expand the input syntax to allow for multiple materials separated by …
adamdempsey90 fe6bd10
Add example inputs that combine the old inputs
adamdempsey90 6442797
Use the single input file for sesame2spiner
adamdempsey90 da5c782
Changelog
adamdempsey90 e422602
Correct titanium block
adamdempsey90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # ====================================================================== | ||
| # © 2026. Triad National Security, LLC. All rights reserved. This | ||
| # program was produced under U.S. Government contract 89233218CNA000001 | ||
| # for Los Alamos National Laboratory (LANL), which is operated by Triad | ||
| # National Security, LLC for the U.S. Department of Energy/National | ||
| # Nuclear Security Administration. All rights in the program are | ||
| # reserved by Triad National Security, LLC, and the U.S. Department of | ||
| # Energy/National Nuclear Security Administration. The Government is | ||
| # granted for itself and others acting on its behalf a nonexclusive, | ||
| # paid-up, irrevocable worldwide license in this material to reproduce, | ||
| # prepare derivative works, distribute copies to the public, perform | ||
| # publicly and display publicly, and to permit others to do so. | ||
| # ====================================================================== | ||
|
|
||
| # First material doesn't need <name> | ||
| matid = 5030 | ||
| name = air | ||
| # These set the number of grid points per decade | ||
| # for each variable. The default is 50 points | ||
| # per decade. | ||
| numrho/decade = 40 | ||
| numT/decade = 40 | ||
| numSie/decade = 40 | ||
|
|
||
| <aluminum> | ||
| matid=3720 | ||
| name=aluminum # define it again to test | ||
| rhomin = 1e-5 | ||
| Tmin = 1 | ||
|
|
||
| <helium> | ||
| matid = 5762 | ||
|
|
||
| <steel> | ||
| matid = 4272 | ||
| rhomin = 1e-5 | ||
| Tmin = 1 | ||
|
|
||
|
|
||
| <titanium> | ||
| matid = 2961 | ||
| # These set the number of grid points per decade | ||
| # for each variable. The default is 50 points | ||
| # per decade. | ||
| numrho/decade = 30 | ||
| numT/decade = 25 | ||
| numSie/decade = 15 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # ====================================================================== | ||
| # © 2026. Triad National Security, LLC. All rights reserved. This | ||
| # program was produced under U.S. Government contract 89233218CNA000001 | ||
| # for Los Alamos National Laboratory (LANL), which is operated by Triad | ||
| # National Security, LLC for the U.S. Department of Energy/National | ||
| # Nuclear Security Administration. All rights in the program are | ||
| # reserved by Triad National Security, LLC, and the U.S. Department of | ||
| # Energy/National Nuclear Security Administration. The Government is | ||
| # granted for itself and others acting on its behalf a nonexclusive, | ||
| # paid-up, irrevocable worldwide license in this material to reproduce, | ||
| # prepare derivative works, distribute copies to the public, perform | ||
| # publicly and display publicly, and to permit others to do so. | ||
| # ====================================================================== | ||
|
|
||
| # First material doesn't need <name> | ||
| matid = 5030 | ||
| name = air | ||
|
|
||
| <Aluminum> | ||
| matid=3720 | ||
| name=Aluminum # can override name | ||
|
|
||
| <copper> | ||
| matid=3337 | ||
| piecewiseRho = false | ||
| numrho/decade = 50 | ||
|
|
||
| <deuterium> | ||
| matid = 5267 | ||
|
|
||
| <Foam> | ||
| matid=7592 | ||
| numrho/decade = 200 | ||
| numT/decade = 200 | ||
|
|
||
| <gold> | ||
| matid = 2700 | ||
|
|
||
| <neon> | ||
| matid = 5000 | ||
|
|
||
| <steel> | ||
| matid=4272 | ||
| ionization = true | ||
|
|
||
| <tin> | ||
| matid=2162 | ||
|
|
||
| <titanium> | ||
| matid = 2961 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,9 @@ | |
| #include <stdexcept> | ||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| #include "parse_cli.hpp" | ||
| #include "parser.hpp" | ||
|
|
||
| Params::Params(const std::string &input_file) { | ||
|
|
@@ -39,10 +41,22 @@ void Params::Parse(std::istream &s) { | |
| auto delimiter_pos = line.find("="); | ||
| auto name = line.substr(0, delimiter_pos); | ||
| auto value = line.substr(delimiter_pos + 1); | ||
| // make sure there's no trailing comment | ||
| auto comment_pos = value.find("#"); | ||
| if (comment_pos != std::string::npos) { | ||
| value.erase(comment_pos); | ||
| } | ||
|
Comment on lines
+44
to
+48
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. 👍 |
||
| params_[name] = value; | ||
| } | ||
| } | ||
|
|
||
| void Params::Print(std::ostream &s) const { | ||
| s << "\nParams for " << params_.at("name") << "\n"; | ||
| for (const auto &pair : params_) { | ||
| s << pair.first << " = " << pair.second << "\n"; | ||
| } | ||
| } | ||
|
|
||
| template <> | ||
| std::string Params::Get(const std::string &key) const { | ||
| return params_.at(key); | ||
|
|
@@ -74,3 +88,74 @@ bool Params::Get(const std::string &key) const { | |
| throw std::runtime_error("The value of " + key + " is not a boolean.\n"); | ||
| } | ||
| } | ||
|
|
||
| void add_param(const Params &p, std::vector<Params> ¶ms, std::vector<int> &matids, | ||
| const std::string &filename) { | ||
|
|
||
| if (!p.Contains("matid")) { | ||
| if (p.Contains("name")) { | ||
| const auto &name = p.Get<std::string>("name"); | ||
| std::cerr << "Material " << name << " in file " << filename << "is missing matid.\n" | ||
| << "Example input files:\n" | ||
| << EXAMPLESTRING << std::endl; | ||
| std::exit(1); | ||
| } else { | ||
| std::cerr << "A Material in file " << filename << "has no name.\n" | ||
| << "Example input files:\n" | ||
| << EXAMPLESTRING << std::endl; | ||
| std::exit(1); | ||
| } | ||
| } | ||
| matids.push_back(p.Get<int>("matid")); | ||
| params.push_back(p); | ||
| } | ||
|
|
||
| void parse_file(std::vector<Params> ¶ms, std::vector<int> &matids, std::istream &s, | ||
| const std::string &filename) { | ||
| std::string line; | ||
| Params p; | ||
| size_t line_num = 1; | ||
| while (getline(s, line)) { | ||
| line.erase(std::remove_if(line.begin(), line.end(), isspace), line.end()); | ||
| if (line[0] == '#' || line.empty()) { | ||
| line_num++; | ||
| continue; | ||
| } | ||
| if (line[0] == '<') { | ||
| auto term = line.find('>'); | ||
| if (term == std::string::npos) { | ||
| std::cerr << "Missing closing > on line " << line_num << " of file " << filename | ||
| << "\n"; | ||
| std::exit(1); | ||
| } | ||
|
|
||
| auto name = line.substr(1, term - 1); | ||
| if (!p.Empty()) add_param(p, params, matids, filename); | ||
|
|
||
| p.Clear(); | ||
| p.Set("name", name); | ||
| } else { | ||
| auto delimiter_pos = line.find("="); | ||
| auto name = line.substr(0, delimiter_pos); | ||
| auto value = line.substr(delimiter_pos + 1); | ||
| // make sure there's no trailing comment | ||
| auto comment_pos = value.find("#"); | ||
| if (comment_pos != std::string::npos) { | ||
| value.erase(comment_pos); | ||
| } | ||
| p.Set(name, value); | ||
| } | ||
| line_num++; | ||
| } | ||
| if (!p.Empty()) add_param(p, params, matids, filename); | ||
| } | ||
|
|
||
| void AddMaterials(std::vector<Params> ¶ms, std::vector<int> &matids, | ||
| const std::string &input_file) { | ||
| std::ifstream config_file(input_file); | ||
| if (config_file.is_open()) { | ||
| parse_file(params, matids, config_file, input_file); | ||
| } else { | ||
| throw std::runtime_error("Couldn't open config file " + input_file + "\n"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.