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 void EnterNotify();
139
140 virtual std::string version() { return CYCAMORE_VERSION; }
142 cyclus::Facility::InitFrom(m);
143 int rawcycpp_shape_latitude[1] = {-1};
144 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
145 int rawcycpp_shape_longitude[1] = {-1};
146 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
147 int rawcycpp_shape_feed_commod[1] = {-1};
148 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
149 int rawcycpp_shape_feed_recipe[1] = {-1};
150 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
151 int rawcycpp_shape_product_commod[1] = {-1};
152 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
153 int rawcycpp_shape_tails_commod[1] = {-1};
154 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
155 int rawcycpp_shape_tails_assay[1] = {-1};
156 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
157 int rawcycpp_shape_initial_feed[1] = {-1};
158 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
159 int rawcycpp_shape_max_feed_inventory[1] = {-1};
160 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
161 int rawcycpp_shape_max_enrich[1] = {-1};
162 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
163 int rawcycpp_shape_order_prefs[1] = {-1};
164 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
165 int rawcycpp_shape_swu_capacity[1] = {-1};
166 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
167 int rawcycpp_shape_inventory[2] = {-1, -1};
168 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
169 int rawcycpp_shape_tails[2] = {-1, -1};
170 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
171 latitude = m->latitude;
172 longitude = m->longitude;
183 inventory.capacity(m->inventory.capacity());
184 tails.capacity(m->tails.capacity());
185 };
186#line 172 "/cycamore/src/enrichment.h"
187
188 virtual void InitFrom(cyclus::QueryableBackend* b) {
189 cyclus::Facility::InitFrom(b);
190 int rawcycpp_shape_latitude[1] = {-1};
191 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
192 int rawcycpp_shape_longitude[1] = {-1};
193 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
194 int rawcycpp_shape_feed_commod[1] = {-1};
195 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
196 int rawcycpp_shape_feed_recipe[1] = {-1};
197 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
198 int rawcycpp_shape_product_commod[1] = {-1};
199 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
200 int rawcycpp_shape_tails_commod[1] = {-1};
201 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
202 int rawcycpp_shape_tails_assay[1] = {-1};
203 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
204 int rawcycpp_shape_initial_feed[1] = {-1};
205 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
206 int rawcycpp_shape_max_feed_inventory[1] = {-1};
207 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
208 int rawcycpp_shape_max_enrich[1] = {-1};
209 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
210 int rawcycpp_shape_order_prefs[1] = {-1};
211 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
212 int rawcycpp_shape_swu_capacity[1] = {-1};
213 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
214 int rawcycpp_shape_inventory[2] = {-1, -1};
215 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
216 int rawcycpp_shape_tails[2] = {-1, -1};
217 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
218 cyclus::QueryResult qr = b->Query("Info", NULL);
219 latitude = qr.GetVal<double>("latitude");
220 longitude = qr.GetVal<double>("longitude");
221 feed_commod = qr.GetVal<std::string>("feed_commod");
222 feed_recipe = qr.GetVal<std::string>("feed_recipe");
223 product_commod = qr.GetVal<std::string>("product_commod");
224 tails_commod = qr.GetVal<std::string>("tails_commod");
225 tails_assay = qr.GetVal<double>("tails_assay");
226 initial_feed = qr.GetVal<double>("initial_feed");
227 max_feed_inventory = qr.GetVal<double>("max_feed_inventory");
228 max_enrich = qr.GetVal<double>("max_enrich");
229 order_prefs = qr.GetVal<bool>("order_prefs");
230 swu_capacity = qr.GetVal<double>("swu_capacity");
232 tails.capacity(1e+300);
233 };
234
235 virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
236 cyclus::Facility::InfileToDb(tree, di);
237 int rawcycpp_shape_latitude[1] = {-1};
238 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
239 int rawcycpp_shape_longitude[1] = {-1};
240 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
241 int rawcycpp_shape_feed_commod[1] = {-1};
242 cycpp_shape_feed_commod = std::vector<int>(rawcycpp_shape_feed_commod, rawcycpp_shape_feed_commod + 1);
243 int rawcycpp_shape_feed_recipe[1] = {-1};
244 cycpp_shape_feed_recipe = std::vector<int>(rawcycpp_shape_feed_recipe, rawcycpp_shape_feed_recipe + 1);
245 int rawcycpp_shape_product_commod[1] = {-1};
246 cycpp_shape_product_commod = std::vector<int>(rawcycpp_shape_product_commod, rawcycpp_shape_product_commod + 1);
247 int rawcycpp_shape_tails_commod[1] = {-1};
248 cycpp_shape_tails_commod = std::vector<int>(rawcycpp_shape_tails_commod, rawcycpp_shape_tails_commod + 1);
249 int rawcycpp_shape_tails_assay[1] = {-1};
250 cycpp_shape_tails_assay = std::vector<int>(rawcycpp_shape_tails_assay, rawcycpp_shape_tails_assay + 1);
251 int rawcycpp_shape_initial_feed[1] = {-1};
252 cycpp_shape_initial_feed = std::vector<int>(rawcycpp_shape_initial_feed, rawcycpp_shape_initial_feed + 1);
253 int rawcycpp_shape_max_feed_inventory[1] = {-1};
254 cycpp_shape_max_feed_inventory = std::vector<int>(rawcycpp_shape_max_feed_inventory, rawcycpp_shape_max_feed_inventory + 1);
255 int rawcycpp_shape_max_enrich[1] = {-1};
256 cycpp_shape_max_enrich = std::vector<int>(rawcycpp_shape_max_enrich, rawcycpp_shape_max_enrich + 1);
257 int rawcycpp_shape_order_prefs[1] = {-1};
258 cycpp_shape_order_prefs = std::vector<int>(rawcycpp_shape_order_prefs, rawcycpp_shape_order_prefs + 1);
259 int rawcycpp_shape_swu_capacity[1] = {-1};
260 cycpp_shape_swu_capacity = std::vector<int>(rawcycpp_shape_swu_capacity, rawcycpp_shape_swu_capacity + 1);
261 int rawcycpp_shape_inventory[2] = {-1, -1};
262 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
263 int rawcycpp_shape_tails[2] = {-1, -1};
264 cycpp_shape_tails = std::vector<int>(rawcycpp_shape_tails, rawcycpp_shape_tails + 2);
265 cyclus::InfileTree* sub = tree->SubTree("config/*");
266 int i;
267 int n;
268 if (sub->NMatches("latitude") > 0) {
269 {
270 double latitude_val = cyclus::Query<double>(sub, "latitude");
271 latitude = latitude_val;
272 }
273 } else {
274 double latitude_tmp = 0.0;
275 latitude = latitude_tmp;
276 }
277 if (sub->NMatches("longitude") > 0) {
278 {
279 double longitude_val = cyclus::Query<double>(sub, "longitude");
280 longitude = longitude_val;
281 }
282 } else {
283 double longitude_tmp = 0.0;
284 longitude = longitude_tmp;
285 }
286 {
287 std::string feed_commod_val = cyclus::Query<std::string>(sub, "feed_commod");
288 feed_commod = feed_commod_val;
289 }
290 {
291 std::string feed_recipe_val = cyclus::Query<std::string>(sub, "feed_recipe");
292 feed_recipe = feed_recipe_val;
293 }
294 {
295 std::string product_commod_val = cyclus::Query<std::string>(sub, "product_commod");
296 product_commod = product_commod_val;
297 }
298 {
299 std::string tails_commod_val = cyclus::Query<std::string>(sub, "tails_commod");
300 tails_commod = tails_commod_val;
301 }
302 if (sub->NMatches("tails_assay") > 0) {
303 {
304 double tails_assay_val = cyclus::Query<double>(sub, "tails_assay");
305 tails_assay = tails_assay_val;
306 }
307 } else {
308 double tails_assay_tmp = 0.003;
309 tails_assay = tails_assay_tmp;
310 }
311 if (sub->NMatches("initial_feed") > 0) {
312 {
313 double initial_feed_val = cyclus::Query<double>(sub, "initial_feed");
314 initial_feed = initial_feed_val;
315 }
316 } else {
317 double initial_feed_tmp = 0;
318 initial_feed = initial_feed_tmp;
319 }
320 if (sub->NMatches("max_feed_inventory") > 0) {
321 {
322 double max_feed_inventory_val = cyclus::Query<double>(sub, "max_feed_inventory");
323 max_feed_inventory = max_feed_inventory_val;
324 }
325 } else {
326 double max_feed_inventory_tmp = 1e+299;
327 max_feed_inventory = max_feed_inventory_tmp;
328 }
329 if (sub->NMatches("max_enrich") > 0) {
330 {
331 double max_enrich_val = cyclus::Query<double>(sub, "max_enrich");
332 max_enrich = max_enrich_val;
333 }
334 } else {
335 double max_enrich_tmp = 1.0;
336 max_enrich = max_enrich_tmp;
337 }
338 if (sub->NMatches("order_prefs") > 0) {
339 {
340 bool order_prefs_val = cyclus::Query<bool>(sub, "order_prefs");
341 order_prefs = order_prefs_val;
342 }
343 } else {
344 bool order_prefs_tmp = true;
345 order_prefs = order_prefs_tmp;
346 }
347 if (sub->NMatches("swu_capacity") > 0) {
348 {
349 double swu_capacity_val = cyclus::Query<double>(sub, "swu_capacity");
350 swu_capacity = swu_capacity_val;
351 }
352 } else {
353 double swu_capacity_tmp = 1e+299;
354 swu_capacity = swu_capacity_tmp;
355 }
356 di.NewDatum("Info")
357 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
358 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
359 ->AddVal("feed_commod", feed_commod, &cycpp_shape_feed_commod)
360 ->AddVal("feed_recipe", feed_recipe, &cycpp_shape_feed_recipe)
361 ->AddVal("product_commod", product_commod, &cycpp_shape_product_commod)
362 ->AddVal("tails_commod", tails_commod, &cycpp_shape_tails_commod)
363 ->AddVal("tails_assay", tails_assay, &cycpp_shape_tails_assay)
364 ->AddVal("initial_feed", initial_feed, &cycpp_shape_initial_feed)
365 ->AddVal("max_feed_inventory", max_feed_inventory, &cycpp_shape_max_feed_inventory)
366 ->AddVal("max_enrich", max_enrich, &cycpp_shape_max_enrich)
367 ->AddVal("order_prefs", order_prefs, &cycpp_shape_order_prefs)
368 ->AddVal("swu_capacity", swu_capacity, &cycpp_shape_swu_capacity)
369 ->Record();
370 };
371
372 virtual cyclus::Agent* Clone() {
373 cycamore::Enrichment* m = new cycamore::Enrichment(context());
374 m->InitFrom(this);
375 return m;
376 };
377
378 virtual std::string schema() {
379 return ""
380 "<interleave>\n"
381 " <optional>\n"
382 " <element name=\"latitude\">\n"
383 " <a:documentation>Latitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
384 " <data type=\"double\"/>\n"
385 " </element>\n"
386 " </optional>\n"
387 " <optional>\n"
388 " <element name=\"longitude\">\n"
389 " <a:documentation>Longitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
390 " <data type=\"double\"/>\n"
391 " </element>\n"
392 " </optional>\n"
393 " <element name=\"feed_commod\">\n"
394 " <a:documentation>feed commodity that the enrichment facility accepts</a:documentation>\n"
395 " <data type=\"string\"/>\n"
396 " </element>\n"
397 " <element name=\"feed_recipe\">\n"
398 " <a:documentation>recipe for enrichment facility feed commodity</a:documentation>\n"
399 " <data type=\"string\"/>\n"
400 " </element>\n"
401 " <element name=\"product_commod\">\n"
402 " <a:documentation>product commodity that the enrichment facility generates</a:documentation>\n"
403 " <data type=\"string\"/>\n"
404 " </element>\n"
405 " <element name=\"tails_commod\">\n"
406 " <a:documentation>tails commodity supplied by enrichment facility</a:documentation>\n"
407 " <data type=\"string\"/>\n"
408 " </element>\n"
409 " <optional>\n"
410 " <element name=\"tails_assay\">\n"
411 " <a:documentation>tails assay from the enrichment process</a:documentation>\n"
412 " <data type=\"double\"/>\n"
413 " </element>\n"
414 " </optional>\n"
415 " <optional>\n"
416 " <element name=\"initial_feed\">\n"
417 " <a:documentation>amount of natural uranium stored at the enrichment facility at the beginning of the simulation (kg)</a:documentation>\n"
418 " <data type=\"double\"/>\n"
419 " </element>\n"
420 " </optional>\n"
421 " <optional>\n"
422 " <element name=\"max_feed_inventory\">\n"
423 " <a:documentation>maximum total inventory of natural uranium in the enrichment facility (kg)</a:documentation>\n"
424 " <data type=\"double\"/>\n"
425 " </element>\n"
426 " </optional>\n"
427 " <optional>\n"
428 " <element name=\"max_enrich\">\n"
429 " <data type=\"double\">\n"
430 " <param name=\"minInclusive\">0</param>\n"
431 " <param name=\"maxInclusive\">1</param>\n"
432 " </data>\n"
433 " </element>\n"
434 " </optional>\n"
435 " <optional>\n"
436 " <element name=\"order_prefs\">\n"
437 " <a:documentation>turn on preference ordering for input material so that EF chooses higher U235 content first</a:documentation>\n"
438 " <data type=\"boolean\"/>\n"
439 " </element>\n"
440 " </optional>\n"
441 " <optional>\n"
442 " <element name=\"swu_capacity\">\n"
443 " <a:documentation>separative work unit (SWU) capacity of enrichment facility (kgSWU/timestep) </a:documentation>\n"
444 " <data type=\"double\"/>\n"
445 " </element>\n"
446 " </optional>\n"
447 "</interleave>\n";
448 };
449
450 virtual Json::Value annotations() {
451 Json::Value root;
452 Json::Reader reader;
453 bool parsed_ok = reader.parse(
454 "{\"name\":\"cycamore::Enrichment\",\"entity\":\"facility\""
455 ",\"parents\":[\"cyclus::Facility\",\"cyclus::toolkit::P"
456 "osition\"],\"all_parents\":[\"EconomicEntity\",\"cyclus:"
457 ":Agent\",\"cyclus::Facility\",\"cyclus::Ider\",\"cyclus:"
458 ":StateWrangler\",\"cyclus::TimeListener\",\"cyclus::Tr"
459 "ader\",\"cyclus::toolkit::Position\"],\"vars\":{\"latitu"
460 "de\":{\"default\":0.0,\"uilabel\":\"Geographical "
461 "latitude in degrees as a double\",\"doc\":\"Latitude "
462 "of the agent's geographical position. The value "
463 "should be expressed in degrees as a double.\",\"type"
464 "\":\"double\",\"index\":0,\"shape\":[-"
465 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
466 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
467 "longitude in degrees as a double\",\"doc\":\"Longitude"
468 " of the agent's geographical position. The value "
469 "should be expressed in degrees as a double.\",\"type"
470 "\":\"double\",\"index\":1,\"shape\":[-"
471 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"},\"fee"
472 "d_commod\":{\"tooltip\":\"feed commodity\",\"doc\":\"feed "
473 "commodity that the enrichment facility "
474 "accepts\",\"uilabel\":\"Feed Commodity\",\"uitype\":\"inco"
475 "mmodity\",\"type\":\"std::string\",\"index\":2,\"shape\":[-"
476 "1],\"alias\":\"feed_commod\"},\"feed_recipe\":{\"tooltip\""
477 ":\"feed recipe\",\"doc\":\"recipe for enrichment "
478 "facility feed commodity\",\"uilabel\":\"Feed Recipe\",\""
479 "uitype\":\"inrecipe\",\"type\":\"std::string\",\"index\":3,"
480 "\"shape\":[-"
481 "1],\"alias\":\"feed_recipe\"},\"product_commod\":{\"toolt"
482 "ip\":\"product commodity\",\"doc\":\"product commodity "
483 "that the enrichment facility "
484 "generates\",\"uilabel\":\"Product Commodity\",\"uitype\":"
485 "\"outcommodity\",\"type\":\"std::string\",\"index\":4,\"sha"
486 "pe\":[-"
487 "1],\"alias\":\"product_commod\"},\"tails_commod\":{\"tool"
488 "tip\":\"tails commodity\",\"doc\":\"tails commodity "
489 "supplied by enrichment facility\",\"uilabel\":\"Tails "
490 "Commodity\",\"uitype\":\"outcommodity\",\"type\":\"std::st"
491 "ring\",\"index\":5,\"shape\":[-"
492 "1],\"alias\":\"tails_commod\"},\"tails_assay\":{\"default"
493 "\":0.003,\"tooltip\":\"tails assay\",\"uilabel\":\"Tails A"
494 "ssay\",\"uitype\":\"range\",\"range\":[0.0,0.003],\"doc\":\""
495 "tails assay from the enrichment process\",\"type\":\"d"
496 "ouble\",\"index\":6,\"shape\":[-"
497 "1],\"alias\":\"tails_assay\"},\"initial_feed\":{\"default"
498 "\":0,\"tooltip\":\"initial uranium reserves "
499 "(kg)\",\"uilabel\":\"Initial Feed "
500 "Inventory\",\"doc\":\"amount of natural uranium stored"
501 " at the enrichment facility at the beginning of "
502 "the simulation (kg)\",\"type\":\"double\",\"index\":7,\"sh"
503 "ape\":[-"
504 "1],\"alias\":\"initial_feed\"},\"max_feed_inventory\":{\""
505 "default\":1e+299,\"tooltip\":\"max inventory of feed "
506 "material (kg)\",\"uilabel\":\"Maximum Feed Inventory\","
507 "\"uitype\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"maxim"
508 "um total inventory of natural uranium in the "
509 "enrichment facility (kg)\",\"type\":\"double\",\"index\":"
510 "8,\"shape\":[-"
511 "1],\"alias\":\"max_feed_inventory\"},\"max_enrich\":{\"de"
512 "fault\":1.0,\"tooltip\":\"maximum allowed enrichment "
513 "fraction\",\"doc\":\"maximum allowed weight fraction "
514 "of U235 in product\",\"uilabel\":\"Maximum Allowed Enr"
515 "ichment\",\"uitype\":\"range\",\"range\":[0.0,1.0],\"schem"
516 "a\":\"<optional> <element "
517 "name=\\\"max_enrich\\\"> <data "
518 "type=\\\"double\\\"> <param "
519 "name=\\\"minInclusive\\\">0</param> "
520 "<param name=\\\"maxInclusive\\\">1</param>"
521 " </data> </element> </o"
522 "ptional>\",\"type\":\"double\",\"index\":9,\"shape\":[-"
523 "1],\"alias\":\"max_enrich\"},\"order_prefs\":{\"default\":"
524 "1,\"userlevel\":10,\"tooltip\":\"Rank Material Requests"
525 " by U235 Content\",\"uilabel\":\"Prefer feed with "
526 "higher U235 content\",\"doc\":\"turn on preference "
527 "ordering for input material so that EF chooses "
528 "higher U235 content first\",\"type\":\"bool\",\"index\":1"
529 "0,\"shape\":[-"
530 "1],\"alias\":\"order_prefs\"},\"swu_capacity\":{\"default"
531 "\":1e+299,\"tooltip\":\"SWU capacity "
532 "(kgSWU/timestep)\",\"uilabel\":\"SWU Capacity\",\"uitype"
533 "\":\"range\",\"range\":[0.0,1e+299],\"doc\":\"separative "
534 "work unit (SWU) capacity of enrichment facility "
535 "(kgSWU/timestep) \",\"type\":\"double\",\"index\":11,\"sha"
536 "pe\":[-"
537 "1],\"alias\":\"swu_capacity\"},\"inventory\":{\"capacity\""
538 ":\"max_feed_inventory\",\"type\":[\"cyclus::toolkit::Re"
539 "sBuf\",\"cyclus::Material\"],\"index\":12,\"shape\":[-1,-"
540 "1]},\"tails\":{\"type\":[\"cyclus::toolkit::ResBuf\",\"cy"
541 "clus::Material\"],\"index\":13,\"shape\":[-1,-"
542 "1]}},\"niche\":\"enrichment facility\",\"doc\":\"The "
543 "Enrichment facility is a simple agent that "
544 "enriches natural uranium in a Cyclus simulation. "
545 "It does not explicitly compute the physical "
546 "enrichment process, rather it calculates the SWU "
547 "required to convert a source uranium recipe (i.e. "
548 "natural uranium) into a requested enriched recipe "
549 "(i.e. 4% enriched uranium), given the natural "
550 "uranium inventory constraint and its SWU capacity "
551 "constraint.\\n\\nThe Enrichment facility requests an"
552 " input commodity and associated recipe whose "
553 "quantity is its remaining inventory capacity. All"
554 " facilities trading the same input commodity (even"
555 " with different recipes) will offer materials for "
556 "trade. The Enrichment facility accepts any input "
557 "materials with enrichments less than its tails "
558 "assay, as long as some U235 is present, and "
559 "preference increases with U235 content. If no "
560 "U235 is present in the offered material, the trade"
561 " preference is set to -1 and the material is not "
562 "accepted. Any material components other than U235"
563 " and U238 are sent directly to the tails "
564 "buffer.\\n\\nThe Enrichment facility will bid on any"
565 " request for its output commodity up to the "
566 "maximum allowed enrichment (if not specified, "
567 "default is 100%) It bids on either the request "
568 "quantity, or the maximum quanity allowed by its "
569 "SWU constraint or natural uranium inventory, "
570 "whichever is lower. If multiple output commodities"
571 " with different enrichment levels are requested "
572 "and the facility does not have the SWU or quantity"
573 " capacity to meet all requests, the requests are "
574 "fully, then partially filled in unspecified but "
575 "repeatable order. A request for the product "
576 "commodity without an associated requested enriched"
577 " recipe will not be fulfilled.\\n\\nAccumulated "
578 "tails inventory is offered for trading as a "
579 "specifiable output commodity.\"}", root);
580 if (!parsed_ok) {
581 throw cyclus::ValueError("failed to parse annotations for cycamore::Enrichment.");
582 }
583 return root;
584 };
585
586 virtual void InitInv(cyclus::Inventories& inv) {
587 inventory.Push(inv["inventory"]);
588 tails.Push(inv["tails"]);
589
590 };
591
592 virtual cyclus::Inventories SnapshotInv() {
593 cyclus::Inventories invs;
594 invs["inventory"] = inventory.PopNRes(inventory.count());
595 inventory.Push(invs["inventory"]);
596 invs["tails"] = tails.PopNRes(tails.count());
597 tails.Push(invs["tails"]);
598 return invs;
599 };
600
601 virtual void Snapshot(cyclus::DbInit di) {
602 di.NewDatum("Info")
603 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
604 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
605 ->AddVal("feed_commod", feed_commod, &cycpp_shape_feed_commod)
606 ->AddVal("feed_recipe", feed_recipe, &cycpp_shape_feed_recipe)
607 ->AddVal("product_commod", product_commod, &cycpp_shape_product_commod)
608 ->AddVal("tails_commod", tails_commod, &cycpp_shape_tails_commod)
609 ->AddVal("tails_assay", tails_assay, &cycpp_shape_tails_assay)
610 ->AddVal("initial_feed", initial_feed, &cycpp_shape_initial_feed)
611 ->AddVal("max_feed_inventory", max_feed_inventory, &cycpp_shape_max_feed_inventory)
612 ->AddVal("max_enrich", max_enrich, &cycpp_shape_max_enrich)
613 ->AddVal("order_prefs", order_prefs, &cycpp_shape_order_prefs)
614 ->AddVal("swu_capacity", swu_capacity, &cycpp_shape_swu_capacity)
615 ->Record();
616 };
617#line 174 "/cycamore/src/enrichment.h"
618
620 virtual std::string str();
621 // ---
622
623 // --- Facility Members ---
625 virtual void Build(cyclus::Agent* parent);
626 // ---
627
628 // --- Agent Members ---
631
633 virtual void Tick();
634
637
639 virtual void Tock();
640
643 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
645
649 virtual void AdjustMatlPrefs(cyclus::PrefMap<cyclus::Material>::type& prefs);
650
653 virtual void AcceptMatlTrades(
654 const std::vector< std::pair<cyclus::Trade<cyclus::Material>,
655 cyclus::Material::Ptr> >& responses);
656
660 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr>
661 GetMatlBids(cyclus::CommodMap<cyclus::Material>::type&
662 commod_requests);
663
669 virtual void GetMatlTrades(
670 const std::vector< cyclus::Trade<cyclus::Material> >& trades,
671 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
672 cyclus::Material::Ptr> >& responses);
673 // ---
674
679 bool ValidReq(const cyclus::Material::Ptr mat);
680
681 inline void SetMaxInventorySize(double size) {
682 max_feed_inventory = size;
683 inventory.capacity(size);
684 }
685
686 inline void SwuCapacity(double capacity) {
687 swu_capacity = capacity;
689 }
690
691 inline double SwuCapacity() const { return swu_capacity; }
692
693 inline const cyclus::toolkit::ResBuf<cyclus::Material>& Tails() const {
694 return tails;
695 }
696
697 private:
698 // Code Injection:
699 #include "toolkit/position.cycpp.h"
700
703 void AddMat_(cyclus::Material::Ptr mat);
704
707 cyclus::Material::Ptr Request_();
708
715 cyclus::Material::Ptr Offer_(cyclus::Material::Ptr req);
716
717 cyclus::Material::Ptr Enrich_(cyclus::Material::Ptr mat, double qty);
718
720 double FeedAssay();
721
723 void RecordEnrichment_(double natural_u, double swu);
724
725 #pragma cyclus var { "tooltip": "feed commodity", "doc": "feed commodity that the enrichment facility accepts", "uilabel": "Feed Commodity", "uitype": "incommodity" }
726#line 287 "/cycamore/src/enrichment.h"
727 std::string feed_commod;
728 std::vector<int> cycpp_shape_feed_commod;
729#line 288 "/cycamore/src/enrichment.h"
730
731
732 #pragma cyclus var { "tooltip": "feed recipe", "doc": "recipe for enrichment facility feed commodity", "uilabel": "Feed Recipe", "uitype": "inrecipe" }
733#line 295 "/cycamore/src/enrichment.h"
734 std::string feed_recipe;
735 std::vector<int> cycpp_shape_feed_recipe;
736#line 296 "/cycamore/src/enrichment.h"
737
738
739 #pragma cyclus var { "tooltip": "product commodity", "doc": "product commodity that the enrichment facility generates", "uilabel": "Product Commodity", "uitype": "outcommodity" }
740#line 303 "/cycamore/src/enrichment.h"
741 std::string product_commod;
743#line 304 "/cycamore/src/enrichment.h"
744
745
746 #pragma cyclus var { "tooltip": "tails commodity", "doc": "tails commodity supplied by enrichment facility", "uilabel": "Tails Commodity", "uitype": "outcommodity" }
747#line 311 "/cycamore/src/enrichment.h"
748 std::string tails_commod;
749 std::vector<int> cycpp_shape_tails_commod;
750#line 312 "/cycamore/src/enrichment.h"
751
752
753 #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", }
754#line 320 "/cycamore/src/enrichment.h"
756 std::vector<int> cycpp_shape_tails_assay;
757#line 321 "/cycamore/src/enrichment.h"
758
759
760 #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)" }
761#line 328 "/cycamore/src/enrichment.h"
763 std::vector<int> cycpp_shape_initial_feed;
764#line 329 "/cycamore/src/enrichment.h"
765
766
767 #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)" }
768#line 338 "/cycamore/src/enrichment.h"
771#line 339 "/cycamore/src/enrichment.h"
772
773
774 #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>' }
775#line 356 "/cycamore/src/enrichment.h"
777 std::vector<int> cycpp_shape_max_enrich;
778#line 357 "/cycamore/src/enrichment.h"
779
780
781 #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" }
782#line 366 "/cycamore/src/enrichment.h"
784 std::vector<int> cycpp_shape_order_prefs;
785#line 367 "/cycamore/src/enrichment.h"
786
787
788 #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) " }
789#line 377 "/cycamore/src/enrichment.h"
791 std::vector<int> cycpp_shape_swu_capacity;
792
793#line 378 "/cycamore/src/enrichment.h"
794
796
797 #pragma cyclus var { 'capacity': 'max_feed_inventory' }
798 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
799 std::vector<int> cycpp_shape_inventory;
800 // natural u
801#line 383 "/cycamore/src/enrichment.h"
802 #pragma cyclus var {}
803 cyclus::toolkit::ResBuf<cyclus::Material> tails;
804 std::vector<int> cycpp_shape_tails;
805 // depleted u
806#line 385 "/cycamore/src/enrichment.h"
807
808 // used to total intra-timestep swu and natu usage for meeting requests -
809 // these help enable time series generation.
812
813 friend class EnrichmentTest;
814 // ---
815
816};
817
818} // namespace cycamore
819
820#endif // CYCAMORE_SRC_ENRICHMENT_FACILITY_H_
#define CYCAMORE_VERSION
The Enrichment facility is a simple Agent that enriches natural uranium in a Cyclus simulation.
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.
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
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
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