Skip to content

Commit

Permalink
Added tests for Separations retirement behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Meghan McGarry authored and rwcarlsen committed Aug 26, 2015
1 parent 908ce2b commit fee222d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/separations.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Separations : public cyclus::Facility {
std::vector<std::pair<cyclus::Trade<cyclus::Material>,
cyclus::Material::Ptr> >& responses);

bool CheckDecommissionCondition();
virtual bool CheckDecommissionCondition();

#pragma cyclus clone
#pragma cyclus initfromcopy
Expand Down
59 changes: 59 additions & 0 deletions src/separations_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,64 @@ TEST(SeparationsTests, SepMixElemAndNuclide) {
EXPECT_DOUBLE_EQ(0, mq.mass("Pu240"));
}

TEST(SeparationsTests, Retire) {
std::string config =
"<streams>"
" <item>"
" <commod>stream1</commod>"
" <info>"
" <buf_size>-1</buf_size>"
" <efficiencies>"
" <item><comp>U235</comp> <eff>1.0</eff></item>"
" </efficiencies>"
" </info>"
" </item>"
"</streams>"
""
"<leftover_commod>waste</leftover_commod>"
"<throughput>100</throughput>"
"<feedbuf_size>100</feedbuf_size>"
"<feed_commods> <val>feed</val> </feed_commods>"
;

CompMap m;
m[id("u235")] = 0.1;
m[id("u238")] = 0.9;
Composition::Ptr c = Composition::CreateFromMass(m);

int simdur = 5;
int life = 2;

cyclus::MockSim sim(cyclus::AgentSpec(":cycamore:Separations"),
config, simdur, life);
sim.AddSource("feed").recipe("recipe1").Finalize();
sim.AddSink("stream1").capacity(100).Finalize();
sim.AddSink("waste").capacity(70).Finalize();
sim.AddRecipe("recipe1", c);
int id = sim.Run();

// Separations should stop requesting material at its lifetime
// (it is smart enough to not request material on its last timestep because
// it knows it won't be able to process it)
std::vector<Cond> conds;
conds.push_back(Cond("ReceiverId", "==", id));
QueryResult qr = sim.db().Query("Transactions", &conds);
EXPECT_EQ(life - 1, qr.rows.size())
<< "failed to stop ordering near retirement";

// Separations should discharge all material before decomissioning
conds.clear();
conds.push_back(Cond("SenderId", "==", id));
qr = sim.db().Query("Transactions", &conds);
double tot_mat = 0;
for (int i = 0; i < qr.rows.size(); i++) {
cyclus::Material::Ptr m = sim.GetMaterial(qr.GetVal<int>("ResourceId", i));
tot_mat += m->quantity();
}
EXPECT_EQ(100, tot_mat)
<< "total material traded away does not equal total material separated";
EXPECT_EQ(3.0, qr.rows.size())
<< "failed to discharge all material before decomissioning";
}
} // namespace cycamore

0 comments on commit fee222d

Please sign in to comment.