Skip to content
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

No way to print out the full composition of a material to screen #1739

Open
dean-krueger opened this issue Apr 27, 2024 · 0 comments
Open

No way to print out the full composition of a material to screen #1739

dean-krueger opened this issue Apr 27, 2024 · 0 comments

Comments

@dean-krueger
Copy link

There are some times where it might be nice from a user perspective to be able to get a string with the normalized composition of a material in it (to print, or to use otherwise). Currently, Cyclus can write this out to a file, but there's no way to do it on screen or use it as a variable. I wrote my own version of a function that does this, which I will include below to further illustrate what I mean.

std::string Reactor::GetComp(cyclus::Material::Ptr mat) {
  std::string comp = "{";
  cyclus::CompMap c = mat->comp()->atom();
  cyclus::compmath::Normalize(&c, 1);
  for (std::map<const int, double>::const_iterator it = c.begin();
       it != c.end(); ++it) {
    comp = comp + std::string("{") + std::to_string(it->first) +
           std::string(",") + std::to_string(it->second) + std::string("},");
  }
  comp.pop_back();
  comp = comp + std::string("}");
  return comp;
}
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

No branches or pull requests

1 participant