Skip to content

Commit

Permalink
Merge pull request cyclus#1761 from nuclearkatie/resource_table_recor…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
gonuke authored Jun 7, 2024
2 parents eaa0cd1 + 368e927 commit 1243f65
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Since last release
* Removed the ResourceBuff class and replaced its instances with ResBuf (#1755)

**Fixed:**

* Removed unnecessary records being added to the Resource database by packaging process (#1761)

v1.6.0
====================
Expand Down
11 changes: 8 additions & 3 deletions src/res_tracker.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "res_tracker.h"

#include "recorder.h"
#include "cyc_limits.h"

namespace cyclus {

Expand Down Expand Up @@ -44,13 +45,17 @@ void ResTracker::Extract(ResTracker* removed) {
return;
}

parent1_ = res_->state_id();
parent2_ = 0;
if (res_->quantity() > eps_rsrc()) {
parent1_ = res_->state_id();
parent2_ = 0;

Record();
}

removed->parent1_ = res_->state_id();
removed->parent2_ = 0;
removed->tracked_ = tracked_;

Record();
removed->Record();
}

Expand Down
27 changes: 19 additions & 8 deletions src/toolkit/matl_sell_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,26 @@ void MatlSellPolicy::GetMatlTrades(
double qty = it->amt;
LGH(INFO3) << " sending " << qty << " kg of " << it->request->commodity();
Material::Ptr mat = buf_->Pop(qty, cyclus::eps_rsrc());
std::vector<Material::Ptr> mat_pkgd = mat->Package<Material>(package_);
// push any extra material that couldn't be packaged back onto buffer
buf_->Push(mat);
if (mat_pkgd.size() > 0) {
if (ignore_comp_) {
mat_pkgd[0]->Transmute(it->request->target()->comp());
}
responses.push_back(std::make_pair(*it, mat_pkgd[0]));
Material::Ptr trade_mat;

// don't go through packaging if you don't need to. packaging always bumps
// resource ids and records on resources table, which is not necessary
// when nothing is happening
if (package_->name() != mat->package_name()) { // packaging needed
std::vector<Material::Ptr> mat_pkgd = mat->Package<Material>(package_);
// push any extra material that couldn't be packaged back onto buffer
buf_->Push(mat);
if (mat_pkgd.size() > 0) {
trade_mat = mat_pkgd[0];
}
} else { // no packaging needed
trade_mat = mat;
}

if (ignore_comp_) {
trade_mat->Transmute(it->request->target()->comp());
}
responses.push_back(std::make_pair(*it, trade_mat));
}
}

Expand Down

0 comments on commit 1243f65

Please sign in to comment.