Skip to content

Commit

Permalink
bug fix and transport test
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearkatie committed Jul 16, 2024
1 parent 4ab9742 commit ba3e22a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Since last release

**Added:**
* Added package parameter to storage (#603, #612)
* Added package parameter to source (#613)

**Changed:**

Expand Down
3 changes: 1 addition & 2 deletions src/source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr> Source::GetMatlBids(
std::vector<double> bids;
bids.assign(n_full_bids, bid_qty);

double remaining_qty = std::fmod(qty, bid_qty);
double remaining_qty = qty - (n_full_bids * bid_qty);
if ((remaining_qty > cyclus::eps()) && (remaining_qty >= context()->GetPackage(package)->fill_min())) {
bids.push_back(remaining_qty);
}
Expand Down Expand Up @@ -165,7 +165,6 @@ void Source::GetMatlTrades(
// If not all material is packaged successfully, return the excess
// amount to the inventory
inventory.Push(m);
//inventory_size += m->quantity();
}

Material::Ptr response;
Expand Down
39 changes: 35 additions & 4 deletions src/source_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ TEST_F(SourceTest, Package) {

sim.context()->AddPackage(package_name, 3, 4, "first");
package = sim.context()->GetPackage(package_name);
// sim.context()->AddTransportUnit(tu_name, 1, 2, "hybrid");
// tu = sim.context()->GetTransportUnit(tu_name);

sim.AddSink("commod").Finalize();

Expand All @@ -186,8 +184,41 @@ TEST_F(SourceTest, Package) {
conds.push_back(Cond("PackageName", "==", package->name()));
QueryResult qr_res = sim.db().Query("Resources", &conds);

EXPECT_EQ(qr_res.rows.size(), 3);

EXPECT_EQ(qr_res.rows.size(), 3);
}

TEST_F(SourceTest, TransportUnit) {
using cyclus::QueryResult;
using cyclus::Cond;

std::string config =
"<outcommod>commod</outcommod>"
"<package>testpackage</package>"
"<transport_unit>testtu</transport_unit>"
"<throughput>10</throughput>";

int simdur = 2;
cyclus::MockSim sim(cyclus::AgentSpec (":cycamore:Source"), config, simdur);

sim.context()->AddPackage(package_name, 3, 4, "equal");
package = sim.context()->GetPackage(package_name);
sim.context()->AddTransportUnit(tu_name, 2, 2);
tu = sim.context()->GetTransportUnit(tu_name);

sim.AddSink("commod").Finalize();

EXPECT_NO_THROW(sim.Run());

QueryResult qr_tr = sim.db().Query("Transactions", NULL);
EXPECT_EQ(qr_tr.rows.size(), 4);

std::vector<Cond> conds;
conds.push_back(Cond("PackageName", "==", package->name()));
QueryResult qr_res = sim.db().Query("Resources", &conds);

EXPECT_EQ(qr_res.rows.size(), 4);

QueryResult qr_allres = sim.db().Query("Resources", NULL);
}

boost::shared_ptr< cyclus::ExchangeContext<cyclus::Material> >
Expand Down

0 comments on commit ba3e22a

Please sign in to comment.