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 " <a:documentation>feed commodity that the enrichment facility accepts</a:documentation>\n"
381 " <data type=\"string\"/>\n"
382 " </element>\n"
383 " <element name=\"feed_recipe\">\n"
384 " <a:documentation>recipe for enrichment facility feed commodity</a:documentation>\n"
385 " <data type=\"string\"/>\n"
386 " </element>\n"
387 " <element name=\"product_commod\">\n"
388 " <a:documentation>product commodity that the enrichment facility generates</a:documentation>\n"
389 " <data type=\"string\"/>\n"
390 " </element>\n"
391 " <element name=\"tails_commod\">\n"
392 " <a:documentation>tails commodity supplied by enrichment facility</a:documentation>\n"
393 " <data type=\"string\"/>\n"
394 " </element>\n"
395 " <optional>\n"
396 " <element name=\"tails_assay\">\n"
397 " <a:documentation>tails assay from the enrichment process</a:documentation>\n"
398 " <data type=\"double\"/>\n"
399 " </element>\n"
400 " </optional>\n"
401 " <optional>\n"
402 " <element name=\"initial_feed\">\n"
403 " <a:documentation>amount of natural uranium stored at the enrichment facility at the beginning of the simulation (kg)</a:documentation>\n"
404 " <data type=\"double\"/>\n"
405 " </element>\n"
406 " </optional>\n"
407 " <optional>\n"
408 " <element name=\"max_feed_inventory\">\n"
409 " <a:documentation>maximum total inventory of natural uranium in the enrichment facility (kg)</a:documentation>\n"
410 " <data type=\"double\"/>\n"
411 " </element>\n"
412 " </optional>\n"
413 " <optional>\n"
414 " <element name=\"max_enrich\">\n"
415 " <data type=\"double\">\n"
416 " <param name=\"minInclusive\">0</param>\n"
417 " <param name=\"maxInclusive\">1</param>\n"
418 " </data>\n"
419 " </element>\n"
420 " </optional>\n"
421 " <optional>\n"
422 " <element name=\"order_prefs\">\n"
423 " <a:documentation>turn on preference ordering for input material so that EF chooses higher U235 content first</a:documentation>\n"
424 " <data type=\"boolean\"/>\n"
425 " </element>\n"
426 " </optional>\n"
427 " <optional>\n"
428 " <element name=\"swu_capacity\">\n"
429 " <a:documentation>separative work unit (SWU) capacity of enrichment facility (kgSWU/timestep) </a:documentation>\n"
430 " <data type=\"double\"/>\n"
431 " </element>\n"
432 " </optional>\n"
433 " <optional>\n"
434 " <element name=\"latitude\">\n"
435 " <a:documentation>Latitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
436 " <data type=\"double\"/>\n"
437 " </element>\n"
438 " </optional>\n"
439 " <optional>\n"
440 " <element name=\"longitude\">\n"
441 " <a:documentation>Longitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
442 " <data type=\"double\"/>\n"
443 " </element>\n"
444 " </optional>\n"
445 "</interleave>\n";
446 };
447
448 virtual Json::Value annotations() {
449 Json::Value root;
450 Json::Reader reader;
451 bool parsed_ok = reader.parse(
452 "{\"name\":\"cycamore::Enrichment\",\"entity\":\"facility\""
453 ",\"parents\":[\"cyclus::Facility\",\"cyclus::toolkit::P"
454 "osition\"],\"all_parents\":[\"EconomicEntity\",\"cyclus:"
455 ":Agent\",\"cyclus::Facility\",\"cyclus::Ider\",\"cyclus:"
456 ":StateWrangler\",\"cyclus::TimeListener\",\"cyclus::Tr"
457 "ader\",\"cyclus::toolkit::Position\"],\"vars\":{\"feed_c"
458 "ommod\":{\"tooltip\":\"feed commodity\",\"doc\":\"feed "
459 "commodity that the enrichment facility "
460 "accepts\",\"uilabel\":\"Feed Commodity\",\"uitype\":\"inco"
461 "mmodity\",\"type\":\"std::string\",\"index\":0,\"shape\":[-"
462 "1],\"alias\":\"feed_commod\"},\"feed_recipe\":{\"tooltip\""
463 ":\"feed recipe\",\"doc\":\"recipe for enrichment "
464 "facility feed commodity\",\"uilabel\":\"Feed Recipe\",\""
465 "uitype\":\"inrecipe\",\"type\":\"std::string\",\"index\":1,"
466 "\"shape\":[-"
467 "1],\"alias\":\"feed_recipe\"},\"product_commod\":{\"toolt"
468 "ip\":\"product commodity\",\"doc\":\"product commodity "
469 "that the enrichment facility "
470 "generates\",\"uilabel\":\"Product Commodity\",\"uitype\":"
471 "\"outcommodity\",\"type\":\"std::string\",\"index\":2,\"sha"
472 "pe\":[-"
473 "1],\"alias\":\"product_commod\"},\"tails_commod\":{\"tool"
474 "tip\":\"tails commodity\",\"doc\":\"tails commodity "
475 "supplied by enrichment facility\",\"uilabel\":\"Tails "
476 "Commodity\",\"uitype\":\"outcommodity\",\"type\":\"std::st"
477 "ring\",\"index\":3,\"shape\":[-"
478 "1],\"alias\":\"tails_commod\"},\"tails_assay\":{\"default"
479 "\":0.003,\"tooltip\":\"tails assay\",\"uilabel\":\"Tails A"
480 "ssay\",\"uitype\":\"range\",\"range\":[0.0,0.003],\"doc\":\""
481 "tails assay from the enrichment process\",\"type\":\"d"
482 "ouble\",\"index\":4,\"shape\":[-"
483 "1],\"alias\":\"tails_assay\"},\"initial_feed\":{\"default"
484 "\":0,\"tooltip\":\"initial uranium reserves "
485 "(kg)\",\"uilabel\":\"Initial Feed "
486 "Inventory\",\"doc\":\"amount of natural uranium stored"
487 " at the enrichment facility at the beginning of "
488 "the simulation (kg)\",\"type\":\"double\",\"index\":5,\"sh"
489 "ape\":[-"
490 "1],\"alias\":\"initial_feed\"},\"max_feed_inventory\":{\""
491 "default\":1e+299,\"tooltip\":\"max inventory of feed "
492 "material (kg)\",\"uilabel\":\"Maximum Feed Inventory\","
493 "\"uitype\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"maxim"
494 "um total inventory of natural uranium in the "
495 "enrichment facility (kg)\",\"type\":\"double\",\"index\":"
496 "6,\"shape\":[-"
497 "1],\"alias\":\"max_feed_inventory\"},\"max_enrich\":{\"de"
498 "fault\":1.0,\"tooltip\":\"maximum allowed enrichment "
499 "fraction\",\"doc\":\"maximum allowed weight fraction "
500 "of U235 in product\",\"uilabel\":\"Maximum Allowed Enr"
501 "ichment\",\"uitype\":\"range\",\"range\":[0.0,1.0],\"schem"
502 "a\":\"<optional> <element "
503 "name=\\\"max_enrich\\\"> <data "
504 "type=\\\"double\\\"> <param "
505 "name=\\\"minInclusive\\\">0</param> "
506 "<param name=\\\"maxInclusive\\\">1</param>"
507 " </data> </element> </o"
508 "ptional>\",\"type\":\"double\",\"index\":7,\"shape\":[-"
509 "1],\"alias\":\"max_enrich\"},\"order_prefs\":{\"default\":"
510 "1,\"userlevel\":10,\"tooltip\":\"Rank Material Requests"
511 " by U235 Content\",\"uilabel\":\"Prefer feed with "
512 "higher U235 content\",\"doc\":\"turn on preference "
513 "ordering for input material so that EF chooses "
514 "higher U235 content first\",\"type\":\"bool\",\"index\":8"
515 ",\"shape\":[-"
516 "1],\"alias\":\"order_prefs\"},\"swu_capacity\":{\"default"
517 "\":1e+299,\"tooltip\":\"SWU capacity "
518 "(kgSWU/timestep)\",\"uilabel\":\"SWU Capacity\",\"uitype"
519 "\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"separative "
520 "work unit (SWU) capacity of enrichment facility "
521 "(kgSWU/timestep) \",\"type\":\"double\",\"index\":9,\"shap"
522 "e\":[-"
523 "1],\"alias\":\"swu_capacity\"},\"inventory\":{\"capacity\""
524 ":\"max_feed_inventory\",\"type\":[\"cyclus::toolkit::Re"
525 "sBuf\",\"cyclus::Material\"],\"index\":10,\"shape\":[-1,-"
526 "1]},\"tails\":{\"type\":[\"cyclus::toolkit::ResBuf\",\"cy"
527 "clus::Material\"],\"index\":11,\"shape\":[-1,-"
528 "1]},\"latitude\":{\"default\":0.0,\"uilabel\":\"Geographi"
529 "cal latitude in degrees as a "
530 "double\",\"doc\":\"Latitude of the agent's "
531 "geographical position. The value should be "
532 "expressed in degrees as a double.\",\"type\":\"double\""
533 ",\"index\":12,\"shape\":[-"
534 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
535 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
536 "longitude in degrees as a double\",\"doc\":\"Longitude"
537 " of the agent's geographical position. The value "
538 "should be expressed in degrees as a double.\",\"type"
539 "\":\"double\",\"index\":13,\"shape\":[-"
540 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"}},\"ni"
541 "che\":\"enrichment facility\",\"doc\":\"The Enrichment "
542 "facility is a simple agent that enriches natural "
543 "uranium in a Cyclus simulation. It does not "
544 "explicitly compute the physical enrichment "
545 "process, rather it calculates the SWU required to "
546 "convert a source uranium recipe (i.e. natural "
547 "uranium) into a requested enriched recipe (i.e. 4%"
548 " enriched uranium), given the natural uranium "
549 "inventory constraint and its SWU capacity "
550 "constraint.\\n\\nThe Enrichment facility requests an"
551 " input commodity and associated recipe whose "
552 "quantity is its remaining inventory capacity. All"
553 " facilities trading the same input commodity (even"
554 " with different recipes) will offer materials for "
555 "trade. The Enrichment facility accepts any input "
556 "materials with enrichments less than its tails "
557 "assay, as long as some U235 is present, and "
558 "preference increases with U235 content. If no "
559 "U235 is present in the offered material, the trade"
560 " preference is set to -1 and the material is not "
561 "accepted. Any material components other than U235"
562 " and U238 are sent directly to the tails "
563 "buffer.\\n\\nThe Enrichment facility will bid on any"
564 " request for its output commodity up to the "
565 "maximum allowed enrichment (if not specified, "
566 "default is 100%) It bids on either the request "
567 "quantity, or the maximum quanity allowed by its "
568 "SWU constraint or natural uranium inventory, "
569 "whichever is lower. If multiple output commodities"
570 " with different enrichment levels are requested "
571 "and the facility does not have the SWU or quantity"
572 " capacity to meet all requests, the requests are "
573 "fully, then partially filled in unspecified but "
574 "repeatable order. A request for the product "
575 "commodity without an associated requested enriched"
576 " recipe will not be fulfilled.\\n\\nAccumulated "
577 "tails inventory is offered for trading as a "
578 "specifiable output commodity.\"}", root);
579 if (!parsed_ok) {
580 throw cyclus::ValueError("failed to parse annotations for cycamore::Enrichment.");
581 }
582 return root;
583 };
584
585 virtual void InitInv(cyclus::Inventories& inv) {
586 inventory.Push(inv["inventory"]);
587 tails.Push(inv["tails"]);
588
589 };
590
591 virtual cyclus::Inventories SnapshotInv() {
592 cyclus::Inventories invs;
593 invs["inventory"] = inventory.PopNRes(inventory.count());
594 inventory.Push(invs["inventory"]);
595 invs["tails"] = tails.PopNRes(tails.count());
596 tails.Push(invs["tails"]);
597 return invs;
598 };
599
600 virtual void Snapshot(cyclus::DbInit di) {
601 di.NewDatum("Info")
602 ->AddVal("feed_commod", feed_commod, &cycpp_shape_feed_commod)
603 ->AddVal("feed_recipe", feed_recipe, &cycpp_shape_feed_recipe)
604 ->AddVal("product_commod", product_commod, &cycpp_shape_product_commod)
605 ->AddVal("tails_commod", tails_commod, &cycpp_shape_tails_commod)
606 ->AddVal("tails_assay", tails_assay, &cycpp_shape_tails_assay)
607 ->AddVal("initial_feed", initial_feed, &cycpp_shape_initial_feed)
608 ->AddVal("max_feed_inventory", max_feed_inventory, &cycpp_shape_max_feed_inventory)
609 ->AddVal("max_enrich", max_enrich, &cycpp_shape_max_enrich)
610 ->AddVal("order_prefs", order_prefs, &cycpp_shape_order_prefs)
611 ->AddVal("swu_capacity", swu_capacity, &cycpp_shape_swu_capacity)
612 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
613 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
614 ->Record();
615 };
616#line 172 "/cycamore/src/enrichment.h"
617
619 virtual std::string str();
620 // ---
621
622 // --- Facility Members ---
624 virtual void Build(cyclus::Agent* parent);
625 // ---
626
627 // --- Agent Members ---
630
632 virtual void Tick();
633
636
638 virtual void Tock();
639
642 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
644
648 virtual void AdjustMatlPrefs(cyclus::PrefMap<cyclus::Material>::type& prefs);
649
652 virtual void AcceptMatlTrades(
653 const std::vector< std::pair<cyclus::Trade<cyclus::Material>,
654 cyclus::Material::Ptr> >& responses);
655
659 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr>
660 GetMatlBids(cyclus::CommodMap<cyclus::Material>::type&
661 commod_requests);
662
668 virtual void GetMatlTrades(
669 const std::vector< cyclus::Trade<cyclus::Material> >& trades,
670 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
671 cyclus::Material::Ptr> >& responses);
672 // ---
673
678 bool ValidReq(const cyclus::Material::Ptr mat);
679
680 inline void SetMaxInventorySize(double size) {
681 max_feed_inventory = size;
682 inventory.capacity(size);
683 }
684
685 inline void SwuCapacity(double capacity) {
686 swu_capacity = capacity;
688 }
689
690 inline double SwuCapacity() const { return swu_capacity; }
691
692 inline const cyclus::toolkit::ResBuf<cyclus::Material>& Tails() const {
693 return tails;
694 }
695
696 private:
699 void AddMat_(cyclus::Material::Ptr mat);
700
703 cyclus::Material::Ptr Request_();
704
711 cyclus::Material::Ptr Offer_(cyclus::Material::Ptr req);
712
713 cyclus::Material::Ptr Enrich_(cyclus::Material::Ptr mat, double qty);
714
716 double FeedAssay();
717
719 void RecordEnrichment_(double natural_u, double swu);
720
722 void RecordPosition();
723
724 #pragma cyclus var { "tooltip": "feed commodity", "doc": "feed commodity that the enrichment facility accepts", "uilabel": "Feed Commodity", "uitype": "incommodity" }
725#line 285 "/cycamore/src/enrichment.h"
726 std::string feed_commod;
727 std::vector<int> cycpp_shape_feed_commod;
728#line 286 "/cycamore/src/enrichment.h"
729
730
731 #pragma cyclus var { "tooltip": "feed recipe", "doc": "recipe for enrichment facility feed commodity", "uilabel": "Feed Recipe", "uitype": "inrecipe" }
732#line 293 "/cycamore/src/enrichment.h"
733 std::string feed_recipe;
734 std::vector<int> cycpp_shape_feed_recipe;
735#line 294 "/cycamore/src/enrichment.h"
736
737
738 #pragma cyclus var { "tooltip": "product commodity", "doc": "product commodity that the enrichment facility generates", "uilabel": "Product Commodity", "uitype": "outcommodity" }
739#line 301 "/cycamore/src/enrichment.h"
740 std::string product_commod;
742#line 302 "/cycamore/src/enrichment.h"
743
744
745 #pragma cyclus var { "tooltip": "tails commodity", "doc": "tails commodity supplied by enrichment facility", "uilabel": "Tails Commodity", "uitype": "outcommodity" }
746#line 309 "/cycamore/src/enrichment.h"
747 std::string tails_commod;
748 std::vector<int> cycpp_shape_tails_commod;
749#line 310 "/cycamore/src/enrichment.h"
750
751
752 #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", }
753#line 318 "/cycamore/src/enrichment.h"
755 std::vector<int> cycpp_shape_tails_assay;
756#line 319 "/cycamore/src/enrichment.h"
757
758
759 #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)" }
760#line 326 "/cycamore/src/enrichment.h"
762 std::vector<int> cycpp_shape_initial_feed;
763#line 327 "/cycamore/src/enrichment.h"
764
765
766 #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)" }
767#line 336 "/cycamore/src/enrichment.h"
770#line 337 "/cycamore/src/enrichment.h"
771
772
773 #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>' }
774#line 354 "/cycamore/src/enrichment.h"
776 std::vector<int> cycpp_shape_max_enrich;
777#line 355 "/cycamore/src/enrichment.h"
778
779
780 #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" }
781#line 364 "/cycamore/src/enrichment.h"
783 std::vector<int> cycpp_shape_order_prefs;
784#line 365 "/cycamore/src/enrichment.h"
785
786
787 #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) " }
788#line 375 "/cycamore/src/enrichment.h"
790 std::vector<int> cycpp_shape_swu_capacity;
791
792#line 376 "/cycamore/src/enrichment.h"
793
795
796 #pragma cyclus var { 'capacity': 'max_feed_inventory' }
797 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
798 std::vector<int> cycpp_shape_inventory;
799 // natural u
800#line 381 "/cycamore/src/enrichment.h"
801 #pragma cyclus var {}
802 cyclus::toolkit::ResBuf<cyclus::Material> tails;
803 std::vector<int> cycpp_shape_tails;
804 // depleted u
805#line 383 "/cycamore/src/enrichment.h"
806
807 // used to total intra-timestep swu and natu usage for meeting requests -
808 // these help enable time series generation.
811
812 friend class EnrichmentTest;
813 // ---
814
815 #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." }
816#line 398 "/cycamore/src/enrichment.h"
817 double latitude;
818 std::vector<int> cycpp_shape_latitude;
819#line 399 "/cycamore/src/enrichment.h"
820
821
822 #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." }
823#line 406 "/cycamore/src/enrichment.h"
824 double longitude;
825 std::vector<int> cycpp_shape_longitude;
826
827#line 407 "/cycamore/src/enrichment.h"
828
829 cyclus::toolkit::Position coordinates;
830};
831
832} // namespace cycamore
833
834#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
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
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