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