3#include <gtest/gtest.h>
7using pyne::nucname::id;
8using cyclus::Composition;
10using cyclus::Material;
11using cyclus::QueryResult;
13using cyclus::toolkit::MatQuery;
19 comp[id(
"U235")] = 10;
20 comp[id(
"U238")] = 90;
21 comp[id(
"Pu239")] = 1;
22 comp[id(
"Pu240")] = 2;
23 comp[id(
"Am241")] = 3;
24 comp[id(
"Am242")] = 2.8;
26 Composition::Ptr c = Composition::CreateFromMass(comp);
27 Material::Ptr mat = Material::CreateUntracked(qty, c);
29 std::map<int, double> effs;
32 effs[id(
"Am241")] = .4;
38 EXPECT_DOUBLE_EQ(effs[
id(
"U")] * mqorig.mass(
"U235"), mqsep.mass(
"U235"));
39 EXPECT_DOUBLE_EQ(effs[
id(
"U")] * mqorig.mass(
"U238"), mqsep.mass(
"U238"));
40 EXPECT_DOUBLE_EQ(effs[
id(
"Pu")] * mqorig.mass(
"Pu239"), mqsep.mass(
"Pu239"));
41 EXPECT_DOUBLE_EQ(effs[
id(
"Pu")] * mqorig.mass(
"Pu240"), mqsep.mass(
"Pu240"));
42 EXPECT_DOUBLE_EQ(effs[
id(
"Am241")] * mqorig.mass(
"Am241"), mqsep.mass(
"Am241"));
43 EXPECT_DOUBLE_EQ(0, mqsep.mass(
"Am242"));
48TEST(SeparationsTests, SeparationEfficiency) {
54 " <commod>stream1</commod>"
56 " <buf_size>-1</buf_size>"
58 " <item><comp>Pu239</comp> <eff>.2</eff></item>"
63 " <commod>stream1</commod>"
65 " <buf_size>-1</buf_size>"
67 " <item><comp>Pu239</comp> <eff>.1</eff></item>"
72 " <commod>stream1</commod>"
74 " <buf_size>-1</buf_size>"
76 " <item><comp>Pu239</comp> <eff>.5</eff></item>"
82 "<leftover_commod>waste</leftover_commod>"
83 "<throughput>100</throughput>"
84 "<feedbuf_size>100</feedbuf_size>"
85 "<feed_commods> <val>feed</val> </feed_commods>"
89 cyclus::MockSim sim1(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
91 EXPECT_NO_THROW(sim1.Run()) <<
"Cumulative separation efficiency smaler than 1 is throwing an error but should not.";
97 " <commod>stream1</commod>"
99 " <buf_size>-1</buf_size>"
101 " <item><comp>U</comp> <eff>0.1</eff></item>"
102 " <item><comp>Pu239</comp> <eff>.2</eff></item>"
107 " <commod>stream1</commod>"
109 " <buf_size>-1</buf_size>"
111 " <item><comp>U</comp> <eff>0.2</eff></item>"
112 " <item><comp>Pu239</comp> <eff>.1</eff></item>"
117 " <commod>stream1</commod>"
119 " <buf_size>-1</buf_size>"
121 " <item><comp>U</comp> <eff>0.7</eff></item>"
122 " <item><comp>Pu239</comp> <eff>.5</eff></item>"
128 "<leftover_commod>waste</leftover_commod>"
129 "<throughput>100</throughput>"
130 "<feedbuf_size>100</feedbuf_size>"
131 "<feed_commods> <val>feed</val> </feed_commods>"
135 cyclus::MockSim sim2(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
137 EXPECT_NO_THROW(sim2.Run()) <<
"Cumulative separation efficiency of 1 is throwing an error but should not.";
141TEST(SeparationsTests, SeparationEfficiencyThrowing) {
148 " <commod>stream1</commod>"
150 " <buf_size>-1</buf_size>"
152 " <item><comp>U</comp> <eff>1.6</eff></item>"
153 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
159 "<leftover_commod>waste</leftover_commod>"
160 "<throughput>100</throughput>"
161 "<feedbuf_size>100</feedbuf_size>"
162 "<feed_commods> <val>feed</val> </feed_commods>"
165 cyclus::MockSim sim1(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
167 EXPECT_THROW(sim1.Run(), cyclus::ValueError) <<
"Direct separation efficiency greater than 1 is not throwing an error but should.";
173 " <commod>stream1</commod>"
175 " <buf_size>-1</buf_size>"
177 " <item><comp>U</comp> <eff>0.6</eff></item>"
178 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
183 " <commod>stream2</commod>"
185 " <buf_size>-1</buf_size>"
187 " <item><comp>U</comp> <eff>0.1</eff></item>"
188 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
194 "<leftover_commod>waste</leftover_commod>"
195 "<throughput>100</throughput>"
196 "<feedbuf_size>100</feedbuf_size>"
197 "<feed_commods> <val>feed</val> </feed_commods>"
200 cyclus::MockSim sim2(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
202 EXPECT_THROW(sim2.Run(), cyclus::ValueError) <<
"Single cumulative separation efficiency greater than 1 is not throwing an error but should.";
207 " <commod>stream1</commod>"
209 " <buf_size>-1</buf_size>"
211 " <item><comp>U</comp> <eff>0.6</eff></item>"
212 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
217 " <commod>stream2</commod>"
219 " <buf_size>-1</buf_size>"
221 " <item><comp>U</comp> <eff>0.6</eff></item>"
222 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
228 "<leftover_commod>waste</leftover_commod>"
229 "<throughput>100</throughput>"
230 "<feedbuf_size>100</feedbuf_size>"
231 "<feed_commods> <val>feed</val> </feed_commods>"
234 cyclus::MockSim sim3(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
236 EXPECT_THROW(sim3.Run(), cyclus::ValueError) <<
"Multiple cumulative separation efficiencies greater than 1 are not throwing an error but should.";
239TEST(SeparationsTests, SepMixElemAndNuclide) {
243 " <commod>stream1</commod>"
245 " <buf_size>-1</buf_size>"
247 " <item><comp>U</comp> <eff>0.6</eff></item>"
248 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
254 "<leftover_commod>waste</leftover_commod>"
255 "<throughput>100</throughput>"
256 "<feedbuf_size>100</feedbuf_size>"
257 "<feed_commods> <val>feed</val> </feed_commods>"
261 m[id(
"u235")] = 0.08;
263 m[id(
"Pu239")] = .01;
264 m[id(
"Pu240")] = .01;
265 Composition::Ptr c = Composition::CreateFromMass(m);
268 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
269 sim.AddSource(
"feed").recipe(
"recipe1").Finalize();
270 sim.AddSink(
"stream1").capacity(100).Finalize();
271 sim.AddRecipe(
"recipe1", c);
274 std::vector<Cond> conds;
275 conds.push_back(Cond(
"SenderId",
"==",
id));
276 int resid = sim.db().Query(
"Transactions", &conds).GetVal<
int>(
"ResourceId");
277 MatQuery mq (sim.GetMaterial(resid));
278 EXPECT_DOUBLE_EQ(m[922350000]*0.6*100, mq.mass(
"U235"));
279 EXPECT_DOUBLE_EQ(m[922380000]*0.6*100, mq.mass(
"U238"));
280 EXPECT_DOUBLE_EQ(m[942390000]*0.7*100, mq.mass(
"Pu239"));
281 EXPECT_DOUBLE_EQ(0, mq.mass(
"Pu240"));
284TEST(SeparationsTests, Retire) {
288 " <commod>stream1</commod>"
290 " <buf_size>-1</buf_size>"
292 " <item><comp>U235</comp> <eff>1.0</eff></item>"
298 "<leftover_commod>waste</leftover_commod>"
299 "<throughput>100</throughput>"
300 "<feedbuf_size>100</feedbuf_size>"
301 "<feed_commods> <val>feed</val> </feed_commods>"
307 Composition::Ptr c = Composition::CreateFromMass(m);
312 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:Separations"),
313 config, simdur, life);
314 sim.AddSource(
"feed").recipe(
"recipe1").Finalize();
315 sim.AddSink(
"stream1").capacity(100).Finalize();
316 sim.AddSink(
"waste").capacity(70).Finalize();
317 sim.AddRecipe(
"recipe1", c);
323 std::vector<Cond> conds;
324 conds.push_back(Cond(
"ReceiverId",
"==",
id));
325 QueryResult qr = sim.db().Query(
"Transactions", &conds);
326 EXPECT_EQ(life - 1, qr.rows.size())
327 <<
"failed to stop ordering near retirement";
331 conds.push_back(Cond(
"SenderId",
"==",
id));
332 qr = sim.db().Query(
"Transactions", &conds);
334 for (
int i = 0; i < qr.rows.size(); i++) {
335 Material::Ptr m = sim.GetMaterial(qr.GetVal<
int>(
"ResourceId", i));
336 tot_mat += m->quantity();
338 EXPECT_EQ(100, tot_mat)
339 <<
"total material traded away does not equal total material separated";
340 EXPECT_EQ(3.0, qr.rows.size())
341 <<
"failed to discharge all material before decomissioning";
344 TEST(SeparationsTests, PositionInitialize) {
348 " <commod>stream1</commod>"
350 " <buf_size>-1</buf_size>"
352 " <item><comp>U</comp> <eff>0.6</eff></item>"
353 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
359 "<leftover_commod>waste</leftover_commod>"
360 "<throughput>100</throughput>"
361 "<feedbuf_size>100</feedbuf_size>"
362 "<feed_commods> <val>feed</val> </feed_commods>";
364 m[id(
"u235")] = 0.08;
366 m[id(
"Pu239")] = .01;
367 m[id(
"Pu240")] = .01;
368 Composition::Ptr c = Composition::CreateFromMass(m);
371 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
372 sim.AddSource(
"feed").recipe(
"recipe1").Finalize();
373 sim.AddSink(
"stream1").capacity(100).Finalize();
374 sim.AddRecipe(
"recipe1", c);
377 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
378 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 0.0);
379 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 0.0);
382 TEST(SeparationsTests, PositionInitialize2) {
386 " <commod>stream1</commod>"
388 " <buf_size>-1</buf_size>"
390 " <item><comp>U</comp> <eff>0.6</eff></item>"
391 " <item><comp>Pu239</comp> <eff>.7</eff></item>"
397 "<leftover_commod>waste</leftover_commod>"
398 "<throughput>100</throughput>"
399 "<feedbuf_size>100</feedbuf_size>"
400 "<feed_commods> <val>feed</val> </feed_commods>"
401 "<latitude>10.0</latitude> "
402 "<longitude>15.0</longitude> ";
404 m[id(
"u235")] = 0.08;
406 m[id(
"Pu239")] = .01;
407 m[id(
"Pu240")] = .01;
408 Composition::Ptr c = Composition::CreateFromMass(m);
411 cyclus::MockSim sim(cyclus::AgentSpec(
":cycamore:Separations"), config, simdur);
412 sim.AddSource(
"feed").recipe(
"recipe1").Finalize();
413 sim.AddSink(
"stream1").capacity(100).Finalize();
414 sim.AddRecipe(
"recipe1", c);
417 QueryResult qr = sim.db().Query(
"AgentPosition", NULL);
418 EXPECT_EQ(qr.GetVal<
double>(
"Latitude"), 10.0);
419 EXPECT_EQ(qr.GetVal<
double>(
"Longitude"), 15.0);
Material::Ptr SepMaterial(std::map< int, double > effs, Material::Ptr mat)
TEST(MixerTests, MultipleFissStreams)