74 cyclus::Env::SetNucDataPath();
77 Composition::Ptr c = Composition::CreateFromMass(m);
79 EXPECT_DOUBLE_EQ(1.0, w);
83 c = Composition::CreateFromMass(m);
85 EXPECT_DOUBLE_EQ(0.0, w);
89 c = Composition::CreateFromMass(m);
91 EXPECT_DOUBLE_EQ(1.0, w);
95 c = Composition::CreateFromMass(m);
97 EXPECT_DOUBLE_EQ(0.0, w);
102 c = Composition::CreateFromAtom(m);
104 EXPECT_DOUBLE_EQ(0.5, w) <<
"might be using mass-fractions instead of atom";
109 c = Composition::CreateFromAtom(m);
111 EXPECT_DOUBLE_EQ(0.5, w) <<
"might be using mass-fractions instead of atom";
117 c = Composition::CreateFromAtom(m);
119 double w_fast =
CosiWeight(c,
"fission_spectrum_ave");
120 EXPECT_GT(w_therm, w_fast);
123TEST(FuelFabTests, CosiWeight_Mixed) {
124 cyclus::Env::SetNucDataPath();
129 double fiss_frac =
HighFrac(w_fill, w_target, w_fiss);
130 double fill_frac =
LowFrac(w_fill, w_target, w_fiss);
136 Material::Ptr m1 = Material::CreateUntracked(fiss_frac,
c_pustream());
137 Material::Ptr m2 = Material::CreateUntracked(fill_frac,
c_natu());
139 double got =
CosiWeight(m1->comp(),
"thermal");
140 EXPECT_LT(std::abs((w_target-got)/w_target), 0.00001) <<
"mixed composition not within 0.001% of target";
144 cyclus::Env::SetNucDataPath();
149 EXPECT_THROW(
HighFrac(w_fiss, w_target, w_fill), cyclus::ValueError);
150 EXPECT_THROW(
HighFrac(w_target, w_fill, w_fiss), cyclus::ValueError);
151 EXPECT_THROW(
HighFrac(w_target, w_fiss, w_fill), cyclus::ValueError);
153 double f =
HighFrac(w_fill, w_target, w_fiss);
154 EXPECT_DOUBLE_EQ((w_target-w_fill)/(w_fiss-w_fill), f);
158 cyclus::Env::SetNucDataPath();
163 EXPECT_THROW(
LowFrac(w_fiss, w_target, w_fill), cyclus::ValueError);
164 EXPECT_THROW(
LowFrac(w_target, w_fill, w_fiss), cyclus::ValueError);
165 EXPECT_THROW(
LowFrac(w_target, w_fiss, w_fill), cyclus::ValueError);
167 double f =
LowFrac(w_fill, w_target, w_fiss);
168 EXPECT_DOUBLE_EQ((w_fiss-w_target)/(w_fiss-w_fill), f);
172 cyclus::Env::SetNucDataPath();
177 EXPECT_EQ(
true,
ValidWeights(w_fill, w_target, w_fiss));
178 EXPECT_EQ(
false,
ValidWeights(w_fiss, w_target, w_fill));
179 EXPECT_EQ(
false,
ValidWeights(w_target, w_fill, w_fiss));
180 EXPECT_EQ(
false,
ValidWeights(w_fiss, w_fill, w_target));
181 EXPECT_EQ(
false,
ValidWeights(w_target, w_fiss, w_fill));
182 EXPECT_EQ(
false,
ValidWeights(w_fill, w_fiss, w_target));
186TEST(FuelFabTests, FissRecipe) {
188 "<fill_commods> <val>dummy</val> </fill_commods>"
189 "<fill_recipe>natu</fill_recipe>"
190 "<fill_size>1</fill_size>"
192 "<fiss_commods> <val>stream1</val> <val>stream2</val> <val>stream3</val> </fiss_commods>"
193 "<fiss_size>2.5</fiss_size>"
194 "<fiss_recipe>spentuox</fiss_recipe>"
196 "<outcommod>dummyout</outcommod>"
197 "<spectrum>thermal</spectrum>"
198 "<throughput>0</throughput>"
202 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
203 sim.AddSource(
"stream1").Finalize();
205 sim.AddRecipe(
"natu",
c_natu());
208 int resid = sim.db().Query(
"Transactions", NULL).GetVal<
int>(
"ResourceId");
209 CompMap got = sim.GetMaterial(resid)->comp()->mass();
211 cyclus::compmath::Normalize(&got);
212 cyclus::compmath::Normalize(&want);
213 CompMap::iterator it;
214 for (it = want.begin(); it != want.end(); ++it) {
215 EXPECT_DOUBLE_EQ(it->second, got[it->first]) <<
"nuclide qty off: " << pyne::nucname::name(it->first);
221TEST(FuelFabTests, MultipleFissStreams) {
223 "<fill_commods> <val>dummy</val> </fill_commods>"
224 "<fill_recipe>natu</fill_recipe>"
225 "<fill_size>1</fill_size>"
227 "<fiss_commods> <val>stream1</val> <val>stream2</val> <val>stream3</val> </fiss_commods>"
228 "<fiss_size>2.5</fiss_size>"
230 "<outcommod>dummyout</outcommod>"
231 "<spectrum>thermal</spectrum>"
232 "<throughput>0</throughput>"
236 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
237 sim.AddSource(
"stream1").recipe(
"spentuox").capacity(1).Finalize();
238 sim.AddSource(
"stream2").recipe(
"spentuox").capacity(1).Finalize();
239 sim.AddSource(
"stream3").recipe(
"spentuox").capacity(1).Finalize();
241 sim.AddRecipe(
"natu",
c_natu());
244 QueryResult qr = sim.db().Query(
"Transactions", NULL);
245 EXPECT_EQ(3, qr.rows.size());
247 std::vector<Cond> conds;
248 conds.push_back(Cond(
"Commodity",
"==", std::string(
"stream1")));
249 qr = sim.db().Query(
"Transactions", &conds);
250 EXPECT_EQ(1, qr.rows.size());
252 conds[0] = Cond(
"Commodity",
"==", std::string(
"stream2"));
253 qr = sim.db().Query(
"Transactions", &conds);
254 EXPECT_EQ(1, qr.rows.size());
256 conds[0] = Cond(
"Commodity",
"==", std::string(
"stream3"));
257 qr = sim.db().Query(
"Transactions", &conds);
258 EXPECT_EQ(1, qr.rows.size());
262TEST(FuelFabTests, FissStreamPrefs) {
264 "<fill_commods> <val>dummy</val> </fill_commods>"
265 "<fill_recipe>natu</fill_recipe>"
266 "<fill_size>1</fill_size>"
268 "<fiss_commods> <val>stream1</val> <val>stream2</val> <val>stream3</val> </fiss_commods>"
269 "<fiss_commod_prefs> <val>1.0</val> <val>0.1</val> <val>2.0</val> </fiss_commod_prefs>"
270 "<fiss_size>1.5</fiss_size>"
272 "<outcommod>dummyout</outcommod>"
273 "<spectrum>thermal</spectrum>"
274 "<throughput>0</throughput>"
278 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
279 sim.AddSource(
"stream1").recipe(
"spentuox").capacity(1).Finalize();
280 sim.AddSource(
"stream2").recipe(
"spentuox").capacity(1).Finalize();
281 sim.AddSource(
"stream3").recipe(
"spentuox").capacity(1).Finalize();
283 sim.AddRecipe(
"natu",
c_natu());
286 std::vector<Cond> conds;
287 conds.push_back(Cond(
"Commodity",
"==", std::string(
"stream1")));
288 QueryResult qr = sim.db().Query(
"Transactions", &conds);
289 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
290 EXPECT_DOUBLE_EQ(0.5, m->quantity());
292 conds[0] = Cond(
"Commodity",
"==", std::string(
"stream2"));
293 qr = sim.db().Query(
"Transactions", &conds);
294 EXPECT_EQ(0, qr.rows.size());
296 conds[0] = Cond(
"Commodity",
"==", std::string(
"stream3"));
297 qr = sim.db().Query(
"Transactions", &conds);
298 m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
299 EXPECT_DOUBLE_EQ(1.0, m->quantity());
303TEST(FuelFabTests, ZeroThroughput) {
305 "<fill_commods> <val>natu</val> </fill_commods>"
306 "<fill_recipe>natu</fill_recipe>"
307 "<fill_size>3.9</fill_size>"
309 "<fiss_commods> <val>spentuox</val> </fiss_commods>"
310 "<fiss_recipe>spentuox</fiss_recipe>"
311 "<fiss_size>3.5</fiss_size>"
313 "<topup_commod>uox</topup_commod>"
314 "<topup_recipe>uox</topup_recipe>"
315 "<topup_size>3.3</topup_size>"
317 "<outcommod>dummyout</outcommod>"
318 "<spectrum>thermal</spectrum>"
319 "<throughput>0</throughput>"
323 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
324 sim.AddSource(
"uox").capacity(1).Finalize();
325 sim.AddSource(
"spentuox").capacity(1).Finalize();
326 sim.AddSource(
"natu").capacity(1).Finalize();
327 sim.AddRecipe(
"uox",
c_uox());
329 sim.AddRecipe(
"natu",
c_natu());
330 EXPECT_NO_THROW(sim.Run());
336TEST(FuelFabTests, FillAllInventories) {
338 "<fill_commods> <val>natu</val> </fill_commods>"
339 "<fill_recipe>natu</fill_recipe>"
340 "<fill_size>3.9</fill_size>"
342 "<fiss_commods> <val>spentuox</val> </fiss_commods>"
343 "<fiss_recipe>spentuox</fiss_recipe>"
344 "<fiss_size>3.5</fiss_size>"
346 "<topup_commod>uox</topup_commod>"
347 "<topup_recipe>uox</topup_recipe>"
348 "<topup_size>3.3</topup_size>"
350 "<outcommod>dummyout</outcommod>"
351 "<spectrum>thermal</spectrum>"
352 "<throughput>1</throughput>"
356 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
357 sim.AddSource(
"uox").capacity(1).Finalize();
358 sim.AddSource(
"spentuox").capacity(1).Finalize();
359 sim.AddSource(
"natu").capacity(1).Finalize();
360 sim.AddRecipe(
"uox",
c_uox());
362 sim.AddRecipe(
"natu",
c_natu());
365 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
366 "SELECT SUM(r.Quantity) FROM Transactions AS t"
367 " INNER JOIN Resources AS r ON r.ResourceId = t.ResourceId"
368 " WHERE t.Commodity = ?;"
371 stmt->BindText(1,
"natu");
373 EXPECT_DOUBLE_EQ(3.9, stmt->GetDouble(0));
375 stmt->BindText(1,
"spentuox");
377 EXPECT_DOUBLE_EQ(3.5, stmt->GetDouble(0));
379 stmt->BindText(1,
"uox");
381 EXPECT_DOUBLE_EQ(3.3, stmt->GetDouble(0));
386TEST(FuelFabTests, ProvideStraightFiss_WithZeroFill) {
388 "<fill_commods> <val>nothing</val> </fill_commods>"
389 "<fill_recipe>natu</fill_recipe>"
390 "<fill_size>100</fill_size>"
392 "<fiss_commods> <val>anything</val> </fiss_commods>"
393 "<fiss_recipe>spentuox</fiss_recipe>"
394 "<fiss_size>100</fiss_size>"
396 "<outcommod>recyclefuel</outcommod>"
397 "<spectrum>thermal</spectrum>"
398 "<throughput>100</throughput>"
401 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
402 sim.AddSource(
"anything").Finalize();
403 sim.AddSink(
"recyclefuel").recipe(
"spentuox").capacity(100).Finalize();
404 sim.AddRecipe(
"uox",
c_uox());
406 sim.AddRecipe(
"natu",
c_natu());
409 std::vector<Cond> conds;
410 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
411 QueryResult qr = sim.db().Query(
"Transactions", NULL);
413 EXPECT_EQ(6, qr.rows.size());
416TEST(FuelFabTests, ProvideStraightFill_ZeroFiss) {
418 "<fill_commods> <val>anything</val> </fill_commods>"
419 "<fill_recipe>natu</fill_recipe>"
420 "<fill_size>100</fill_size>"
422 "<fiss_commods> <val>nothing</val> </fiss_commods>"
423 "<fiss_recipe>spentuox</fiss_recipe>"
424 "<fiss_size>100</fiss_size>"
426 "<outcommod>recyclefuel</outcommod>"
427 "<spectrum>thermal</spectrum>"
428 "<throughput>100</throughput>"
431 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
432 sim.AddSource(
"anything").Finalize();
433 sim.AddSink(
"recyclefuel").recipe(
"natu").capacity(100).Finalize();
434 sim.AddRecipe(
"uox",
c_uox());
436 sim.AddRecipe(
"natu",
c_natu());
439 std::vector<Cond> conds;
440 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
441 QueryResult qr = sim.db().Query(
"Transactions", NULL);
443 EXPECT_EQ(6, qr.rows.size());
448TEST(FuelFabTests, ThroughputLimit) {
450 "<fill_commods> <val>anything</val> </fill_commods>"
451 "<fill_recipe>natu</fill_recipe>"
452 "<fill_size>100</fill_size>"
454 "<fiss_commods> <val>anything</val> </fiss_commods>"
455 "<fiss_recipe>pustream</fiss_recipe>"
456 "<fiss_size>100</fiss_size>"
458 "<outcommod>recyclefuel</outcommod>"
459 "<spectrum>thermal</spectrum>"
460 "<throughput>3</throughput>"
462 double throughput = 3;
465 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
466 sim.AddSource(
"anything").lifetime(1).Finalize();
467 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2*throughput).Finalize();
468 sim.AddRecipe(
"uox",
c_uox());
470 sim.AddRecipe(
"natu",
c_natu());
473 QueryResult qr = sim.db().Query(
"Transactions", NULL);
474 EXPECT_LT(2, qr.rows.size());
476 cyclus::SqlStatement::Ptr stmt = sim.db().db().Prepare(
477 "SELECT SUM(r.Quantity) FROM Transactions AS t"
478 " INNER JOIN Resources AS r ON r.ResourceId = t.ResourceId"
479 " WHERE t.Commodity = 'recyclefuel';"
483 EXPECT_DOUBLE_EQ(throughput * (simdur-1), stmt->GetDouble(0));
485 stmt = sim.db().db().Prepare(
486 "SELECT COUNT(*) FROM Transactions WHERE Commodity = 'recyclefuel';"
490 EXPECT_DOUBLE_EQ(simdur-1, stmt->GetDouble(0));
494TEST(FuelFabTests, CorrectMixing) {
496 "<fill_commods> <val>natu</val> </fill_commods>"
497 "<fill_recipe>natu</fill_recipe>"
498 "<fill_size>100</fill_size>"
500 "<fiss_commods> <val>pustream</val> </fiss_commods>"
501 "<fiss_recipe>pustream</fiss_recipe>"
502 "<fiss_size>100</fiss_size>"
504 "<outcommod>recyclefuel</outcommod>"
505 "<spectrum>thermal</spectrum>"
506 "<throughput>100</throughput>"
509 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
510 sim.AddSource(
"pustream").Finalize();
511 sim.AddSource(
"natu").Finalize();
512 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(10).lifetime(2).Finalize();
513 sim.AddRecipe(
"uox",
c_uox());
515 sim.AddRecipe(
"natu",
c_natu());
518 std::vector<Cond> conds;
519 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
520 QueryResult qr = sim.db().Query(
"Transactions", &conds);
521 EXPECT_EQ(1, qr.rows.size());
523 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
524 double got =
CosiWeight(m->comp(),
"thermal");
526 EXPECT_LT(std::abs((w_target-got)/w_target), 0.00001) <<
"mixed composition not within 0.001% of target";
528 conds.push_back(Cond(
"Time",
"==", 2));
531 conds[0] = Cond(
"Commodity",
"==", std::string(
"natu"));
532 qr = sim.db().Query(
"Transactions", &conds);
533 m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
534 EXPECT_NEAR(9.7463873197, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"mixed wrong amount of Nat. U stream";
536 conds[0] = Cond(
"Commodity",
"==", std::string(
"pustream"));
537 qr = sim.db().Query(
"Transactions", &conds);
538 m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
539 EXPECT_NEAR(0.25361268029, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"mixed wrong amount of Pu stream";
544TEST(FuelFabTests, FillConstrained) {
545 cyclus::Env::SetNucDataPath();
547 "<fill_commods> <val>natu</val> </fill_commods>"
548 "<fill_recipe>natu</fill_recipe>"
549 "<fill_size>1</fill_size>"
551 "<fiss_commods> <val>pustream</val> </fiss_commods>"
552 "<fiss_recipe>pustream</fiss_recipe>"
553 "<fiss_size>10000</fiss_size>"
555 "<outcommod>recyclefuel</outcommod>"
556 "<spectrum>thermal</spectrum>"
557 "<throughput>10000</throughput>"
565 double fiss_frac =
HighFrac(w_fill, w_target, w_fiss);
566 double fill_frac =
LowFrac(w_fill, w_target, w_fiss);
569 double max_provide = fillinv / fill_frac;
571 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
572 sim.AddSource(
"pustream").lifetime(1).Finalize();
573 sim.AddSource(
"natu").lifetime(1).Finalize();
574 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
575 sim.AddRecipe(
"uox",
c_uox());
577 sim.AddRecipe(
"natu",
c_natu());
580 std::vector<Cond> conds;
581 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
582 QueryResult qr = sim.db().Query(
"Transactions", &conds);
583 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
585 EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"matched trade uses more fill than available";
590TEST(FuelFabTests, FissConstrained) {
591 cyclus::Env::SetNucDataPath();
593 "<fill_commods> <val>natu</val> </fill_commods>"
594 "<fill_recipe>natu</fill_recipe>"
595 "<fill_size>10000</fill_size>"
597 "<fiss_commods> <val>pustream</val> </fiss_commods>"
598 "<fiss_recipe>pustream</fiss_recipe>"
599 "<fiss_size>1</fiss_size>"
601 "<outcommod>recyclefuel</outcommod>"
602 "<spectrum>thermal</spectrum>"
603 "<throughput>10000</throughput>"
611 double fiss_frac =
HighFrac(w_fill, w_target, w_fiss);
612 double fill_frac =
LowFrac(w_fill, w_target, w_fiss);
615 double max_provide = fissinv / fiss_frac;
617 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
618 sim.AddSource(
"pustream").lifetime(1).Finalize();
619 sim.AddSource(
"natu").lifetime(1).Finalize();
620 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
621 sim.AddRecipe(
"uox",
c_uox());
623 sim.AddRecipe(
"natu",
c_natu());
626 std::vector<Cond> conds;
627 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
628 QueryResult qr = sim.db().Query(
"Transactions", &conds);
629 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
631 EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"matched trade uses more fill than available";
637 "<fill_commods> <val>natu</val> </fill_commods>"
638 "<fill_recipe>natu</fill_recipe>"
639 "<fill_size>10000</fill_size>"
641 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
642 "<fiss_recipe>pustreambad</fiss_recipe>"
643 "<fiss_size>10000</fiss_size>"
645 "<topup_commod>pustream</topup_commod>"
646 "<topup_recipe>pustream</topup_recipe>"
647 "<topup_size>10000</topup_size>"
649 "<outcommod>recyclefuel</outcommod>"
650 "<spectrum>thermal</spectrum>"
651 "<throughput>10000</throughput>"
654 double sink_cap = 10;
656 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
657 sim.AddSource(
"pustream").Finalize();
658 sim.AddSource(
"pustreambad").Finalize();
659 sim.AddSource(
"natu").Finalize();
660 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(sink_cap).lifetime(2).Finalize();
661 sim.AddRecipe(
"uox",
c_uox());
664 sim.AddRecipe(
"natu",
c_natu());
667 std::vector<Cond> conds;
668 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
669 QueryResult qr = sim.db().Query(
"Transactions", &conds);
670 ASSERT_EQ(1, qr.rows.size()) <<
"failed to meet fuel request";
671 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
672 EXPECT_NEAR(sink_cap, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"supplied fuel was constrained too much";
674 conds[0] = Cond(
"Commodity",
"==", std::string(
"natu"));
675 conds.push_back(Cond(
"Time",
"==", 2));
676 qr = sim.db().Query(
"Transactions", &conds);
677 ASSERT_EQ(0, qr.rows.size()) <<
"failed to swith to topup - used fill - uh oh";
679 conds[0] = Cond(
"Commodity",
"==", std::string(
"pustream"));
680 conds.push_back(Cond(
"Time",
"==", 2));
681 qr = sim.db().Query(
"Transactions", &conds);
682 ASSERT_EQ(1, qr.rows.size()) <<
"didn't get more topup after supposedly using it - why?";
685TEST(FuelFabTests, SwapTopup_ZeroFill) {
687 "<fill_commods> <val>natu</val> </fill_commods>"
688 "<fill_recipe>natu</fill_recipe>"
689 "<fill_size>0</fill_size>"
691 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
692 "<fiss_recipe>pustreambad</fiss_recipe>"
693 "<fiss_size>10000</fiss_size>"
695 "<topup_commod>pustream</topup_commod>"
696 "<topup_recipe>pustream</topup_recipe>"
697 "<topup_size>10000</topup_size>"
699 "<outcommod>recyclefuel</outcommod>"
700 "<spectrum>thermal</spectrum>"
701 "<throughput>10000</throughput>"
704 double sink_cap = 10;
706 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
707 sim.AddSource(
"pustream").Finalize();
708 sim.AddSource(
"pustreambad").Finalize();
709 sim.AddSource(
"natu").Finalize();
710 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(sink_cap).lifetime(2).Finalize();
711 sim.AddRecipe(
"uox",
c_uox());
714 sim.AddRecipe(
"natu",
c_natu());
717 std::vector<Cond> conds;
718 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
719 QueryResult qr = sim.db().Query(
"Transactions", &conds);
720 ASSERT_EQ(1, qr.rows.size()) <<
"failed to meet fuel request";
721 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
722 EXPECT_NEAR(sink_cap, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"supplied fuel was constrained too much";
724 conds[0] = Cond(
"Commodity",
"==", std::string(
"pustream"));
725 conds.push_back(Cond(
"Time",
"==", 2));
726 qr = sim.db().Query(
"Transactions", &conds);
727 ASSERT_EQ(1, qr.rows.size()) <<
"failed to use topup - why?";
729 conds[0] = Cond(
"Commodity",
"==", std::string(
"pustreambad"));
730 conds.push_back(Cond(
"Time",
"==", 2));
731 qr = sim.db().Query(
"Transactions", &conds);
732 ASSERT_EQ(1, qr.rows.size()) <<
"failed to use fiss - why?";
740TEST(FuelFabTests, SwapTopup_TopupConstrained) {
741 cyclus::Env::SetNucDataPath();
743 "<fill_commods> <val>natu</val> </fill_commods>"
744 "<fill_recipe>natu</fill_recipe>"
745 "<fill_size>10000</fill_size>"
747 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
748 "<fiss_recipe>pustreambad</fiss_recipe>"
749 "<fiss_size>10000</fiss_size>"
751 "<topup_commod>pustream</topup_commod>"
752 "<topup_recipe>pustream</topup_recipe>"
753 "<topup_size>1</topup_size>"
755 "<outcommod>recyclefuel</outcommod>"
756 "<spectrum>thermal</spectrum>"
757 "<throughput>10000</throughput>"
766 double topup_frac =
HighFrac(w_fiss, w_target, w_topup);
767 double fiss_frac =
LowFrac(w_fiss, w_target, w_topup);
770 double max_provide = topupinv / topup_frac;
772 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
773 sim.AddSource(
"pustream").Finalize();
774 sim.AddSource(
"pustreambad").Finalize();
775 sim.AddSource(
"natu").Finalize();
776 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
777 sim.AddRecipe(
"uox",
c_uox());
780 sim.AddRecipe(
"natu",
c_natu());
783 std::vector<Cond> conds;
784 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
785 QueryResult qr = sim.db().Query(
"Transactions", &conds);
786 ASSERT_EQ(1, qr.rows.size()) <<
"failed to meet fuel request";
787 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
789 EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"matched trade uses more fiss than available";
795TEST(FuelFabTests, SwapTopup_FissConstrained) {
796 cyclus::Env::SetNucDataPath();
798 "<fill_commods> <val>natu</val> </fill_commods>"
799 "<fill_recipe>natu</fill_recipe>"
800 "<fill_size>0</fill_size>"
802 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
803 "<fiss_recipe>pustreambad</fiss_recipe>"
804 "<fiss_size>1</fiss_size>"
806 "<topup_commod>pustream</topup_commod>"
807 "<topup_recipe>pustream</topup_recipe>"
808 "<topup_size>10000</topup_size>"
810 "<outcommod>recyclefuel</outcommod>"
811 "<spectrum>thermal</spectrum>"
812 "<throughput>10000</throughput>"
821 double topup_frac =
HighFrac(w_fiss, w_target, w_topup);
822 double fiss_frac =
LowFrac(w_fiss, w_target, w_topup);
825 double max_provide = fissinv / fiss_frac;
827 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
828 sim.AddSource(
"pustream").Finalize();
829 sim.AddSource(
"pustreambad").Finalize();
830 sim.AddSource(
"natu").Finalize();
831 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
832 sim.AddRecipe(
"uox",
c_uox());
835 sim.AddRecipe(
"natu",
c_natu());
838 std::vector<Cond> conds;
839 conds.push_back(Cond(
"Commodity",
"==", std::string(
"recyclefuel")));
840 QueryResult qr = sim.db().Query(
"Transactions", &conds);
841 ASSERT_EQ(1, qr.rows.size()) <<
"failed to meet fuel request";
842 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId"));
844 EXPECT_NEAR(max_provide, m->quantity(), cyclus::CY_NEAR_ZERO) <<
"matched trade uses more fiss than available";
855TEST(FuelFabTests, HomogenousBuffers) {
857 "<fill_commods> <val>natu</val> </fill_commods>"
858 "<fill_recipe>natu</fill_recipe>"
859 "<fill_size>40</fill_size>"
861 "<fiss_commods> <val>stream1</val> </fiss_commods>"
862 "<fiss_size>4</fiss_size>"
863 "<fiss_recipe>spentuox</fiss_recipe>"
865 "<outcommod>out</outcommod>"
866 "<spectrum>thermal</spectrum>"
867 "<throughput>1e10</throughput>"
876 Composition::Ptr c = Composition::CreateFromMass(m);
879 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
880 sim.AddSource(
"stream1").start(0).lifetime(1).capacity(.01).recipe(
"special").Finalize();
881 sim.AddSource(
"stream1").start(1).lifetime(1).capacity(3.98).recipe(
"natu").Finalize();
882 sim.AddSource(
"natu").lifetime(1).Finalize();
883 sim.AddSink(
"out").start(2).capacity(4).lifetime(1).recipe(
"uox").Finalize();
884 sim.AddSink(
"out").start(2).capacity(4).lifetime(1).recipe(
"uox").Finalize();
885 sim.AddRecipe(
"uox",
c_uox());
887 sim.AddRecipe(
"natu",
c_natu());
888 sim.AddRecipe(
"special", c);
889 ASSERT_NO_THROW(sim.Run());
893TEST(FuelFabTests, PositionInitialize) {
894 cyclus::Env::SetNucDataPath();
896 "<fill_commods> <val>natu</val> </fill_commods>"
897 "<fill_recipe>natu</fill_recipe>"
898 "<fill_size>0</fill_size>"
900 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
901 "<fiss_recipe>pustreambad</fiss_recipe>"
902 "<fiss_size>1</fiss_size>"
904 "<topup_commod>pustream</topup_commod>"
905 "<topup_recipe>pustream</topup_recipe>"
906 "<topup_size>10000</topup_size>"
908 "<outcommod>recyclefuel</outcommod>"
909 "<spectrum>thermal</spectrum>"
910 "<throughput>10000</throughput>";
917 double fiss_frac =
HighFrac(w_fill, w_target, w_fiss);
918 double fill_frac =
LowFrac(w_fill, w_target, w_fiss);
921 double max_provide = fillinv / fill_frac;
923 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
924 sim.AddSource(
"pustream").Finalize();
925 sim.AddSource(
"pustreambad").Finalize();
926 sim.AddSource(
"natu").Finalize();
927 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
928 sim.AddRecipe(
"uox",
c_uox());
931 sim.AddRecipe(
"natu",
c_natu());
934 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
935 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 0.0);
936 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 0.0);
939TEST(FuelFabTests, PositionInitialize2) {
940 cyclus::Env::SetNucDataPath();
942 "<fill_commods> <val>natu</val> </fill_commods>"
943 "<fill_recipe>natu</fill_recipe>"
944 "<fill_size>0</fill_size>"
946 "<fiss_commods> <val>pustreambad</val> </fiss_commods>"
947 "<fiss_recipe>pustreambad</fiss_recipe>"
948 "<fiss_size>1</fiss_size>"
950 "<topup_commod>pustream</topup_commod>"
951 "<topup_recipe>pustream</topup_recipe>"
952 "<topup_size>10000</topup_size>"
954 "<outcommod>recyclefuel</outcommod>"
955 "<spectrum>thermal</spectrum>"
956 "<throughput>10000</throughput>"
957 "<latitude>-90.0</latitude> "
958 "<longitude>-120.0</longitude> "
966 double fiss_frac =
HighFrac(w_fill, w_target, w_fiss);
967 double fill_frac =
LowFrac(w_fill, w_target, w_fiss);
970 double max_provide = fillinv / fill_frac;
972 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:FuelFab"), config, simdur);
973 sim.AddSource(
"pustream").Finalize();
974 sim.AddSource(
"pustreambad").Finalize();
975 sim.AddSource(
"natu").Finalize();
976 sim.AddSink(
"recyclefuel").recipe(
"uox").capacity(2 * max_provide).Finalize();
977 sim.AddRecipe(
"uox",
c_uox());
980 sim.AddRecipe(
"natu",
c_natu());
983 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
984 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), -90.0);
985 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), -120.0);