CYCAMORE
Loading...
Searching...
No Matches
build/cycamore/source.h
Go to the documentation of this file.
1
2#line 1 "/cycamore/src/source.h"
3#ifndef CYCAMORE_SRC_SOURCE_H_
4#define CYCAMORE_SRC_SOURCE_H_
5
6#include <set>
7#include <vector>
8
9#include "cyclus.h"
10#include "cycamore_version.h"
11
12#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
13
14namespace cycamore {
15
16class Context;
17
27class Source : public cyclus::Facility,
28 public cyclus::toolkit::CommodityProducer,
29 public cyclus::toolkit::Position {
30 friend class SourceTest;
31 public:
32
33 Source(cyclus::Context* ctx);
34
35 virtual ~Source();
36
37 virtual std::string version() { return CYCAMORE_VERSION; }
38
39 #pragma cyclus note { "doc": "This facility acts as a source of material with a fixed throughput (per\n" "time step) capacity and a lifetime capacity defined by a total inventory\n" "size. It offers its material as a single commodity. If a composition\n" "recipe is specified, it provides that single material composition to\n" "requesters. If unspecified, the source provides materials with the exact\n" "requested compositions. The inventory size and throughput both default to\n" "infinite. Supplies material results in corresponding decrease in\n" "inventory, and when the inventory size reaches zero, the source can provide\n" "no more material.\n" "", }
40#line 49 "/cycamore/src/source.h"
41
42 virtual cyclus::Agent* Clone() {
43 cycamore::Source* m = new cycamore::Source(context());
44 m->InitFrom(this);
45 return m;
46 };
47
48 virtual std::string schema() {
49 return ""
50 "<interleave>\n"
51 " <element name=\"outcommod\">\n"
52 " <data type=\"string\"/>\n"
53 " </element>\n"
54 " <optional>\n"
55 " <element name=\"outrecipe\">\n"
56 " <data type=\"string\"/>\n"
57 " </element>\n"
58 " </optional>\n"
59 " <optional>\n"
60 " <element name=\"inventory_size\">\n"
61 " <data type=\"double\"/>\n"
62 " </element>\n"
63 " </optional>\n"
64 " <optional>\n"
65 " <element name=\"throughput\">\n"
66 " <data type=\"double\"/>\n"
67 " </element>\n"
68 " </optional>\n"
69 " <optional>\n"
70 " <element name=\"package\">\n"
71 " <data type=\"string\"/>\n"
72 " </element>\n"
73 " </optional>\n"
74 " <optional>\n"
75 " <element name=\"transport_unit\">\n"
76 " <data type=\"string\"/>\n"
77 " </element>\n"
78 " </optional>\n"
79 " <optional>\n"
80 " <element name=\"latitude\">\n"
81 " <data type=\"double\"/>\n"
82 " </element>\n"
83 " </optional>\n"
84 " <optional>\n"
85 " <element name=\"longitude\">\n"
86 " <data type=\"double\"/>\n"
87 " </element>\n"
88 " </optional>\n"
89 "</interleave>\n";
90 };
91
92 virtual Json::Value annotations() {
93 Json::Value root;
94 Json::Reader reader;
95 bool parsed_ok = reader.parse(
96 "{\"name\":\"cycamore::Source\",\"entity\":\"facility\",\"pa"
97 "rents\":[\"cyclus::Facility\",\"cyclus::toolkit::Commo"
98 "dityProducer\",\"cyclus::toolkit::Position\"],\"all_pa"
99 "rents\":[\"cyclus::Agent\",\"cyclus::Facility\",\"cyclus"
100 "::Ider\",\"cyclus::StateWrangler\",\"cyclus::TimeListe"
101 "ner\",\"cyclus::Trader\",\"cyclus::toolkit::AgentManag"
102 "ed\",\"cyclus::toolkit::CommodityProducer\",\"cyclus::"
103 "toolkit::Position\"],\"vars\":{\"outcommod\":{\"tooltip\""
104 ":\"source output commodity\",\"doc\":\"Output commodity"
105 " on which the source offers "
106 "material.\",\"uilabel\":\"Output Commodity\",\"uitype\":\""
107 "outcommodity\",\"type\":\"std::string\",\"index\":0,\"shap"
108 "e\":[-"
109 "1],\"alias\":\"outcommod\"},\"outrecipe\":{\"tooltip\":\"na"
110 "me of material recipe to provide\",\"doc\":\"Name of "
111 "composition recipe that this source provides "
112 "regardless of requested composition. If empty, "
113 "source creates and provides whatever compositions "
114 "are requested.\",\"uilabel\":\"Output Recipe\",\"default"
115 "\":\"\",\"uitype\":\"outrecipe\",\"type\":\"std::string\",\"in"
116 "dex\":1,\"shape\":[-"
117 "1],\"alias\":\"outrecipe\"},\"inventory_size\":{\"doc\":\"T"
118 "otal amount of material this source has remaining."
119 " Every trade decreases this value by the supplied "
120 "material quantity. When it reaches zero, the "
121 "source cannot provide any more material.\",\"defaul"
122 "t\":1e+299,\"uitype\":\"range\",\"range\":[0.0,1e+299],\"u"
123 "ilabel\":\"Initial Inventory\",\"units\":\"kg\",\"type\":\"d"
124 "ouble\",\"index\":2,\"shape\":[-"
125 "1],\"alias\":\"inventory_size\",\"tooltip\":\"inventory_s"
126 "ize\"},\"throughput\":{\"default\":1e+299,\"tooltip\":\"pe"
127 "r time step throughput\",\"units\":\"kg/(time "
128 "step)\",\"uilabel\":\"Maximum Throughput\",\"uitype\":\"ra"
129 "nge\",\"range\":[0.0,1e+299],\"doc\":\"amount of "
130 "commodity that can be supplied at each time step\","
131 "\"type\":\"double\",\"index\":3,\"shape\":[-"
132 "1],\"alias\":\"throughput\"},\"package\":{\"default\":\"unp"
133 "ackaged\",\"tooltip\":\"name of package to provide "
134 "material in\",\"doc\":\"Name of package that this "
135 "source provides. Offers will only bemade in "
136 "packagable quantities of "
137 "material.\",\"uilabel\":\"Output Package Type\",\"uitype"
138 "\":\"package\",\"type\":\"std::string\",\"index\":4,\"shape\""
139 ":[-"
140 "1],\"alias\":\"package\"},\"transport_unit\":{\"default\":"
141 "\"unrestricted\",\"tooltip\":\"name of transport unit "
142 "to ship packages in\",\"doc\":\"Name of transport unit"
143 " that this source uses to ship packages of "
144 "material. Offers will only be made in shippable "
145 "quantities of packages. Optional if packaging is "
146 "used, but use of transport units requires "
147 "packaging type to also be set\",\"uilabel\":\"Output "
148 "Transport Unit Type\",\"uitype\":\"transportunit\",\"typ"
149 "e\":\"std::string\",\"index\":5,\"shape\":[-"
150 "1],\"alias\":\"transport_unit\"},\"latitude\":{\"default\""
151 ":0.0,\"uilabel\":\"Geographical latitude in degrees "
152 "as a double\",\"doc\":\"Latitude of the agent's "
153 "geographical position. The value should be "
154 "expressed in degrees as a double.\",\"type\":\"double\""
155 ",\"index\":6,\"shape\":[-"
156 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
157 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
158 "longitude in degrees as a double\",\"doc\":\"Longitude"
159 " of the agent's geographical position. The value "
160 "should be expressed in degrees as a double.\",\"type"
161 "\":\"double\",\"index\":7,\"shape\":[-"
162 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"},\"inv"
163 "entory\":{\"tooltip\":\"Material buffer\",\"type\":[\"cycl"
164 "us::toolkit::ResBuf\",\"cyclus::Material\"],\"index\":8"
165 ",\"shape\":[-1,-1]}},\"doc\":\"This facility acts as a "
166 "source of material with a fixed throughput "
167 "(per\\ntime step) capacity and a lifetime capacity "
168 "defined by a total inventory\\nsize. It offers its"
169 " material as a single commodity. If a "
170 "composition\\nrecipe is specified, it provides that"
171 " single material composition to\\nrequesters. If "
172 "unspecified, the source provides materials with "
173 "the exact\\nrequested compositions. The inventory "
174 "size and throughput both default to\\ninfinite. "
175 "Supplies material results in corresponding "
176 "decrease in\\ninventory, and when the inventory "
177 "size reaches zero, the source can provide\\nno more"
178 " material.\\n\"}", root);
179 if (!parsed_ok) {
180 throw cyclus::ValueError("failed to parse annotations for cycamore::Source.");
181 }
182 return root;
183 };
184
185 virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
186 cyclus::Facility::InfileToDb(tree, di);
187 int rawcycpp_shape_outcommod[1] = {-1};
188 cycpp_shape_outcommod = std::vector<int>(rawcycpp_shape_outcommod, rawcycpp_shape_outcommod + 1);
189 int rawcycpp_shape_outrecipe[1] = {-1};
190 cycpp_shape_outrecipe = std::vector<int>(rawcycpp_shape_outrecipe, rawcycpp_shape_outrecipe + 1);
191 int rawcycpp_shape_inventory_size[1] = {-1};
192 cycpp_shape_inventory_size = std::vector<int>(rawcycpp_shape_inventory_size, rawcycpp_shape_inventory_size + 1);
193 int rawcycpp_shape_throughput[1] = {-1};
194 cycpp_shape_throughput = std::vector<int>(rawcycpp_shape_throughput, rawcycpp_shape_throughput + 1);
195 int rawcycpp_shape_package[1] = {-1};
196 cycpp_shape_package = std::vector<int>(rawcycpp_shape_package, rawcycpp_shape_package + 1);
197 int rawcycpp_shape_transport_unit[1] = {-1};
198 cycpp_shape_transport_unit = std::vector<int>(rawcycpp_shape_transport_unit, rawcycpp_shape_transport_unit + 1);
199 int rawcycpp_shape_latitude[1] = {-1};
200 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
201 int rawcycpp_shape_longitude[1] = {-1};
202 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
203 int rawcycpp_shape_inventory[2] = {-1, -1};
204 cycpp_shape_inventory = std::vector<int>(rawcycpp_shape_inventory, rawcycpp_shape_inventory + 2);
205 cyclus::InfileTree* sub = tree->SubTree("config/*");
206 int i;
207 int n;
208 {
209 std::string outcommod_val = cyclus::Query<std::string>(sub, "outcommod");
210 outcommod = outcommod_val;
211 }
212 if (sub->NMatches("outrecipe") > 0) {
213 {
214 std::string outrecipe_val = cyclus::Query<std::string>(sub, "outrecipe");
215 outrecipe = outrecipe_val;
216 }
217 } else {
218 std::string outrecipe_tmp("");
219 outrecipe = outrecipe_tmp;
220 }
221 if (sub->NMatches("inventory_size") > 0) {
222 {
223 double inventory_size_val = cyclus::Query<double>(sub, "inventory_size");
224 inventory_size = inventory_size_val;
225 }
226 } else {
227 double inventory_size_tmp = 1e+299;
228 inventory_size = inventory_size_tmp;
229 }
230 if (sub->NMatches("throughput") > 0) {
231 {
232 double throughput_val = cyclus::Query<double>(sub, "throughput");
233 throughput = throughput_val;
234 }
235 } else {
236 double throughput_tmp = 1e+299;
237 throughput = throughput_tmp;
238 }
239 if (sub->NMatches("package") > 0) {
240 {
241 std::string package_val = cyclus::Query<std::string>(sub, "package");
242 package = package_val;
243 }
244 } else {
245 std::string package_tmp("unpackaged");
246 package = package_tmp;
247 }
248 if (sub->NMatches("transport_unit") > 0) {
249 {
250 std::string transport_unit_val = cyclus::Query<std::string>(sub, "transport_unit");
251 transport_unit = transport_unit_val;
252 }
253 } else {
254 std::string transport_unit_tmp("unrestricted");
255 transport_unit = transport_unit_tmp;
256 }
257 if (sub->NMatches("latitude") > 0) {
258 {
259 double latitude_val = cyclus::Query<double>(sub, "latitude");
260 latitude = latitude_val;
261 }
262 } else {
263 double latitude_tmp = 0.0;
264 latitude = latitude_tmp;
265 }
266 if (sub->NMatches("longitude") > 0) {
267 {
268 double longitude_val = cyclus::Query<double>(sub, "longitude");
269 longitude = longitude_val;
270 }
271 } else {
272 double longitude_tmp = 0.0;
273 longitude = longitude_tmp;
274 }
275 di.NewDatum("Info")
276 ->AddVal("outcommod", outcommod, &cycpp_shape_outcommod)
277 ->AddVal("outrecipe", outrecipe, &cycpp_shape_outrecipe)
278 ->AddVal("inventory_size", inventory_size, &cycpp_shape_inventory_size)
279 ->AddVal("throughput", throughput, &cycpp_shape_throughput)
280 ->AddVal("package", package, &cycpp_shape_package)
281 ->AddVal("transport_unit", transport_unit, &cycpp_shape_transport_unit)
282 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
283 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
284 ->Record();
285 };
286
287 virtual void Snapshot(cyclus::DbInit di) {
288 di.NewDatum("Info")
289 ->AddVal("outcommod", outcommod, &cycpp_shape_outcommod)
290 ->AddVal("outrecipe", outrecipe, &cycpp_shape_outrecipe)
291 ->AddVal("inventory_size", inventory_size, &cycpp_shape_inventory_size)
292 ->AddVal("throughput", throughput, &cycpp_shape_throughput)
293 ->AddVal("package", package, &cycpp_shape_package)
294 ->AddVal("transport_unit", transport_unit, &cycpp_shape_transport_unit)
295 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
296 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
297 ->Record();
298 };
299
300 virtual cyclus::Inventories SnapshotInv() {
301 cyclus::Inventories invs;
302 invs["inventory"] = inventory.PopNRes(inventory.count());
303 inventory.Push(invs["inventory"]);
304 return invs;
305 };
306
307 virtual void InitInv(cyclus::Inventories& inv) {
308 inventory.Push(inv["inventory"]);
309
310 };
311#line 57 "/cycamore/src/source.h"
312
313 virtual void InitFrom(Source* m);
314
315 virtual void InitFrom(cyclus::QueryableBackend* b);
316
317 virtual void Tick() {};
318
319 virtual void Tock() {};
320
321 virtual std::string str();
322
323 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr>
324 GetMatlBids(cyclus::CommodMap<cyclus::Material>::type&
325 commod_requests);
326
327 virtual void EnterNotify();
328
331 virtual void Build(cyclus::Agent* parent);
332
333 virtual void GetMatlTrades(
334 const std::vector< cyclus::Trade<cyclus::Material> >& trades,
335 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
336 cyclus::Material::Ptr> >& responses);
337
338 private:
339 #pragma cyclus var { "tooltip": "source output commodity", "doc": "Output commodity on which the source offers material.", "uilabel": "Output Commodity", "uitype": "outcommodity", }
340#line 90 "/cycamore/src/source.h"
341 std::string outcommod;
342 std::vector<int> cycpp_shape_outcommod;
343#line 91 "/cycamore/src/source.h"
344
345
346 #pragma cyclus var { "tooltip": "name of material recipe to provide", "doc": "Name of composition recipe that this source provides regardless " "of requested composition. If empty, source creates and provides " "whatever compositions are requested.", "uilabel": "Output Recipe", "default": "", "uitype": "outrecipe", }
347#line 101 "/cycamore/src/source.h"
348 std::string outrecipe;
349 std::vector<int> cycpp_shape_outrecipe;
350#line 102 "/cycamore/src/source.h"
351
352
353 #pragma cyclus var { "doc": "Total amount of material this source has remaining." " Every trade decreases this value by the supplied material " "quantity. When it reaches zero, the source cannot provide any " " more material.", "default": CY_LARGE_DOUBLE, "uitype": "range", "range": [0.0, CY_LARGE_DOUBLE], "uilabel": "Initial Inventory", "units": "kg", }
354#line 114 "/cycamore/src/source.h"
357#line 115 "/cycamore/src/source.h"
358
359
360 #pragma cyclus var { "default": CY_LARGE_DOUBLE, "tooltip": "per time step throughput", "units": "kg/(time step)", "uilabel": "Maximum Throughput", "uitype": "range", "range": [0.0, CY_LARGE_DOUBLE], "doc": "amount of commodity that can be supplied at each time step", }
361#line 125 "/cycamore/src/source.h"
363 std::vector<int> cycpp_shape_throughput;
364#line 126 "/cycamore/src/source.h"
365
366
367 #pragma cyclus var { "default": "unpackaged", "tooltip": "name of package to provide material in", "doc": "Name of package that this source provides. Offers will only be" "made in packagable quantities of material.", "uilabel": "Output Package Type", "uitype": "package", }
368#line 135 "/cycamore/src/source.h"
369 std::string package;
370 std::vector<int> cycpp_shape_package;
371#line 136 "/cycamore/src/source.h"
372
373
374 #pragma cyclus var { "default": "unrestricted", "tooltip": "name of transport unit to ship packages in", "doc": "Name of transport unit that this source uses to ship packages of " "material. Offers will only be made in shippable quantities of " "packages. Optional if packaging is used, but use of transport " "units requires packaging type to also be set", "uilabel": "Output Transport Unit Type", "uitype": "transportunit", }
375#line 147 "/cycamore/src/source.h"
376 std::string transport_unit;
378#line 148 "/cycamore/src/source.h"
379
380
381 #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." }
382#line 155 "/cycamore/src/source.h"
383 double latitude;
384 std::vector<int> cycpp_shape_latitude;
385#line 156 "/cycamore/src/source.h"
386
387
388 #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." }
389#line 163 "/cycamore/src/source.h"
390 double longitude;
391 std::vector<int> cycpp_shape_longitude;
392#line 164 "/cycamore/src/source.h"
393
394
395 #pragma cyclus var { "tooltip":"Material buffer"}
396#line 167 "/cycamore/src/source.h"
397 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
398 std::vector<int> cycpp_shape_inventory;
399
400#line 168 "/cycamore/src/source.h"
401
402 cyclus::toolkit::Position coordinates;
403
404 void RecordPosition();
406};
407
408} // namespace cycamore
409
410#endif // CYCAMORE_SRC_SOURCE_H_
#define CYCAMORE_VERSION
This facility acts as a source of material with a fixed throughput (per time step) capacity and a lif...
std::vector< int > cycpp_shape_longitude
std::vector< int > cycpp_shape_latitude
virtual void Snapshot(cyclus::DbInit di)
virtual cyclus::Agent * Clone()
virtual void Build(cyclus::Agent *parent)
— Facility Members — perform module-specific tasks when entering the simulation
virtual void InitInv(cyclus::Inventories &inv)
virtual std::string version()
std::vector< int > cycpp_shape_inventory_size
std::vector< int > cycpp_shape_package
std::vector< int > cycpp_shape_inventory
std::vector< int > cycpp_shape_transport_unit
virtual std::set< cyclus::BidPortfolio< cyclus::Material >::Ptr > GetMatlBids(cyclus::CommodMap< cyclus::Material >::type &commod_requests)
virtual void GetMatlTrades(const std::vector< cyclus::Trade< cyclus::Material > > &trades, std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
virtual void InfileToDb(cyclus::InfileTree *tree, cyclus::DbInit di)
cyclus::toolkit::Position coordinates
std::vector< int > cycpp_shape_throughput
Source(cyclus::Context *ctx)
cyclus::toolkit::ResBuf< cyclus::Material > inventory
virtual void InitFrom(Source *m)
std::vector< int > cycpp_shape_outcommod
virtual std::string str()
virtual std::string schema()
std::vector< int > cycpp_shape_outrecipe
virtual cyclus::Inventories SnapshotInv()
virtual Json::Value annotations()