58 " <feed_commod>natu</feed_commod> "
59 " <feed_recipe>natu1</feed_recipe> "
60 " <product_commod>enr_u</product_commod> "
61 " <tails_commod>tails</tails_commod> "
62 " <max_feed_inventory>1.0</max_feed_inventory> "
63 " <tails_assay>0.003</tails_assay> ";
66 cyclus::MockSim sim(cyclus::AgentSpec
67 (
":cycamore:Enrichment"), config, simdur);
68 sim.AddRecipe(
"natu1",
c_natu1());
76 std::vector<Cond> conds;
77 conds.push_back(Cond(
"Commodity",
"==", std::string(
"natu")));
78 QueryResult qr = sim.db().Query(
"Transactions", &conds);
79 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
83 EXPECT_EQ(1.0, qr.rows.size());
84 EXPECT_NEAR(1.0, m->quantity(), cyclus::CY_NEAR_ZERO) <<
85 "matched trade provides the wrong quantity of material";
96 " <feed_commod>natu</feed_commod> "
97 " <feed_recipe>natu1</feed_recipe> "
98 " <product_commod>enr_u</product_commod> "
99 " <tails_commod>tails</tails_commod> "
100 " <tails_assay>0.003</tails_assay> "
101 " <initial_feed>1000</initial_feed> "
102 " <swu_capacity>195</swu_capacity> ";
106 cyclus::MockSim sim(cyclus::AgentSpec
107 (
":cycamore:Enrichment"), config, simdur);
109 sim.AddRecipe(
"natu1",
c_natu1());
110 sim.AddRecipe(
"heu",
c_heu());
119 std::vector<Cond> conds;
120 conds.push_back(Cond(
"Commodity",
"==", std::string(
"enr_u")));
121 QueryResult qr = sim.db().Query(
"Transactions", &conds);
122 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
124 EXPECT_EQ(1.0, qr.rows.size());
125 EXPECT_NEAR(5.0, m->quantity(), 0.1) <<
126 "traded quantity exceeds SWU constraint";
135 " <feed_commod>natu</feed_commod> "
136 " <feed_recipe>natu1</feed_recipe> "
137 " <product_commod>enr_u</product_commod> "
138 " <tails_commod>tails</tails_commod> "
139 " <tails_assay>0.003</tails_assay> "
140 " <initial_feed>243</initial_feed> ";
144 cyclus::MockSim sim(cyclus::AgentSpec
145 (
":cycamore:Enrichment"), config, simdur);
148 sim.AddRecipe(
"natu1",
c_natu1());
149 sim.AddRecipe(
"heu",
c_heu());
158 std::vector<Cond> conds;
159 conds.push_back(Cond(
"Commodity",
"==", std::string(
"enr_u")));
160 QueryResult qr = sim.db().Query(
"Transactions", &conds);
161 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
163 EXPECT_EQ(1.0, qr.rows.size());
164 EXPECT_LE(m->quantity(), 5.0) <<
165 "traded quantity exceeds capacity constraint";
174 " <feed_commod>natu</feed_commod> "
175 " <feed_recipe>natu1</feed_recipe> "
176 " <product_commod>enr_u</product_commod> "
177 " <tails_commod>tails</tails_commod> "
178 " <tails_assay>0.003</tails_assay> "
179 " <max_enrich>0.19</max_enrich> ";
182 cyclus::MockSim sim(cyclus::AgentSpec
183 (
":cycamore:Enrichment"), config, simdur);
184 sim.AddRecipe(
"natu1",
c_natu1());
185 sim.AddRecipe(
"leu",
c_leu());
186 sim.AddRecipe(
"heu",
c_heu());
188 sim.AddSource(
"natu")
201 std::vector<Cond> conds;
202 conds.push_back(Cond(
"Commodity",
"==", std::string(
"enr_u")));
203 QueryResult qr = sim.db().Query(
"Transactions", &conds);
204 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
208 EXPECT_EQ(1.0, qr.rows.size());
209 EXPECT_NEAR(1.0, m->quantity(), 0.01) <<
210 "Not providing the requested quantity" ;
212 CompMap got = m->comp()->mass();
213 CompMap want =
c_leu()->mass();
214 cyclus::compmath::Normalize(&got);
215 cyclus::compmath::Normalize(&want);
217 CompMap::iterator it;
218 for (it = want.begin(); it != want.end(); ++it) {
219 EXPECT_DOUBLE_EQ(it->second, got[it->first]) <<
220 "nuclide qty off: " << pyne::nucname::name(it->first);
267 " <feed_commod>natu</feed_commod> "
268 " <feed_recipe>natu1</feed_recipe> "
269 " <product_commod>enr_u</product_commod> "
270 " <tails_commod>tails</tails_commod> "
271 " <tails_assay>0.003</tails_assay> ";
275 cyclus::MockSim sim(cyclus::AgentSpec
276 (
":cycamore:Enrichment"), config, simdur);
277 sim.AddRecipe(
"natu1",
c_natu1());
278 sim.AddRecipe(
"leu",
c_leu());
280 sim.AddSource(
"natu")
296 std::vector<Cond> conds;
297 conds.push_back(Cond(
"Commodity",
"==", std::string(
"tails")));
298 QueryResult qr = sim.db().Query(
"Transactions", &conds);
299 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
303 EXPECT_EQ(2, qr.rows.size());
305 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
306 "SELECT SUM(r.Quantity) FROM Transactions AS t"
307 " INNER JOIN Resources AS r ON r.ResourceId = t.ResourceId"
308 " WHERE t.Commodity = ?;"
311 stmt->BindText(1,
"tails");
313 EXPECT_NEAR(8.25,stmt->GetDouble(0), 0.01) <<
314 "Not providing the requested quantity" ;
323 " <feed_commod>natu</feed_commod> "
324 " <feed_recipe>natu1</feed_recipe> "
325 " <product_commod>enr_u</product_commod> "
326 " <tails_commod>tails</tails_commod> "
327 " <tails_assay>0.003</tails_assay> "
328 " <max_feed_inventory>1.0</max_feed_inventory> ";
331 cyclus::MockSim sim(cyclus::AgentSpec
332 (
":cycamore:Enrichment"), config, simdur);
333 sim.AddRecipe(
"natu1",
c_natu1());
334 sim.AddRecipe(
"natu2",
c_natu2());
336 sim.AddSource(
"natu")
341 sim.AddSource(
"natu")
348 std::vector<Cond> conds;
349 conds.push_back(Cond(
"Commodity",
"==", std::string(
"natu")));
350 QueryResult qr = sim.db().Query(
"Transactions", &conds);
353 EXPECT_EQ(1, qr.rows.size());
355 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
356 CompMap got = m->comp()->mass();
357 CompMap want =
c_natu2()->mass();
358 cyclus::compmath::Normalize(&got);
359 cyclus::compmath::Normalize(&want);
361 CompMap::iterator it;
362 for (it = want.begin(); it != want.end(); ++it) {
363 EXPECT_DOUBLE_EQ(it->second, got[it->first]) <<
364 "nuclide qty off: " << pyne::nucname::name(it->first);
523 double req = inv_size;
525 Material::Ptr mat = DoRequest();
526 EXPECT_DOUBLE_EQ(mat->quantity(), req);
527 EXPECT_EQ(mat->comp(), tc_.get()->GetRecipe(feed_recipe));
529 add = 2 * inv_size / 3;
531 DoAddMat(GetMat(add));
533 EXPECT_DOUBLE_EQ(mat->quantity(), req);
534 EXPECT_EQ(mat->comp(), tc_.get()->GetRecipe(feed_recipe));
538 DoAddMat(GetMat(add));
540 EXPECT_DOUBLE_EQ(mat->quantity(), req);
541 EXPECT_EQ(mat->comp(), tc_.get()->GetRecipe(feed_recipe));
547 using cyclus::Composition;
553 Material::Ptr mat = Material::CreateUntracked
554 (qty,Composition::CreateFromAtom(v1));
555 EXPECT_FALSE(src_facility->ValidReq(mat));
558 v2[922350000] = tails_assay;
559 v2[922380000] = 1 - tails_assay;
560 mat = Material::CreateUntracked(qty, Composition::CreateFromAtom(v2));
562 EXPECT_FALSE(src_facility->ValidReq(mat));
567 mat = Material::CreateUntracked(qty, Composition::CreateFromAtom(v3));
568 EXPECT_TRUE(src_facility->ValidReq(mat));
575 using cyclus::toolkit::MatQuery;
576 using cyclus::Composition;
578 cyclus::Env::SetNucDataPath();
581 double product_assay = 0.05;
583 v[922350000] = product_assay;
584 v[922380000] = 1 - product_assay;
586 Material::Ptr target = Material::CreateUntracked(
587 qty, Composition::CreateFromMass(v));
589 std::set<cyclus::Nuc> nucs;
590 nucs.insert(922350000);
591 nucs.insert(922380000);
594 double mass_frac = mq.mass_frac(nucs);
599 Material::Ptr offer = DoOffer(target);
601 EXPECT_NEAR(swuc.convert(target), swuc.convert(offer), 0.001);
602 EXPECT_NEAR(natuc.convert(target) * mass_frac, natuc.convert(offer), 0.001);
611 using cyclus::toolkit::MatQuery;
612 using cyclus::Composition;
613 using cyclus::toolkit::Assays;
614 using cyclus::toolkit::UraniumAssayMass;
615 using cyclus::toolkit::SwuRequired;
616 using cyclus::toolkit::FeedQty;
619 double product_assay = 0.05;
621 v[922350000] = product_assay;
622 v[922380000] = 1 - product_assay;
624 Material::Ptr target = Material::CreateUntracked(
625 qty + 10, Composition::CreateFromMass(v));
627 Assays assays(feed_assay, UraniumAssayMass(target), tails_assay);
628 double swu_req = SwuRequired(qty, assays);
629 double natu_req = FeedQty(qty, assays);
630 double tails_qty = TailsQty(qty, assays);
632 double swu_cap = swu_req * 5;
633 src_facility->SwuCapacity(swu_cap);
634 src_facility->SetMaxInventorySize(natu_req);
635 DoAddMat(GetMat(natu_req / 2));
636 DoAddMat(GetMat(natu_req / 2));
638 Material::Ptr response;
639 EXPECT_NO_THROW(response = DoEnrich(target, qty));
640 EXPECT_DOUBLE_EQ(src_facility->Tails().quantity(), tails_qty);
642 MatQuery q(response);
643 EXPECT_EQ(response->quantity(), qty);
644 EXPECT_EQ(q.mass_frac(922350000), product_assay);
645 EXPECT_EQ(q.mass_frac(922380000), 1 - product_assay);
648 DoAddMat(GetMat(natu_req - 1));
649 EXPECT_THROW(response = DoEnrich(target, qty), cyclus::Error);
662 using cyclus::Request;
664 using cyclus::toolkit::Assays;
665 using cyclus::toolkit::FeedQty;
666 using cyclus::toolkit::SwuRequired;
667 using cyclus::toolkit::UraniumAssayMass;
670 std::vector< Trade<Material> > trades;
671 std::vector<std::pair<Trade<Material>,
672 Material::Ptr> > responses;
675 double trade_qty = qty / 3;
676 double product_assay = 0.05;
679 v[922350000] = product_assay;
680 v[922380000] = 1 - product_assay;
682 Material::Ptr target = Material::CreateUntracked(
683 qty + 10, cyclus::Composition::CreateFromMass(v));
685 Assays assays(feed_assay, UraniumAssayMass(target), tails_assay);
686 double swu_req = SwuRequired(qty, assays);
687 double natu_req = FeedQty(qty, assays);
689 src_facility->SetMaxInventorySize(natu_req * 4);
690 src_facility->SwuCapacity(swu_req);
692 src_facility->GetMatlTrades(trades, responses);
695 DoAddMat(GetMat(natu_req * 2));
697 src_facility->GetMatlTrades(trades, responses);
699 Request<Material>* req =
700 Request<Material>::Create(target, trader, product_commod);
701 Bid<Material>* bid = Bid<Material>::Create(req, target, src_facility);
702 Trade<Material> trade(req, bid, trade_qty);
703 trades.push_back(trade);
706 ASSERT_GT(src_facility->SwuCapacity() - 2 * swu_req / 3,
708 trades.push_back(trade);
710 EXPECT_NO_THROW(src_facility->GetMatlTrades(trades, responses));
711 EXPECT_EQ(responses.size(), 2);