Skip to content

Commit

Permalink
fix resbuf decay and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke committed Oct 27, 2024
1 parent 89eee5e commit e72f837
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/toolkit/res_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ class ResBuf {
/// @param curr_time time to calculate decay inventory
/// (default: -1 uses the current time of the context)
void Decay(int curr_time = -1) {
for (int i = 0; i < rs_.size(); i++) {
rs_.at(i)->Decay(curr_time);
for (auto rs : rs_) {
rs->Decay(curr_time);
}
}

Expand Down
23 changes: 23 additions & 0 deletions tests/material_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "cyc_limits.h"
#include "toolkit/mat_query.h"
#include "error.h"
#include "toolkit/res_buf.h"

using pyne::nucname::id;

Expand Down Expand Up @@ -208,6 +209,28 @@ TEST_F(MaterialTest, ExtractInGrams) {
EXPECT_DOUBLE_EQ(test_size_ - kg_to_rem, default_mat_->quantity());
}

TEST_F(MaterialTest, DecayResBuf) {
// prequeries
cyclus::toolkit::MatQuery orig(tracked_mat_);
double u235_qty = orig.mass(u235_);
double pb208_qty = orig.mass(pb208_);
double am241_qty = orig.mass(am241_);
double orig_mass = tracked_mat_->quantity();

cyclus::toolkit::ResBuf<cyclus::Material> res_buf;
res_buf.Push(tracked_mat_);
res_buf.Decay(100);
cyclus::Material::Ptr pop_mat = res_buf.Pop();

// postquery
cyclus::toolkit::MatQuery mq(pop_mat);

// postchecks
EXPECT_NE(u235_qty, mq.mass(u235_));
EXPECT_NE(pb208_qty, mq.mass(pb208_));
EXPECT_NE(am241_qty, mq.mass(am241_));
}

TEST_F(MaterialTest, DecayManual) {
// prequeries
cyclus::toolkit::MatQuery orig(tracked_mat_);
Expand Down

0 comments on commit e72f837

Please sign in to comment.