1#include <gtest/gtest.h>
20 in_c1.push_back(
"in_c1");
21 out_c1.push_back(
"out_c1");
33 cyclus::Composition::Ptr recipe = cyclus::Composition::CreateFromAtom(v);
34 tc_.get()->AddRecipe(in_r1, recipe);
53 EXPECT_EQ(
in_r1, fac->in_recipe);
54 EXPECT_EQ(
package, fac->package);
58 cyclus::Material::Ptr mat){
59 double amt = mat->quantity();
60 double before = fac->inventory.quantity();
62 double after = fac->inventory.quantity();
63 EXPECT_EQ(amt, after - before);
67 double proc,
double ready,
double stocks){
68 double t =
tc_.get()->time();
70 EXPECT_EQ(inv, fac->inventory.quantity());
71 EXPECT_EQ(proc, fac->processing.quantity());
72 EXPECT_EQ(stocks, fac->stocks.quantity());
73 EXPECT_EQ(ready, fac->ready.quantity());
78 cyclus::toolkit::ResBuf<cyclus::Material>* buffer = &fac->stocks;
79 Material::Ptr final_mat = cyclus::ResCast<Material>(buffer->PopBack());
80 cyclus::CompMap final_comp = final_mat->comp()->atom();
81 EXPECT_EQ(final_comp,v);
87 EXPECT_EQ(inv, fac->current_capacity());
92 EXPECT_EQ(t, fac->ready_time());
96TEST_F(StorageTest, clone) {
103TEST_F(StorageTest, InitialState) {
109TEST_F(StorageTest, CurrentCapacity){
117TEST_F(StorageTest, Print) {
123TEST_F(StorageTest, AddMats) {
125 cyclus::Material::Ptr mat = cyclus::NewBlankMaterial(0.5*cap);
128 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
129 cyclus::Material::Ptr recmat = cyclus::Material::CreateUntracked(0.5*cap, rec);
134TEST_F(StorageTest, Tick) {
140TEST_F(StorageTest, Tock) {
146 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
147 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(cap, rec);
158 EXPECT_EQ(0,
tc_.get()->time());
179TEST_F(StorageTest, NoProcessTime) {
186 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
187 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(cap, rec);
199TEST_F(StorageTest, NoConvert) {
202 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
203 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(cap, rec);
212 cyclus::CompMap in_rec;
213 in_rec[922350000] = 1;
214 in_rec[922380000] = 2;
218TEST_F(StorageTest, MultipleSmallBatches) {
221 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
222 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(0.2*cap, rec);
235 cyclus::Material::Ptr mat1 = cyclus::Material::CreateUntracked(0.3*cap, rec);
255TEST_F(StorageTest, ChangeCapacity) {
262 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
263 cyclus::Material::Ptr mat1 = cyclus::Material::CreateUntracked(cap1, rec);
273 cyclus::Material::Ptr mat2 = cyclus::Material::CreateUntracked(cap2,rec);
278 cyclus::Material::Ptr mat3 = cyclus::Material::CreateUntracked(cap2,rec);
308TEST_F(StorageTest, TwoBatchSameTime) {
311 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
312 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(0.2*cap, rec);
317 cyclus::Material::Ptr mat1 = cyclus::Material::CreateUntracked(0.2*cap, rec);
330TEST_F(StorageTest,ChangeProcessTime){
334 cyclus::Composition::Ptr rec =
tc_.get()->GetRecipe(
in_r1);
335 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(cap, rec);
344 cyclus::Material::Ptr mat1 = cyclus::Material::CreateUntracked(cap,rec);
360 for(
int i=proc_time1; i < proc_time2 - 1; ++i){
367 tc_.get()->time(proc_time2);
377 tc_.get()->time(proc_time3 +8);
383TEST_F(StorageTest,DifferentRecipe){
389 cyclus::Composition::Ptr rec = cyclus::Composition::CreateFromAtom(v);
390 cyclus::Material::Ptr mat = cyclus::Material::CreateUntracked(cap, rec);
402TEST_F(StorageTest, BehaviorTest){
406 " <in_commods> <val>spent_fuel</val> </in_commods> "
407 " <out_commods> <val>dry_spent</val> </out_commods> "
408 " <residence_time>1</residence_time>"
409 " <max_inv_size>10</max_inv_size>";
413 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
415 sim.AddSource(
"spent_fuel").Finalize();
416 sim.AddSink(
"dry_spent").Finalize();
421 std::vector<cyclus::Cond> conds;
422 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"dry_spent")));
423 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
424 int n_trans = qr.rows.size();
425 EXPECT_EQ(1, n_trans) <<
"expected 1 transactions, got " << n_trans;
429TEST_F(StorageTest, MultipleCommods){
433 " <in_commods> <val>spent_fuel</val>"
434 " <val>spent_fuel2</val> </in_commods>"
435 " <in_commod_prefs> <val>1</val>"
436 " <val>1</val> </in_commod_prefs>"
437 " <out_commods> <val>dry_spent</val> </out_commods> "
438 " <max_inv_size>10</max_inv_size>";
442 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
444 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
445 sim.AddSource(
"spent_fuel2").capacity(5).Finalize();
446 sim.AddSink(
"dry_spent").Finalize();
451 std::vector<cyclus::Cond> conds;
452 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
453 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
454 int n_trans = qr.rows.size();
455 EXPECT_EQ(1, n_trans) <<
"expected 1 transactions, got " << n_trans;
457 std::vector<cyclus::Cond> conds2;
458 conds2.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel2")));
459 cyclus::QueryResult qr2 = sim.db().Query(
"Transactions", &conds2);
460 int n_trans2 = qr2.rows.size();
461 EXPECT_EQ(1, n_trans2) <<
"expected 1 transactions, got " << n_trans;
467TEST_F(StorageTest, ActiveDormant){
469 " <in_commods> <val>spent_fuel</val> </in_commods> "
470 " <out_commods> <val>dry_spent</val> </out_commods> "
471 " <throughput>1</throughput>"
472 " <active_buying_val>1</active_buying_val>"
473 " <dormant_buying_val>1</dormant_buying_val>";
477 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
479 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
480 sim.AddSink(
"dry_spent").Finalize();
485 std::vector<cyclus::Cond> conds;
486 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
487 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
488 int n_trans = qr.rows.size();
489 EXPECT_EQ(1, n_trans) <<
"expected 1 transactions, got " << n_trans;
494TEST_F(StorageTest, NoDormant){
496 " <in_commods> <val>spent_fuel</val> </in_commods> "
497 " <out_commods> <val>dry_spent</val> </out_commods> "
498 " <throughput>1</throughput>"
499 " <active_buying_frequency_type>Fixed</active_buying_frequency_type>"
500 " <active_buying_val>1</active_buying_val>"
501 " <dormant_buying_frequency_type>Fixed</dormant_buying_frequency_type>"
502 " <dormant_buying_val>-1</dormant_buying_val>";
506 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
508 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
509 sim.AddSink(
"dry_spent").Finalize();
513 std::vector<cyclus::Cond> conds;
514 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
515 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
516 int n_trans = qr.rows.size();
517 EXPECT_EQ(3, n_trans) <<
"expected 3 transactions, got " << n_trans;
520TEST_F(StorageTest, UniformActiveNormalDormant){
522 " <in_commods> <val>spent_fuel</val> </in_commods> "
523 " <out_commods> <val>dry_spent</val> </out_commods> "
524 " <throughput>1</throughput>"
525 " <active_buying_frequency_type>Uniform</active_buying_frequency_type>"
526 " <active_buying_min>2</active_buying_min>"
527 " <active_buying_max>3</active_buying_max>"
528 " <dormant_buying_frequency_type>Normal</dormant_buying_frequency_type>"
529 " <dormant_buying_mean>5</dormant_buying_mean>"
530 " <dormant_buying_stddev>1</dormant_buying_stddev>";
534 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
536 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
537 sim.AddSink(
"dry_spent").Finalize();
541 std::vector<cyclus::Cond> conds;
542 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
543 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
546 EXPECT_EQ(0, qr.GetVal<
int>(
"Time", 0));
547 EXPECT_EQ(1, qr.GetVal<
int>(
"Time", 1));
549 EXPECT_EQ(7, qr.GetVal<
int>(
"Time", 2));
550 EXPECT_EQ(8, qr.GetVal<
int>(
"Time", 3));
551 EXPECT_EQ(9, qr.GetVal<
int>(
"Time", 4));
554TEST_F(StorageTest, FixedBuyingSize){
556 " <in_commods> <val>spent_fuel</val> </in_commods> "
557 " <out_commods> <val>dry_spent</val> </out_commods> "
558 " <throughput>1</throughput>"
559 " <buying_size_type>Fixed</buying_size_type>"
560 " <buying_size_val>0.5</buying_size_val>";
564 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
566 sim.AddSource(
"spent_fuel").Finalize();
569 cyclus::QueryResult qr = sim.db().Query(
"Resources", NULL);
570 EXPECT_NEAR(0.5, qr.GetVal<
double>(
"Quantity", 0), 0.00001);
571 EXPECT_NEAR(0.5, qr.GetVal<
double>(
"Quantity", 1), 0.00001);
574TEST_F(StorageTest, UniformBuyingSize){
576 " <in_commods> <val>spent_fuel</val> </in_commods> "
577 " <out_commods> <val>dry_spent</val> </out_commods> "
578 " <throughput>1</throughput>"
579 " <buying_size_type>Uniform</buying_size_type>"
580 " <buying_size_min>0.5</buying_size_min>"
581 " <buying_size_max>0.7</buying_size_max>";
585 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
587 sim.AddSource(
"spent_fuel").Finalize();
590 cyclus::QueryResult qr = sim.db().Query(
"Resources", NULL);
591 EXPECT_NEAR(0.56393, qr.GetVal<
double>(
"Quantity", 0), 0.00001);
592 EXPECT_NEAR(0.68825, qr.GetVal<
double>(
"Quantity", 1), 0.00001);
595TEST_F(StorageTest, NormalBuyingSize){
597 " <in_commods> <val>spent_fuel</val> </in_commods> "
598 " <out_commods> <val>dry_spent</val> </out_commods> "
599 " <throughput>1</throughput>"
600 " <buying_size_type>Normal</buying_size_type>"
601 " <buying_size_mean>0.5</buying_size_mean>"
602 " <buying_size_stddev>0.1</buying_size_stddev>";
606 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
608 sim.AddSource(
"spent_fuel").Finalize();
612 cyclus::QueryResult qr = sim.db().Query(
"Resources", NULL);
613 EXPECT_NEAR(0.64083, qr.GetVal<
double>(
"Quantity", 0), 0.00001);
614 EXPECT_NEAR(0.32648, qr.GetVal<
double>(
"Quantity", 1), 0.00001);
617TEST_F(StorageTest, NormalActiveDormantBuyingSize){
619 " <in_commods> <val>spent_fuel</val> </in_commods> "
620 " <out_commods> <val>dry_spent</val> </out_commods> "
621 " <throughput>1</throughput>"
622 " <active_buying_frequency_type>Normal</active_buying_frequency_type>"
623 " <active_buying_mean>3</active_buying_mean>"
624 " <active_buying_stddev>1</active_buying_stddev>"
625 " <dormant_buying_frequency_type>Normal</dormant_buying_frequency_type>"
626 " <dormant_buying_mean>2</dormant_buying_mean>"
627 " <dormant_buying_stddev>1</dormant_buying_stddev>"
628 " <buying_size_type>Normal</buying_size_type>"
629 " <buying_size_mean>0.5</buying_size_mean>"
630 " <buying_size_stddev>0.1</buying_size_stddev>";
634 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
636 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
637 sim.AddSink(
"dry_spent").Finalize();
641 std::vector<cyclus::Cond> conds;
642 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
643 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
644 int n_trans = qr.rows.size();
645 EXPECT_EQ(10, n_trans) <<
"expected 10 transactions, got " << n_trans;
648 EXPECT_EQ(0, qr.GetVal<
int>(
"Time", 0));
649 EXPECT_EQ(3, qr.GetVal<
int>(
"Time", 3));
651 EXPECT_EQ(6, qr.GetVal<
int>(
"Time", 4));
652 EXPECT_EQ(7, qr.GetVal<
int>(
"Time", 5));
654 EXPECT_EQ(8, qr.GetVal<
int>(
"Time", 6));
655 EXPECT_EQ(9, qr.GetVal<
int>(
"Time", 7));
657 EXPECT_EQ(13, qr.GetVal<
int>(
"Time", 8));
658 EXPECT_EQ(14, qr.GetVal<
int>(
"Time", 9));
660 qr = sim.db().Query(
"Resources", NULL);
661 EXPECT_NEAR(0.61256, qr.GetVal<
double>(
"Quantity", 0), 0.00001);
662 EXPECT_NEAR(0.62217, qr.GetVal<
double>(
"Quantity", 1), 0.00001);
663 EXPECT_NEAR(0.39705, qr.GetVal<
double>(
"Quantity", 2), 0.00001);
666TEST_F(StorageTest, IncorrectBuyPolSetupUniform) {
668 std::string config_uniform =
669 " <in_commods> <val>spent_fuel</val> </in_commods> "
670 " <out_commods> <val>dry_spent</val> </out_commods> "
671 " <throughput>1</throughput>"
672 " <active_buying_frequency_type>Uniform</active_buying_frequency_type>";
676 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config_uniform,
678 EXPECT_THROW(sim.Run(), cyclus::ValueError);
681TEST_F(StorageTest, IncorrectBuyPolSetupNormal) {
683 std::string config_normal =
684 " <in_commods> <val>spent_fuel</val> </in_commods> "
685 " <out_commods> <val>dry_spent</val> </out_commods> "
686 " <throughput>1</throughput>"
687 " <active_buying_frequency_type>Normal</active_buying_frequency_type>";
690 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config_normal,
692 EXPECT_THROW(sim.Run(), cyclus::ValueError);
695TEST_F(StorageTest, IncorrectBuyPolSetupMinMax) {
697 std::string config_uniform_min_bigger_max =
698 " <in_commods> <val>spent_fuel</val> </in_commods> "
699 " <out_commods> <val>dry_spent</val> </out_commods> "
700 " <throughput>1</throughput>"
701 " <active_buying_frequency_type>Uniform</active_buying_frequency_type>"
702 " <active_buying_min>3</active_buying_min>"
703 " <active_buying_max>2</active_buying_max>";
707 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"),
708 config_uniform_min_bigger_max, simdur);
709 EXPECT_THROW(sim.Run(), cyclus::ValueError);
712TEST_F(StorageTest, PositionInitialize){
716 " <in_commods> <val>spent_fuel</val> </in_commods> "
717 " <out_commods> <val>dry_spent</val> </out_commods> "
718 " <residence_time>1</residence_time>"
719 " <max_inv_size>10</max_inv_size>";
723 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
725 sim.AddSource(
"spent_fuel").Finalize();
726 sim.AddSink(
"dry_spent").Finalize();
730 cyclus::QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
731 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 0.0);
732 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 0.0);
735TEST_F(StorageTest, Longitude){
739 " <in_commods> <val>spent_fuel</val> </in_commods> "
740 " <out_commods> <val>dry_spent</val> </out_commods> "
741 " <residence_time>1</residence_time>"
742 " <max_inv_size>10</max_inv_size>"
743 " <latitude>50.0</latitude> "
744 " <longitude>35.0</longitude> ";
748 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
750 sim.AddSource(
"spent_fuel").Finalize();
751 sim.AddSink(
"dry_spent").Finalize();
755 cyclus::QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
756 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 50.0);
757 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 35.0);
760TEST_F(StorageTest, RQ_Inventory_Invalid) {
762 " <in_commods> <val>spent_fuel</val> </in_commods> "
763 " <out_commods> <val>dry_spent</val> </out_commods> "
764 " <max_inv_size>5</max_inv_size>"
765 " <reorder_point>2</reorder_point>"
766 " <reorder_quantity>10</reorder_quantity>";
770 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:Storage"), config, simdur);
772 EXPECT_THROW(
int id = sim.Run(), cyclus::ValueError);
775TEST_F(StorageTest, RQ_Inventory) {
777 " <in_commods> <val>spent_fuel</val> </in_commods> "
778 " <out_commods> <val>dry_spent</val> </out_commods> "
779 " <max_inv_size>5</max_inv_size>"
780 " <reorder_point>2</reorder_point>"
781 " <reorder_quantity>3</reorder_quantity>";
785 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
787 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
788 sim.AddSink(
"dry_spent").Finalize();
792 std::vector<cyclus::Cond> conds;
793 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
794 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
795 int n_trans = qr.rows.size();
797 EXPECT_EQ(3, n_trans) <<
"expected 3 transactions, got " << n_trans;
799 EXPECT_EQ(0, qr.GetVal<
int>(
"Time", 0));
800 EXPECT_EQ(2, qr.GetVal<
int>(
"Time", 1));
801 EXPECT_EQ(4, qr.GetVal<
int>(
"Time", 2));
804 qr = sim.db().Query(
"Resources", NULL);
805 EXPECT_EQ(3, qr.GetVal<
double>(
"Quantity", 0));
808TEST_F(StorageTest, sS_Inventory) {
810 " <in_commods> <val>spent_fuel</val> </in_commods> "
811 " <out_commods> <val>dry_spent</val> </out_commods> "
812 " <max_inv_size>5</max_inv_size>"
813 " <reorder_point>2</reorder_point>";
817 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
819 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
820 sim.AddSink(
"dry_spent").Finalize();
824 std::vector<cyclus::Cond> conds;
825 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
826 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
827 int n_trans = qr.rows.size();
828 EXPECT_EQ(3, n_trans) <<
"expected 3 transactions, got " << n_trans;
830 EXPECT_EQ(0, qr.GetVal<
int>(
"Time", 0));
831 EXPECT_EQ(2, qr.GetVal<
int>(
"Time", 1));
832 EXPECT_EQ(4, qr.GetVal<
int>(
"Time", 2));
835 qr = sim.db().Query(
"Resources", NULL);
836 EXPECT_EQ(5, qr.GetVal<
double>(
"Quantity", 0));
839TEST_F(StorageTest, CCap_Inventory) {
841 " <in_commods> <val>spent_fuel</val> </in_commods> "
842 " <out_commods> <val>dry_spent</val> </out_commods> "
843 " <throughput>1</throughput> "
844 " <cumulative_cap>2</cumulative_cap> "
845 " <dormant_buying_frequency_type>Fixed</dormant_buying_frequency_type> "
846 " <dormant_buying_val>2</dormant_buying_val> ";
850 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
852 sim.AddSource(
"spent_fuel").capacity(5).Finalize();
853 sim.AddSink(
"dry_spent").Finalize();
857 std::vector<cyclus::Cond> conds;
858 conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"spent_fuel")));
859 cyclus::QueryResult qr = sim.db().Query(
"Transactions", &conds);
860 int n_trans = qr.rows.size();
861 EXPECT_EQ(5, n_trans) <<
"expected 5 transactions, got " << n_trans;
863 EXPECT_EQ(0, qr.GetVal<
int>(
"Time", 0));
864 EXPECT_EQ(1, qr.GetVal<
int>(
"Time", 1));
865 EXPECT_EQ(4, qr.GetVal<
int>(
"Time", 2));
866 EXPECT_EQ(5, qr.GetVal<
int>(
"Time", 3));
867 EXPECT_EQ(8, qr.GetVal<
int>(
"Time", 4));
870 qr = sim.db().Query(
"Resources", NULL);
871 EXPECT_EQ(1, qr.GetVal<
double>(
"Quantity", 0));
872 EXPECT_EQ(1, qr.GetVal<
double>(
"Quantity", 4));
875TEST_F(StorageTest, PackageExactly) {
878 " <in_commods> <val>spent_fuel</val> </in_commods> "
879 " <out_commods> <val>dry_spent</val> </out_commods> "
880 " <package>foo</package>";
884 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
885 sim.context()->AddPackage(
"foo", 1, 2,
"first");
886 cyclus::Package::Ptr p = sim.context()->GetPackage(
"foo");
888 sim.AddSource(
"spent_fuel").capacity(2).Finalize();
889 sim.AddSink(
"dry_spent").Finalize();
893 std::vector<cyclus::Cond> tr_conds;
894 tr_conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"dry_spent")));
895 cyclus::QueryResult qr_trans = sim.db().Query(
"Transactions", &tr_conds);
897 EXPECT_EQ(2, qr_trans.rows.size());
899 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 0));
900 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 1));
902 std::vector<cyclus::Cond> res_conds;
903 res_conds.push_back(cyclus::Cond(
"PackageName",
"==", p->name()));
904 cyclus::QueryResult qr_res = sim.db().Query(
"Resources", &res_conds);
906 EXPECT_EQ(qr_res.rows.size(), 2);
907 EXPECT_EQ(qr_res.GetVal<
double>(
"Quantity", 0), 2);
908 EXPECT_EQ(qr_res.GetVal<
double>(
"Quantity", 1), 2);
911TEST_F(StorageTest, PackageSplitEqual) {
914 " <in_commods> <val>commodity</val> </in_commods> "
915 " <out_commods> <val>commodity1</val> </out_commods> "
916 " <package>foo</package>";
920 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
921 sim.context()->AddPackage(
"foo", 1, 2,
"equal");
922 cyclus::Package::Ptr p = sim.context()->GetPackage(
"foo");
924 sim.AddSource(
"commodity").capacity(3).Finalize();
925 sim.AddSink(
"commodity1").Finalize();
929 std::vector<cyclus::Cond> tr_conds;
930 tr_conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"commodity1")));
931 cyclus::QueryResult qr_trans = sim.db().Query(
"Transactions", &tr_conds);
934 EXPECT_EQ(4, qr_trans.rows.size());
936 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 0));
937 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 1));
938 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 2));
939 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 3));
941 std::vector<cyclus::Cond> res_conds;
942 res_conds.push_back(cyclus::Cond(
"PackageName",
"==", p->name()));
943 cyclus::QueryResult qr_res = sim.db().Query(
"Resources", &res_conds);
945 EXPECT_EQ(qr_res.rows.size(), 4);
946 EXPECT_EQ(1.5, qr_res.GetVal<
double>(
"Quantity", 0));
947 EXPECT_EQ(1.5, qr_res.GetVal<
double>(
"Quantity", 1));
948 EXPECT_EQ(1.5, qr_res.GetVal<
double>(
"Quantity", 2));
949 EXPECT_EQ(1.5, qr_res.GetVal<
double>(
"Quantity", 3));
952TEST_F(StorageTest, PackageSplitFirst) {
955 " <in_commods> <val>commodity</val> </in_commods> "
956 " <out_commods> <val>commodity1</val> </out_commods> "
957 " <package>foo</package>";
961 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
962 sim.context()->AddPackage(
"foo", 1, 2,
"first");
963 cyclus::Package::Ptr p = sim.context()->GetPackage(
"foo");
965 sim.AddSource(
"commodity").capacity(3).Finalize();
966 sim.AddSink(
"commodity1").Finalize();
970 std::vector<cyclus::Cond> tr_conds;
971 tr_conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"commodity1")));
972 cyclus::QueryResult qr_trans = sim.db().Query(
"Transactions", &tr_conds);
975 EXPECT_EQ(4, qr_trans.rows.size());
977 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 0));
978 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 1));
979 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 2));
980 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 3));
982 std::vector<cyclus::Cond> res_conds;
983 res_conds.push_back(cyclus::Cond(
"PackageName",
"==", p->name()));
984 cyclus::QueryResult qr_res = sim.db().Query(
"Resources", &res_conds);
986 EXPECT_EQ(qr_res.rows.size(), 4);
990 std::vector<double> pkgd_t0 = {qr_res.GetVal<
double>(
"Quantity", 0),
991 qr_res.GetVal<
double>(
"Quantity", 1)};
992 std::sort(pkgd_t0.begin(), pkgd_t0.end(), std::greater<double>());
993 std::vector<double> exp_t0 = {2, 1};
995 EXPECT_EQ(exp_t0, pkgd_t0);
997 std::vector<double> pkgd_t1 = {qr_res.GetVal<
double>(
"Quantity", 2),
998 qr_res.GetVal<
double>(
"Quantity", 3)};
999 std::sort(pkgd_t1.begin(), pkgd_t1.end(), std::greater<double>());
1000 std::vector<double> exp_t1 = {2, 1};
1002 EXPECT_EQ(exp_t1, pkgd_t1);
1005TEST_F(StorageTest, PackageMerge) {
1006 std::string config =
1007 " <in_commods> <val>commodity</val> </in_commods> "
1008 " <out_commods> <val>commodity1</val> </out_commods> "
1009 " <throughput>1</throughput> "
1010 " <package>foo</package>";
1014 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
1015 sim.context()->AddPackage(
"foo", 1, 2,
"first");
1016 cyclus::Package::Ptr p = sim.context()->GetPackage(
"foo");
1018 sim.AddSource(
"commodity").capacity(0.5).Finalize();
1019 sim.AddSink(
"commodity1").Finalize();
1023 std::vector<cyclus::Cond> tr_conds;
1024 tr_conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"commodity1")));
1026 cyclus::QueryResult qr_trans = sim.db().Query(
"Transactions", &tr_conds);
1030 EXPECT_EQ(2, qr_trans.rows.size());
1032 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 0));
1033 EXPECT_EQ(4, qr_trans.GetVal<
int>(
"Time", 1));
1035 std::vector<cyclus::Cond> res_conds;
1036 res_conds.push_back(cyclus::Cond(
"PackageName",
"==", p->name()));
1037 cyclus::QueryResult qr_res = sim.db().Query(
"Resources", &res_conds);
1039 EXPECT_EQ(2, qr_res.rows.size());
1040 EXPECT_EQ(1, qr_res.GetVal<
double>(
"Quantity", 0));
1041 EXPECT_EQ(1, qr_res.GetVal<
double>(
"Quantity", 1));
1044TEST_F(StorageTest, TransportUnit) {
1045 std::string config =
1046 " <in_commods> <val>commodity</val> </in_commods> "
1047 " <out_commods> <val>commodity1</val> </out_commods> "
1048 " <throughput>3</throughput> "
1049 " <package>foo</package>"
1050 " <transport_unit>bar</transport_unit>";
1054 cyclus::MockSim sim(cyclus::AgentSpec (
":cycamore:Storage"), config, simdur);
1055 sim.context()->AddPackage(
"foo", 1, 1,
"first");
1056 cyclus::Package::Ptr p = sim.context()->GetPackage(
"foo");
1057 sim.context()->AddTransportUnit(
"bar", 2, 2,
"first");
1059 sim.AddSource(
"commodity").Finalize();
1060 sim.AddSink(
"commodity1").Finalize();
1064 std::vector<cyclus::Cond> tr_conds;
1065 tr_conds.push_back(cyclus::Cond(
"Commodity",
"==", std::string(
"commodity1")));
1067 cyclus::QueryResult qr_trans = sim.db().Query(
"Transactions", &tr_conds);
1074 EXPECT_EQ(6, qr_trans.rows.size());
1076 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 0));
1077 EXPECT_EQ(1, qr_trans.GetVal<
int>(
"Time", 1));
1078 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 2));
1079 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 3));
1080 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 4));
1081 EXPECT_EQ(2, qr_trans.GetVal<
int>(
"Time", 5));
1083 for (
int i = 0; i < qr_trans.rows.size(); i++) {
1084 std::cerr <<
"transaction " << i <<
"is at time " << qr_trans.GetVal<
int>(
"Time", i) << std::endl;
1087 std::vector<cyclus::Cond> res_conds;
1088 res_conds.push_back(cyclus::Cond(
"PackageName",
"==", p->name()));
1089 cyclus::QueryResult qr_res = sim.db().Query(
"Resources", &res_conds);
1091 EXPECT_EQ(6, qr_res.rows.size());
1093 EXPECT_EQ(1, qr_res.GetVal<
double>(
"Quantity", 0));
1094 EXPECT_EQ(1, qr_res.GetVal<
double>(
"Quantity", 5));
1105#ifndef CYCLUS_AGENT_TESTS_CONNECTED
1108#define CYCLUS_AGENT_TESTS_CONNECTED cyclus_agent_tests_connected
static int cyclus_agent_tests_connected
INSTANTIATE_TEST_SUITE_P(DeployInst, InstitutionTests, Values(&DeployInstitutionConstructor))
cyclus::Agent * StorageConstructor(cyclus::Context *ctx)
std::vector< std::string > out_c1
void TestInitState(cycamore::Storage *fac)
void TestBuffers(cycamore::Storage *fac, double inv, double proc, double ready, double stocks)
void TestReadyTime(cycamore::Storage *fac, int t)
std::vector< std::string > in_c1
void TestStocks(cycamore::Storage *fac, cyclus::CompMap v)
void TestCurrentCap(cycamore::Storage *fac, double inv)
void TestAddMat(cycamore::Storage *fac, cyclus::Material::Ptr mat)
This Facility is intended to hold materials for a user specified amount of time in order to model a s...
virtual std::string str()
A verbose printer for the Storage Facility.
cyclus::toolkit::TotalInvTracker inventory_tracker
virtual cyclus::Agent * Clone()
std::vector< std::string > in_commods
virtual void Tock()
The handleTick function specific to the Storage.
std::vector< std::string > out_commods
virtual void Tick()
The handleTick function specific to the Storage.
TEST_F(EnrichmentTest, RequestQty)