CYCAMORE
Loading...
Searching...
No Matches
build/cycamore/enrichment.h
Go to the documentation of this file.
1
2#line 1 "/cycamore/src/enrichment.h"
3#ifndef CYCAMORE_SRC_ENRICHMENT_H_
4#define CYCAMORE_SRC_ENRICHMENT_H_
5
6#include <string>
7
8#include "cyclus.h"
9#include "cycamore_version.h"
10
11#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
12
13namespace cycamore {
14
19class SWUConverter : public cyclus::Converter<cyclus::Material> {
20 public:
21 SWUConverter(double feed_commod, double tails) : feed_(feed_commod),
22 tails_(tails) {}
23 virtual ~SWUConverter() {}
24
26 virtual double convert(
27 cyclus::Material::Ptr m,
28 cyclus::Arc const * a = NULL,
29 cyclus::ExchangeTranslationContext<cyclus::Material>
30 const * ctx = NULL) const {
31 cyclus::toolkit::Assays assays(feed_, cyclus::toolkit::UraniumAssayMass(m),
32 tails_);
33 return cyclus::toolkit::SwuRequired(m->quantity(), assays);
34 }
35
37 virtual bool operator==(Converter& other) const {
38 SWUConverter* cast = dynamic_cast<SWUConverter*>(&other);
39 return cast != NULL &&
40 feed_ == cast->feed_ &&
41 tails_ == cast->tails_;
42 }
43
44 private:
45 double feed_, tails_;
46};
47
53class NatUConverter : public cyclus::Converter<cyclus::Material> {
54 public:
55 NatUConverter(double feed_commod, double tails) : feed_(feed_commod),
56 tails_(tails) {}
57 virtual ~NatUConverter() {}
58
59 virtual std::string version() { return CYCAMORE_VERSION; }
60
62 virtual double convert(
63 cyclus::Material::Ptr m,
64 cyclus::Arc const * a = NULL,
65 cyclus::ExchangeTranslationContext<cyclus::Material>
66 const * ctx = NULL) const {
67 cyclus::toolkit::Assays assays(feed_, cyclus::toolkit::UraniumAssayMass(m),
68 tails_);
69 cyclus::toolkit::MatQuery mq(m);
70 std::set<cyclus::Nuc> nucs;
71 nucs.insert(922350000);
72 nucs.insert(922380000);
73
74 double natu_frac = mq.mass_frac(nucs);
75 double natu_req = cyclus::toolkit::FeedQty(m->quantity(), assays);
76 return natu_req / natu_frac;
77 }
78
80 virtual bool operator==(Converter& other) const {
81 NatUConverter* cast = dynamic_cast<NatUConverter*>(&other);
82 return cast != NULL &&
83 feed_ == cast->feed_ &&
84 tails_ == cast->tails_;
85 }
86
87 private:
88 double feed_, tails_;
89};
90
123
125 : public cyclus::Facility,
126 public cyclus::toolkit::Position {
127#pragma cyclus note { "niche": "enrichment facility", "doc": "The Enrichment facility is a simple agent that enriches natural " "uranium in a Cyclus simulation. It does not explicitly compute " "the physical enrichment process, rather it calculates the SWU " "required to convert a source uranium recipe (i.e. natural uranium) " "into a requested enriched recipe (i.e. 4% enriched uranium), given " "the natural uranium inventory constraint and its SWU capacity " "constraint." "\n\n" "The Enrichment facility requests an input commodity and associated " "recipe whose quantity is its remaining inventory capacity. All " "facilities trading the same input commodity (even with different " "recipes) will offer materials for trade. The Enrichment facility " "accepts any input materials with enrichments less than its tails assay, " "as long as some U235 is present, and preference increases with U235 " "content. If no U235 is present in the offered material, the trade " "preference is set to -1 and the material is not accepted. Any material " "components other than U235 and U238 are sent directly to the tails buffer." "\n\n" "The Enrichment facility will bid on any request for its output commodity " "up to the maximum allowed enrichment (if not specified, default is 100%) " "It bids on either the request quantity, or the maximum quanity allowed " "by its SWU constraint or natural uranium inventory, whichever is lower. " "If multiple output commodities with different enrichment levels are " "requested and the facility does not have the SWU or quantity capacity " "to meet all requests, the requests are fully, then partially filled " "in unspecified but repeatable order. A request for the product " "commodity without an associated requested enriched recipe will not be " "fulfilled." "\n\n" "Accumulated tails inventory is offered for trading as a specifiable " "output commodity.", }
128#line 160 "/cycamore/src/enrichment.h"
129 public:
130 // --- Module Members ---
133 Enrichment(cyclus::Context* ctx);
134
136 virtual ~Enrichment();
137
138 virtual std::string version() { return CYCAMORE_VERSION; }
140 cyclus::Facility::InitFrom(m);
141 int rawcycpp_shape_feed_commod[1] = {-1};
142 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
143 int rawcycpp_shape_feed_recipe[1] = {-1};
144 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
145 int rawcycpp_shape_product_commod[1] = {-1};
146 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
147 int rawcycpp_shape_tails_commod[1] = {-1};
148 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
149 int rawcycpp_shape_tails_assay[1] = {-1};
150 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
151 int rawcycpp_shape_initial_feed[1] = {-1};
152 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
153 int rawcycpp_shape_max_feed_inventory[1] = {-1};
154 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
155 int rawcycpp_shape_max_enrich[1] = {-1};
156 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
157 int rawcycpp_shape_order_prefs[1] = {-1};
158 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
159 int rawcycpp_shape_swu_capacity[1] = {-1};
160 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
161 int rawcycpp_shape_inventory[2] = {-1, -1};
162 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
163 int rawcycpp_shape_tails[2] = {-1, -1};
164 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
165 int rawcycpp_shape_latitude[1] = {-1};
166 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
167 int rawcycpp_shape_longitude[1] = {-1};
168 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
179 latitude = m->latitude;
180 longitude = m->longitude;
181 inventory.capacity(m->inventory.capacity());
182 tails.capacity(m->tails.capacity());
183 };
184#line 170 "/cycamore/src/enrichment.h"
185
186 virtual void InitFrom(cyclus::QueryableBackend* b) {
187 cyclus::Facility::InitFrom(b);
188 int rawcycpp_shape_feed_commod[1] = {-1};
189 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
190 int rawcycpp_shape_feed_recipe[1] = {-1};
191 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
192 int rawcycpp_shape_product_commod[1] = {-1};
193 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
194 int rawcycpp_shape_tails_commod[1] = {-1};
195 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
196 int rawcycpp_shape_tails_assay[1] = {-1};
197 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
198 int rawcycpp_shape_initial_feed[1] = {-1};
199 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
200 int rawcycpp_shape_max_feed_inventory[1] = {-1};
201 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
202 int rawcycpp_shape_max_enrich[1] = {-1};
203 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
204 int rawcycpp_shape_order_prefs[1] = {-1};
205 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
206 int rawcycpp_shape_swu_capacity[1] = {-1};
207 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
208 int rawcycpp_shape_inventory[2] = {-1, -1};
209 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
210 int rawcycpp_shape_tails[2] = {-1, -1};
211 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
212 int rawcycpp_shape_latitude[1] = {-1};
213 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
214 int rawcycpp_shape_longitude[1] = {-1};
215 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
216 cyclus::QueryResult qr = b->Query("Info", NULL);
217 feed_commod = qr.GetVal<std::string>("feed_commod");
218 feed_recipe = qr.GetVal<std::string>("feed_recipe");
219 product_commod = qr.GetVal<std::string>("product_commod");
220 tails_commod = qr.GetVal<std::string>("tails_commod");
221 tails_assay = qr.GetVal<double>("tails_assay");
222 initial_feed = qr.GetVal<double>("initial_feed");
223 max_feed_inventory = qr.GetVal<double>("max_feed_inventory");
224 max_enrich = qr.GetVal<double>("max_enrich");
225 order_prefs = qr.GetVal<bool>("order_prefs");
226 swu_capacity = qr.GetVal<double>("swu_capacity");
227 latitude = qr.GetVal<double>("latitude");
228 longitude = qr.GetVal<double>("longitude");
230 tails.capacity(1e+300);
231 };
232
233 virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
234 cyclus::Facility::InfileToDb(tree, di);
235 int rawcycpp_shape_feed_commod[1] = {-1};
236 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
237 int rawcycpp_shape_feed_recipe[1] = {-1};
238 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
239 int rawcycpp_shape_product_commod[1] = {-1};
240 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
241 int rawcycpp_shape_tails_commod[1] = {-1};
242 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
243 int rawcycpp_shape_tails_assay[1] = {-1};
244 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
245 int rawcycpp_shape_initial_feed[1] = {-1};
246 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
247 int rawcycpp_shape_max_feed_inventory[1] = {-1};
248 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
249 int rawcycpp_shape_max_enrich[1] = {-1};
250 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
251 int rawcycpp_shape_order_prefs[1] = {-1};
252 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
253 int rawcycpp_shape_swu_capacity[1] = {-1};
254 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
255 int rawcycpp_shape_inventory[2] = {-1, -1};
256 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
257 int rawcycpp_shape_tails[2] = {-1, -1};
258 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
259 int rawcycpp_shape_latitude[1] = {-1};
260 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
261 int rawcycpp_shape_longitude[1] = {-1};
262 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
263 cyclus::InfileTree* sub = tree->SubTree("config/*");
264 int i;
265 int n;
266 {
267 std::string feed_commod_val = cyclus::Query<std::string>(sub, "feed_commod");
268 feed_commod = feed_commod_val;
269 }
270 {
271 std::string feed_recipe_val = cyclus::Query<std::string>(sub, "feed_recipe");
272 feed_recipe = feed_recipe_val;
273 }
274 {
275 std::string product_commod_val = cyclus::Query<std::string>(sub, "product_commod");
276 product_commod = product_commod_val;
277 }
278 {
279 std::string tails_commod_val = cyclus::Query<std::string>(sub, "tails_commod");
280 tails_commod = tails_commod_val;
281 }
282 if (sub->NMatches("tails_assay") > 0) {
283 {
284 double tails_assay_val = cyclus::Query<double>(sub, "tails_assay");
285 tails_assay = tails_assay_val;
286 }
287 } else {
288 double tails_assay_tmp = 0.003;
289 tails_assay = tails_assay_tmp;
290 }
291 if (sub->NMatches("initial_feed") > 0) {
292 {
293 double initial_feed_val = cyclus::Query<double>(sub, "initial_feed");
294 initial_feed = initial_feed_val;
295 }
296 } else {
297 double initial_feed_tmp = 0;
298 initial_feed = initial_feed_tmp;
299 }
300 if (sub->NMatches("max_feed_inventory") > 0) {
301 {
302 double max_feed_inventory_val = cyclus::Query<double>(sub, "max_feed_inventory");
303 max_feed_inventory = max_feed_inventory_val;
304 }
305 } else {
306 double max_feed_inventory_tmp = 1e+299;
307 max_feed_inventory = max_feed_inventory_tmp;
308 }
309 if (sub->NMatches("max_enrich") > 0) {
310 {
311 double max_enrich_val = cyclus::Query<double>(sub, "max_enrich");
312 max_enrich = max_enrich_val;
313 }
314 } else {
315 double max_enrich_tmp = 1.0;
316 max_enrich = max_enrich_tmp;
317 }
318 if (sub->NMatches("order_prefs") > 0) {
319 {
320 bool order_prefs_val = cyclus::Query<bool>(sub, "order_prefs");
321 order_prefs = order_prefs_val;
322 }
323 } else {
324 bool order_prefs_tmp = true;
325 order_prefs = order_prefs_tmp;
326 }
327 if (sub->NMatches("swu_capacity") > 0) {
328 {
329 double swu_capacity_val = cyclus::Query<double>(sub, "swu_capacity");
330 swu_capacity = swu_capacity_val;
331 }
332 } else {
333 double swu_capacity_tmp = 1e+299;
334 swu_capacity = swu_capacity_tmp;
335 }
336 if (sub->NMatches("latitude") > 0) {
337 {
338 double latitude_val = cyclus::Query<double>(sub, "latitude");
339 latitude = latitude_val;
340 }
341 } else {
342 double latitude_tmp = 0.0;
343 latitude = latitude_tmp;
344 }
345 if (sub->NMatches("longitude") > 0) {
346 {
347 double longitude_val = cyclus::Query<double>(sub, "longitude");
348 longitude = longitude_val;
349 }
350 } else {
351 double longitude_tmp = 0.0;
352 longitude = longitude_tmp;
353 }
354 di.NewDatum("Info")
355 ->AddVal("feed_commod", feed_commod, &cycpp_shape_feed_commod)
356 ->AddVal("feed_recipe", feed_recipe, &cycpp_shape_feed_recipe)
357 ->AddVal("product_commod", product_commod, &cycpp_shape_product_commod)
358 ->AddVal("tails_commod", tails_commod, &cycpp_shape_tails_commod)
359 ->AddVal("tails_assay", tails_assay, &cycpp_shape_tails_assay)
360 ->AddVal("initial_feed", initial_feed, &cycpp_shape_initial_feed)
361 ->AddVal("max_feed_inventory", max_feed_inventory, &cycpp_shape_max_feed_inventory)
362 ->AddVal("max_enrich", max_enrich, &cycpp_shape_max_enrich)
363 ->AddVal("order_prefs", order_prefs, &cycpp_shape_order_prefs)
364 ->AddVal("swu_capacity", swu_capacity, &cycpp_shape_swu_capacity)
365 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
366 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
367 ->Record();
368 };
369
370 virtual cyclus::Agent* Clone() {
371 cycamore::Enrichment* m = new cycamore::Enrichment(context());
372 m->InitFrom(this);
373 return m;
374 };
375
376 virtual std::string schema() {
377 return ""
378 "<interleave>\n"
379 " <element name=\"feed_commod\">\n"
380 " <data type=\"string\"/>\n"
381 " </element>\n"
382 " <element name=\"feed_recipe\">\n"
383 " <data type=\"string\"/>\n"
384 " </element>\n"
385 " <element name=\"product_commod\">\n"
386 " <data type=\"string\"/>\n"
387 " </element>\n"
388 " <element name=\"tails_commod\">\n"
389 " <data type=\"string\"/>\n"
390 " </element>\n"
391 " <optional>\n"
392 " <element name=\"tails_assay\">\n"
393 " <data type=\"double\"/>\n"
394 " </element>\n"
395 " </optional>\n"
396 " <optional>\n"
397 " <element name=\"initial_feed\">\n"
398 " <data type=\"double\"/>\n"
399 " </element>\n"
400 " </optional>\n"
401 " <optional>\n"
402 " <element name=\"max_feed_inventory\">\n"
403 " <data type=\"double\"/>\n"
404 " </element>\n"
405 " </optional>\n"
406 " <optional>\n"
407 " <element name=\"max_enrich\">\n"
408 " <data type=\"double\">\n"
409 " <param name=\"minInclusive\">0</param>\n"
410 " <param name=\"maxInclusive\">1</param>\n"
411 " </data>\n"
412 " </element>\n"
413 " </optional>\n"
414 " <optional>\n"
415 " <element name=\"order_prefs\">\n"
416 " <data type=\"boolean\"/>\n"
417 " </element>\n"
418 " </optional>\n"
419 " <optional>\n"
420 " <element name=\"swu_capacity\">\n"
421 " <data type=\"double\"/>\n"
422 " </element>\n"
423 " </optional>\n"
424 " <optional>\n"
425 " <element name=\"latitude\">\n"
426 " <data type=\"double\"/>\n"
427 " </element>\n"
428 " </optional>\n"
429 " <optional>\n"
430 " <element name=\"longitude\">\n"
431 " <data type=\"double\"/>\n"
432 " </element>\n"
433 " </optional>\n"
434 "</interleave>\n";
435 };
436
437 virtual Json::Value annotations() {
438 Json::Value root;
439 Json::Reader reader;
440 bool parsed_ok = reader.parse(
441 "{\"name\":\"cycamore::Enrichment\",\"entity\":\"facility\""
442 ",\"parents\":[\"cyclus::Facility\",\"cyclus::toolkit::P"
443 "osition\"],\"all_parents\":[\"cyclus::Agent\",\"cyclus::"
444 "Facility\",\"cyclus::Ider\",\"cyclus::StateWrangler\",\""
445 "cyclus::TimeListener\",\"cyclus::Trader\",\"cyclus::to"
446 "olkit::Position\"],\"vars\":{\"feed_commod\":{\"tooltip\""
447 ":\"feed commodity\",\"doc\":\"feed commodity that the "
448 "enrichment facility accepts\",\"uilabel\":\"Feed Commo"
449 "dity\",\"uitype\":\"incommodity\",\"type\":\"std::string\","
450 "\"index\":0,\"shape\":[-"
451 "1],\"alias\":\"feed_commod\"},\"feed_recipe\":{\"tooltip\""
452 ":\"feed recipe\",\"doc\":\"recipe for enrichment "
453 "facility feed commodity\",\"uilabel\":\"Feed Recipe\",\""
454 "uitype\":\"inrecipe\",\"type\":\"std::string\",\"index\":1,"
455 "\"shape\":[-"
456 "1],\"alias\":\"feed_recipe\"},\"product_commod\":{\"toolt"
457 "ip\":\"product commodity\",\"doc\":\"product commodity "
458 "that the enrichment facility "
459 "generates\",\"uilabel\":\"Product Commodity\",\"uitype\":"
460 "\"outcommodity\",\"type\":\"std::string\",\"index\":2,\"sha"
461 "pe\":[-"
462 "1],\"alias\":\"product_commod\"},\"tails_commod\":{\"tool"
463 "tip\":\"tails commodity\",\"doc\":\"tails commodity "
464 "supplied by enrichment facility\",\"uilabel\":\"Tails "
465 "Commodity\",\"uitype\":\"outcommodity\",\"type\":\"std::st"
466 "ring\",\"index\":3,\"shape\":[-"
467 "1],\"alias\":\"tails_commod\"},\"tails_assay\":{\"default"
468 "\":0.003,\"tooltip\":\"tails assay\",\"uilabel\":\"Tails A"
469 "ssay\",\"uitype\":\"range\",\"range\":[0.0,0.003],\"doc\":\""
470 "tails assay from the enrichment process\",\"type\":\"d"
471 "ouble\",\"index\":4,\"shape\":[-"
472 "1],\"alias\":\"tails_assay\"},\"initial_feed\":{\"default"
473 "\":0,\"tooltip\":\"initial uranium reserves "
474 "(kg)\",\"uilabel\":\"Initial Feed "
475 "Inventory\",\"doc\":\"amount of natural uranium stored"
476 " at the enrichment facility at the beginning of "
477 "the simulation (kg)\",\"type\":\"double\",\"index\":5,\"sh"
478 "ape\":[-"
479 "1],\"alias\":\"initial_feed\"},\"max_feed_inventory\":{\""
480 "default\":1e+299,\"tooltip\":\"max inventory of feed "
481 "material (kg)\",\"uilabel\":\"Maximum Feed Inventory\","
482 "\"uitype\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"maxim"
483 "um total inventory of natural uranium in the "
484 "enrichment facility (kg)\",\"type\":\"double\",\"index\":"
485 "6,\"shape\":[-"
486 "1],\"alias\":\"max_feed_inventory\"},\"max_enrich\":{\"de"
487 "fault\":1.0,\"tooltip\":\"maximum allowed enrichment "
488 "fraction\",\"doc\":\"maximum allowed weight fraction "
489 "of U235 in product\",\"uilabel\":\"Maximum Allowed Enr"
490 "ichment\",\"uitype\":\"range\",\"range\":[0.0,1.0],\"schem"
491 "a\":\"<optional> <element "
492 "name=\\\"max_enrich\\\"> <data "
493 "type=\\\"double\\\"> <param "
494 "name=\\\"minInclusive\\\">0</param> "
495 "<param name=\\\"maxInclusive\\\">1</param>"
496 " </data> </element> </o"
497 "ptional>\",\"type\":\"double\",\"index\":7,\"shape\":[-"
498 "1],\"alias\":\"max_enrich\"},\"order_prefs\":{\"default\":"
499 "1,\"userlevel\":10,\"tooltip\":\"Rank Material Requests"
500 " by U235 Content\",\"uilabel\":\"Prefer feed with "
501 "higher U235 content\",\"doc\":\"turn on preference "
502 "ordering for input material so that EF chooses "
503 "higher U235 content first\",\"type\":\"bool\",\"index\":8"
504 ",\"shape\":[-"
505 "1],\"alias\":\"order_prefs\"},\"swu_capacity\":{\"default"
506 "\":1e+299,\"tooltip\":\"SWU capacity "
507 "(kgSWU/timestep)\",\"uilabel\":\"SWU Capacity\",\"uitype"
508 "\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"separative "
509 "work unit (SWU) capacity of enrichment facility "
510 "(kgSWU/timestep) \",\"type\":\"double\",\"index\":9,\"shap"
511 "e\":[-"
512 "1],\"alias\":\"swu_capacity\"},\"inventory\":{\"capacity\""
513 ":\"max_feed_inventory\",\"type\":[\"cyclus::toolkit::Re"
514 "sBuf\",\"cyclus::Material\"],\"index\":10,\"shape\":[-1,-"
515 "1]},\"tails\":{\"type\":[\"cyclus::toolkit::ResBuf\",\"cy"
516 "clus::Material\"],\"index\":11,\"shape\":[-1,-"
517 "1]},\"latitude\":{\"default\":0.0,\"uilabel\":\"Geographi"
518 "cal latitude in degrees as a "
519 "double\",\"doc\":\"Latitude of the agent's "
520 "geographical position. The value should be "
521 "expressed in degrees as a double.\",\"type\":\"double\""
522 ",\"index\":12,\"shape\":[-"
523 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
524 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
525 "longitude in degrees as a double\",\"doc\":\"Longitude"
526 " of the agent's geographical position. The value "
527 "should be expressed in degrees as a double.\",\"type"
528 "\":\"double\",\"index\":13,\"shape\":[-"
529 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"}},\"ni"
530 "che\":\"enrichment facility\",\"doc\":\"The Enrichment "
531 "facility is a simple agent that enriches natural "
532 "uranium in a Cyclus simulation. It does not "
533 "explicitly compute the physical enrichment "
534 "process, rather it calculates the SWU required to "
535 "convert a source uranium recipe (i.e. natural "
536 "uranium) into a requested enriched recipe (i.e. 4%"
537 " enriched uranium), given the natural uranium "
538 "inventory constraint and its SWU capacity "
539 "constraint.\\n\\nThe Enrichment facility requests an"
540 " input commodity and associated recipe whose "
541 "quantity is its remaining inventory capacity. All"
542 " facilities trading the same input commodity (even"
543 " with different recipes) will offer materials for "
544 "trade. The Enrichment facility accepts any input "
545 "materials with enrichments less than its tails "
546 "assay, as long as some U235 is present, and "
547 "preference increases with U235 content. If no "
548 "U235 is present in the offered material, the trade"
549 " preference is set to -1 and the material is not "
550 "accepted. Any material components other than U235"
551 " and U238 are sent directly to the tails "
552 "buffer.\\n\\nThe Enrichment facility will bid on any"
553 " request for its output commodity up to the "
554 "maximum allowed enrichment (if not specified, "
555 "default is 100%) It bids on either the request "
556 "quantity, or the maximum quanity allowed by its "
557 "SWU constraint or natural uranium inventory, "
558 "whichever is lower. If multiple output commodities"
559 " with different enrichment levels are requested "
560 "and the facility does not have the SWU or quantity"
561 " capacity to meet all requests, the requests are "
562 "fully, then partially filled in unspecified but "
563 "repeatable order. A request for the product "
564 "commodity without an associated requested enriched"
565 " recipe will not be fulfilled.\\n\\nAccumulated "
566 "tails inventory is offered for trading as a "
567 "specifiable output commodity.\"}", root);
568 if (!parsed_ok) {
569 throw cyclus::ValueError("failed to parse annotations for cycamore::Enrichment.");
570 }
571 return root;
572 };
573
574 virtual void InitInv(cyclus::Inventories& inv) {
575 inventory.Push(inv["inventory"]);
576 tails.Push(inv["tails"]);
577
578 };
579
580 virtual cyclus::Inventories SnapshotInv() {
581 cyclus::Inventories invs;
582 invs["inventory"] = inventory.PopNRes(inventory.count());
583 inventory.Push(invs["inventory"]);
584 invs["tails"] = tails.PopNRes(tails.count());
585 tails.Push(invs["tails"]);
586 return invs;
587 };
588
589 virtual void Snapshot(cyclus::DbInit di) {
590 di.NewDatum("Info")
591 ->AddVal("feed_commod", feed_commod, &cycpp_shape_feed_commod)
592 ->AddVal("feed_recipe", feed_recipe, &cycpp_shape_feed_recipe)
593 ->AddVal("product_commod", product_commod, &cycpp_shape_product_commod)
594 ->AddVal("tails_commod", tails_commod, &cycpp_shape_tails_commod)
595 ->AddVal("tails_assay", tails_assay, &cycpp_shape_tails_assay)
596 ->AddVal("initial_feed", initial_feed, &cycpp_shape_initial_feed)
597 ->AddVal("max_feed_inventory", max_feed_inventory, &cycpp_shape_max_feed_inventory)
598 ->AddVal("max_enrich", max_enrich, &cycpp_shape_max_enrich)
599 ->AddVal("order_prefs", order_prefs, &cycpp_shape_order_prefs)
600 ->AddVal("swu_capacity", swu_capacity, &cycpp_shape_swu_capacity)
601 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
602 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
603 ->Record();
604 };
605#line 172 "/cycamore/src/enrichment.h"
606
608 virtual std::string str();
609 // ---
610
611 // --- Facility Members ---
613 virtual void Build(cyclus::Agent* parent);
614 // ---
615
616 // --- Agent Members ---
619
621 virtual void Tick();
622
625
627 virtual void Tock();
628
631 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
633
637 virtual void AdjustMatlPrefs(cyclus::PrefMap<cyclus::Material>::type& prefs);
638
641 virtual void AcceptMatlTrades(
642 const std::vector< std::pair<cyclus::Trade<cyclus::Material>,
643 cyclus::Material::Ptr> >& responses);
644
648 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr>
649 GetMatlBids(cyclus::CommodMap<cyclus::Material>::type&
650 commod_requests);
651
657 virtual void GetMatlTrades(
658 const std::vector< cyclus::Trade<cyclus::Material> >& trades,
659 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
660 cyclus::Material::Ptr> >& responses);
661 // ---
662
667 bool ValidReq(const cyclus::Material::Ptr mat);
668
669 inline void SetMaxInventorySize(double size) {
670 max_feed_inventory = size;
671 inventory.capacity(size);
672 }
673
674 inline void SwuCapacity(double capacity) {
675 swu_capacity = capacity;
677 }
678
679 inline double SwuCapacity() const { return swu_capacity; }
680
681 inline const cyclus::toolkit::ResBuf<cyclus::Material>& Tails() const {
682 return tails;
683 }
684
685 private:
688 void AddMat_(cyclus::Material::Ptr mat);
689
692 cyclus::Material::Ptr Request_();
693
700 cyclus::Material::Ptr Offer_(cyclus::Material::Ptr req);
701
702 cyclus::Material::Ptr Enrich_(cyclus::Material::Ptr mat, double qty);
703
705 double FeedAssay();
706
708 void RecordEnrichment_(double natural_u, double swu);
709
711 void RecordPosition();
712
713 #pragma cyclus var { "tooltip": "feed commodity", "doc": "feed commodity that the enrichment facility accepts", "uilabel": "Feed Commodity", "uitype": "incommodity" }
714#line 285 "/cycamore/src/enrichment.h"
715 std::string feed_commod;
716 std::vector<int> cycpp_shape_feed_commod;
717#line 286 "/cycamore/src/enrichment.h"
718
719
720 #pragma cyclus var { "tooltip": "feed recipe", "doc": "recipe for enrichment facility feed commodity", "uilabel": "Feed Recipe", "uitype": "inrecipe" }
721#line 293 "/cycamore/src/enrichment.h"
722 std::string feed_recipe;
723 std::vector<int> cycpp_shape_feed_recipe;
724#line 294 "/cycamore/src/enrichment.h"
725
726
727 #pragma cyclus var { "tooltip": "product commodity", "doc": "product commodity that the enrichment facility generates", "uilabel": "Product Commodity", "uitype": "outcommodity" }
728#line 301 "/cycamore/src/enrichment.h"
729 std::string product_commod;
731#line 302 "/cycamore/src/enrichment.h"
732
733
734 #pragma cyclus var { "tooltip": "tails commodity", "doc": "tails commodity supplied by enrichment facility", "uilabel": "Tails Commodity", "uitype": "outcommodity" }
735#line 309 "/cycamore/src/enrichment.h"
736 std::string tails_commod;
737 std::vector<int> cycpp_shape_tails_commod;
738#line 310 "/cycamore/src/enrichment.h"
739
740
741 #pragma cyclus var { "default": 0.003, "tooltip": "tails assay", "uilabel": "Tails Assay", "uitype": "range", "range": [0.0, 0.003], "doc": "tails assay from the enrichment process", }
742#line 318 "/cycamore/src/enrichment.h"
744 std::vector<int> cycpp_shape_tails_assay;
745#line 319 "/cycamore/src/enrichment.h"
746
747
748 #pragma cyclus var { "default": 0, "tooltip": "initial uranium reserves (kg)", "uilabel": "Initial Feed Inventory", "doc": "amount of natural uranium stored at the enrichment " "facility at the beginning of the simulation (kg)" }
749#line 326 "/cycamore/src/enrichment.h"
751 std::vector<int> cycpp_shape_initial_feed;
752#line 327 "/cycamore/src/enrichment.h"
753
754
755 #pragma cyclus var { "default": CY_LARGE_DOUBLE, "tooltip": "max inventory of feed material (kg)", "uilabel": "Maximum Feed Inventory", "uitype": "range", "range": [0.0, CY_LARGE_DOUBLE], "doc": "maximum total inventory of natural uranium in " "the enrichment facility (kg)" }
756#line 336 "/cycamore/src/enrichment.h"
759#line 337 "/cycamore/src/enrichment.h"
760
761
762 #pragma cyclus var { "default": 1.0, "tooltip": "maximum allowed enrichment fraction", "doc": "maximum allowed weight fraction of U235 in product", "uilabel": "Maximum Allowed Enrichment", "uitype": "range", "range": [0.0,1.0], "schema": '<optional>' ' <element name="max_enrich">' ' <data type="double">' ' <param name="minInclusive">0</param>' ' <param name="maxInclusive">1</param>' ' </data>' ' </element>' ' </optional>' }
763#line 354 "/cycamore/src/enrichment.h"
765 std::vector<int> cycpp_shape_max_enrich;
766#line 355 "/cycamore/src/enrichment.h"
767
768
769 #pragma cyclus var { "default": 1, "userlevel": 10, "tooltip": "Rank Material Requests by U235 Content", "uilabel": "Prefer feed with higher U235 content", "doc": "turn on preference ordering for input material " "so that EF chooses higher U235 content first" }
770#line 364 "/cycamore/src/enrichment.h"
772 std::vector<int> cycpp_shape_order_prefs;
773#line 365 "/cycamore/src/enrichment.h"
774
775
776 #pragma cyclus var { "default": CY_LARGE_DOUBLE, "tooltip": "SWU capacity (kgSWU/timestep)", "uilabel": "SWU Capacity", "uitype": "range", "range": [0.0, CY_LARGE_DOUBLE], "doc": "separative work unit (SWU) capacity of enrichment " "facility (kgSWU/timestep) " }
777#line 375 "/cycamore/src/enrichment.h"
779 std::vector<int> cycpp_shape_swu_capacity;
780
781#line 376 "/cycamore/src/enrichment.h"
782
784
785 #pragma cyclus var { 'capacity': 'max_feed_inventory' }
786 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
787 std::vector<int> cycpp_shape_inventory;
788 // natural u
789#line 381 "/cycamore/src/enrichment.h"
790 #pragma cyclus var {}
791 cyclus::toolkit::ResBuf<cyclus::Material> tails;
792 std::vector<int> cycpp_shape_tails;
793 // depleted u
794#line 383 "/cycamore/src/enrichment.h"
795
796 // used to total intra-timestep swu and natu usage for meeting requests -
797 // these help enable time series generation.
800
801 friend class EnrichmentTest;
802 // ---
803
804 #pragma cyclus var { "default": 0.0, "uilabel": "Geographical latitude in degrees as a double", "doc": "Latitude of the agent's geographical position. The value should " "be expressed in degrees as a double." }
805#line 398 "/cycamore/src/enrichment.h"
806 double latitude;
807 std::vector<int> cycpp_shape_latitude;
808#line 399 "/cycamore/src/enrichment.h"
809
810
811 #pragma cyclus var { "default": 0.0, "uilabel": "Geographical longitude in degrees as a double", "doc": "Longitude of the agent's geographical position. The value should " "be expressed in degrees as a double." }
812#line 406 "/cycamore/src/enrichment.h"
813 double longitude;
814 std::vector<int> cycpp_shape_longitude;
815
816#line 407 "/cycamore/src/enrichment.h"
817
818 cyclus::toolkit::Position coordinates;
819};
820
821} // namespace cycamore
822
823#endif // CYCAMORE_SRC_ENRICHMENT_FACILITY_H_
#define CYCAMORE_VERSION
The Enrichment facility is a simple Agent that enriches natural uranium in a Cyclus simulation.
void RecordPosition()
Records an agent's latitude and longitude to the output db.
cyclus::Material::Ptr Request_()
generates a request for this facility given its current state.
void SwuCapacity(double capacity)
cyclus::Material::Ptr Enrich_(cyclus::Material::Ptr mat, double qty)
cyclus::Material::Ptr Offer_(cyclus::Material::Ptr req)
Generates a material offer for a given request.
std::vector< int > cycpp_shape_max_enrich
std::vector< int > cycpp_shape_tails
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
The Enrichment request Materials of its given commodity.
void SetMaxInventorySize(double size)
std::vector< int > cycpp_shape_initial_feed
virtual void InitFrom(cyclus::QueryableBackend *b)
virtual void InfileToDb(cyclus::InfileTree *tree, cyclus::DbInit di)
const cyclus::toolkit::ResBuf< cyclus::Material > & Tails() const
virtual void InitInv(cyclus::Inventories &inv)
virtual void Tock()
Each facility is prompted to its end-of-time-step stuff on the tock of the timer.
cyclus::toolkit::ResBuf< cyclus::Material > tails
virtual void Snapshot(cyclus::DbInit di)
bool ValidReq(const cyclus::Material::Ptr mat)
Determines if a particular material is a valid request to respond to.
cyclus::toolkit::Position coordinates
virtual ~Enrichment()
Destructor for the Enrichment class.
virtual cyclus::Inventories SnapshotInv()
virtual void AdjustMatlPrefs(cyclus::PrefMap< cyclus::Material >::type &prefs)
The Enrichment adjusts preferences for offers of natural uranium it has received to maximize U-235 co...
virtual cyclus::Agent * Clone()
virtual std::string str()
Print information about this agent.
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
The Enrichment place accepted trade Materials in their Inventory.
double FeedAssay()
calculates the feed assay based on the unenriched inventory
std::vector< int > cycpp_shape_tails_commod
virtual std::set< cyclus::BidPortfolio< cyclus::Material >::Ptr > GetMatlBids(cyclus::CommodMap< cyclus::Material >::type &commod_requests)
Responds to each request for this facility's commodity.
virtual void Tick()
Each facility is prompted to do its beginning-of-time-step stuff at the tick of the timer.
std::vector< int > cycpp_shape_feed_recipe
std::vector< int > cycpp_shape_feed_commod
void RecordEnrichment_(double natural_u, double swu)
records and enrichment with the cyclus::Recorder
virtual Json::Value annotations()
virtual std::string version()
std::vector< int > cycpp_shape_order_prefs
Enrichment(cyclus::Context *ctx)
Constructor for the Enrichment class.
std::vector< int > cycpp_shape_max_feed_inventory
virtual void InitFrom(cycamore::Enrichment *m)
std::vector< int > cycpp_shape_product_commod
cyclus::toolkit::ResBuf< cyclus::Material > inventory
std::vector< int > cycpp_shape_tails_assay
std::vector< int > cycpp_shape_inventory
std::vector< int > cycpp_shape_longitude
virtual void GetMatlTrades(const std::vector< cyclus::Trade< cyclus::Material > > &trades, std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
respond to each trade with a material enriched to the appropriate level given this facility's invento...
virtual void Build(cyclus::Agent *parent)
perform module-specific tasks when entering the simulation
void AddMat_(cyclus::Material::Ptr mat)
adds a material into the natural uranium inventory
std::vector< int > cycpp_shape_swu_capacity
std::vector< int > cycpp_shape_latitude
The NatUConverter is a simple Converter class for material to determine the amount of natural uranium...
virtual bool operator==(Converter &other) const
NatUConverter(double feed_commod, double tails)
virtual double convert(cyclus::Material::Ptr m, cyclus::Arc const *a=NULL, cyclus::ExchangeTranslationContext< cyclus::Material > const *ctx=NULL) const
provides a conversion for the amount of natural Uranium required
The SWUConverter is a simple Converter class for material to determine the amount of SWU required for...
virtual double convert(cyclus::Material::Ptr m, cyclus::Arc const *a=NULL, cyclus::ExchangeTranslationContext< cyclus::Material > const *ctx=NULL) const
provides a conversion for the SWU required
SWUConverter(double feed_commod, double tails)
virtual bool operator==(Converter &other) const