Skip to content

Commit

Permalink
Adapt IsotopesNucID function to return a vector
Browse files Browse the repository at this point in the history
Instead of filling an already existing vector passed by reference to
`IsotopesNucID`, the function now returns a new (filled) vector. This
seems neater and I do not know why I have not done it like this from the
start.
  • Loading branch information
maxschalz committed Mar 9, 2021
1 parent 7c943a7 commit 2b69deb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 29 deletions.
5 changes: 2 additions & 3 deletions src/enrichment_calculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EnrichmentCalculator::EnrichmentCalculator(
feed_qty(0.), product_qty(0.),
max_swu(max_swu),
use_downblending(use_downblending),
isotopes(IsotopesNucID_vector()) {
isotopes(IsotopesNucID()) {
if (feed_qty==1e299 && product_qty==1e299 && max_swu==1e299) {
// TODO think about whether one or two of these variables have to be
// defined. Additionally, add an exception that should be thrown.
Expand All @@ -59,7 +59,7 @@ EnrichmentCalculator::EnrichmentCalculator(const EnrichmentCalculator& e) :
target_tails_assay(e.target_tails_assay),
target_feed_qty(e.target_feed_qty),
target_product_qty(e.target_product_qty), max_swu(e.max_swu),
use_downblending(e.use_downblending), isotopes(IsotopesNucID_vector()),
use_downblending(e.use_downblending), isotopes(IsotopesNucID()),
gamma_235(e.gamma_235) {
CalculateGammaAlphaStar_();
BuildMatchedAbundanceRatioCascade();
Expand Down Expand Up @@ -91,7 +91,6 @@ EnrichmentCalculator& EnrichmentCalculator::operator= (

use_downblending = e.use_downblending;

//IsotopesNucID(isotopes);
gamma_235 = e.gamma_235;
CalculateGammaAlphaStar_();

Expand Down
3 changes: 1 addition & 2 deletions src/miso_enrich.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ class FeedConverter : public cyclus::Converter<cyclus::Material> {
double feed_used = e.FeedUsed();

cyclus::toolkit::MatQuery mq(m);
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());
std::set<int> nucs(isotopes.begin(), isotopes.end());
double feed_uranium_frac = mq.atom_frac(nucs);

Expand Down
24 changes: 6 additions & 18 deletions src/miso_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ namespace misotest {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CompareCompMap(cyclus::CompMap cm1, cyclus::CompMap cm2) {
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());
std::vector<int>::iterator it;
// The following for-loop has been added to ensure that the all of the
// uranium keys are present in both compmaps, else the comparison fails.
Expand Down Expand Up @@ -97,15 +96,7 @@ cyclus::Material::Ptr mat_natU() {
} // namespace misotest

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void IsotopesNucID(std::vector<int>& isotopes) {
isotopes = {232, 233, 234, 235, 236, 238};
for (int i = 0; i < isotopes.size(); i++) {
isotopes[i] = (92*1000 + isotopes[i]) * 10000;
}
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::vector<int> IsotopesNucID_vector() {
const std::vector<int> IsotopesNucID() {
int iso[6] = {232, 233, 234, 235, 236, 238};
std::vector<int> isotopes(iso, iso + sizeof(iso)/sizeof(int));
for (int& i : isotopes) {
Expand All @@ -128,8 +119,7 @@ int IsotopeToNucID(int isotope) {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int NucIDToIsotope(int nuc_id) {
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());
std::vector<int>::iterator it;

it = std::find(isotopes.begin(), isotopes.end(), nuc_id);
Expand Down Expand Up @@ -207,8 +197,7 @@ double MIsoAssay(cyclus::CompMap compmap) {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
double MIsoFrac(cyclus::CompMap compmap, int isotope) {
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());

double isotope_assay = 0;
double uranium_atom_frac = 0;
Expand All @@ -234,10 +223,9 @@ double MIsoFrac(cyclus::CompMap compmap, int isotope) {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::map<int,double> CalculateSeparationFactor(double gamma_235) {
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());
std::map<int,double> separation_factors;

// We consider U-238 to be the key component hence the mass differences
// are calculated with respect to this isotope.
for (int i : isotopes) {
Expand Down
3 changes: 1 addition & 2 deletions src/miso_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ const double kEpsDouble = 1e-5;
const double kEpsCompMap = 1e-5;
const int kIterMax = 200;

std::vector<int> IsotopesNucID_vector();
void IsotopesNucID(std::vector<int>& isotopes);
const std::vector<int> IsotopesNucID();
int IsotopeToNucID(int isotope);
int NucIDToIsotope(int nuc_id);
int ResBufIdx(
Expand Down
6 changes: 2 additions & 4 deletions src/miso_helper_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ TEST(MIsoHelperTest, ChooseCorrectResBuf) {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TEST(MIsoHelperTest, NucIDConversion) {
std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());

for (int i : isotopes) {
int isotope = NucIDToIsotope(i);
Expand Down Expand Up @@ -72,8 +71,7 @@ TEST(MIsoHelperTest, SeparationFactor) {
std::map<int,double> separation_factor = CalculateSeparationFactor(
gamma_235);

std::vector<int> isotopes;
IsotopesNucID(isotopes);
std::vector<int> isotopes(IsotopesNucID());
std::map<int,double> expected;
expected[922320000] = 2.2;
expected[922330000] = 2.0;
Expand Down

0 comments on commit 2b69deb

Please sign in to comment.