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 " <optional>\n"
52 " <element name=\"latitude\">\n"
53 " <a:documentation>Latitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
54 " <data type=\"double\"/>\n"
55 " </element>\n"
56 " </optional>\n"
57 " <optional>\n"
58 " <element name=\"longitude\">\n"
59 " <a:documentation>Longitude of the agent's geographical position. The value should be expressed in degrees as a double.</a:documentation>\n"
60 " <data type=\"double\"/>\n"
61 " </element>\n"
62 " </optional>\n"
63 " <element name=\"outcommod\">\n"
64 " <a:documentation>Output commodity on which the source offers material.</a:documentation>\n"
65 " <data type=\"string\"/>\n"
66 " </element>\n"
67 " <optional>\n"
68 " <element name=\"outrecipe\">\n"
69 " <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"
70 " <data type=\"string\"/>\n"
71 " </element>\n"
72 " </optional>\n"
73 " <optional>\n"
74 " <element name=\"inventory_size\">\n"
75 " <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"
76 " <data type=\"double\"/>\n"
77 " </element>\n"
78 " </optional>\n"
79 " <optional>\n"
80 " <element name=\"throughput\">\n"
81 " <a:documentation>amount of commodity that can be supplied at each time step</a:documentation>\n"
82 " <data type=\"double\"/>\n"
83 " </element>\n"
84 " </optional>\n"
85 " <optional>\n"
86 " <element name=\"package\">\n"
87 " <a:documentation>Name of package that this source provides. Offers will only bemade in packagable quantities of material.</a:documentation>\n"
88 " <data type=\"string\"/>\n"
89 " </element>\n"
90 " </optional>\n"
91 " <optional>\n"
92 " <element name=\"transport_unit\">\n"
93 " <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"
94 " <data type=\"string\"/>\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\":{\"lati"
112 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
113 "latitude in degrees as a double\",\"doc\":\"Latitude "
114 "of the agent's geographical position. The value "
115 "should be expressed in degrees as a double.\",\"type"
116 "\":\"double\",\"index\":0,\"shape\":[-"
117 "1],\"alias\":\"latitude\",\"tooltip\":\"latitude\"},\"longi"
118 "tude\":{\"default\":0.0,\"uilabel\":\"Geographical "
119 "longitude in degrees as a double\",\"doc\":\"Longitude"
120 " of the agent's geographical position. The value "
121 "should be expressed in degrees as a double.\",\"type"
122 "\":\"double\",\"index\":1,\"shape\":[-"
123 "1],\"alias\":\"longitude\",\"tooltip\":\"longitude\"},\"out"
124 "commod\":{\"tooltip\":\"source output "
125 "commodity\",\"doc\":\"Output commodity on which the "
126 "source offers material.\",\"uilabel\":\"Output Commodi"
127 "ty\",\"uitype\":\"outcommodity\",\"type\":\"std::string\",\""
128 "index\":2,\"shape\":[-"
129 "1],\"alias\":\"outcommod\"},\"outrecipe\":{\"tooltip\":\"na"
130 "me of material recipe to provide\",\"doc\":\"Name of "
131 "composition recipe that this source provides "
132 "regardless of requested composition. If empty, "
133 "source creates and provides whatever compositions "
134 "are requested.\",\"uilabel\":\"Output Recipe\",\"default"
135 "\":\"\",\"uitype\":\"outrecipe\",\"type\":\"std::string\",\"in"
136 "dex\":3,\"shape\":[-"
137 "1],\"alias\":\"outrecipe\"},\"inventory_size\":{\"doc\":\"T"
138 "otal amount of material this source has remaining."
139 " Every trade decreases this value by the supplied "
140 "material quantity. When it reaches zero, the "
141 "source cannot provide any more material.\",\"defaul"
142 "t\":1e+299,\"uitype\":\"range\",\"range\":[0.0,1e+299],\"u"
143 "ilabel\":\"Initial Inventory\",\"units\":\"kg\",\"type\":\"d"
144 "ouble\",\"index\":4,\"shape\":[-"
145 "1],\"alias\":\"inventory_size\",\"tooltip\":\"inventory_s"
146 "ize\"},\"throughput\":{\"default\":1e+299,\"tooltip\":\"pe"
147 "r time step throughput\",\"units\":\"kg/(time "
148 "step)\",\"uilabel\":\"Maximum Throughput\",\"uitype\":\"ra"
149 "nge\",\"range\":[0.0,1e+299],\"doc\":\"amount of "
150 "commodity that can be supplied at each time step\","
151 "\"type\":\"double\",\"index\":5,\"shape\":[-"
152 "1],\"alias\":\"throughput\"},\"package\":{\"default\":\"unp"
153 "ackaged\",\"tooltip\":\"name of package to provide "
154 "material in\",\"doc\":\"Name of package that this "
155 "source provides. Offers will only bemade in "
156 "packagable quantities of "
157 "material.\",\"uilabel\":\"Output Package Type\",\"uitype"
158 "\":\"package\",\"type\":\"std::string\",\"index\":6,\"shape\""
159 ":[-"
160 "1],\"alias\":\"package\"},\"transport_unit\":{\"default\":"
161 "\"unrestricted\",\"tooltip\":\"name of transport unit "
162 "to ship packages in\",\"doc\":\"Name of transport unit"
163 " that this source uses to ship packages of "
164 "material. Offers will only be made in shippable "
165 "quantities of packages. Optional if packaging is "
166 "used, but use of transport units requires "
167 "packaging type to also be set\",\"uilabel\":\"Output "
168 "Transport Unit Type\",\"uitype\":\"transportunit\",\"typ"
169 "e\":\"std::string\",\"index\":7,\"shape\":[-"
170 "1],\"alias\":\"transport_unit\"},\"inventory\":{\"tooltip"
171 "\":\"Material buffer\",\"type\":[\"cyclus::toolkit::ResB"
172 "uf\",\"cyclus::Material\"],\"index\":8,\"shape\":[-1,-"
173 "1]}},\"doc\":\"This facility acts as a source of "
174 "material with a fixed throughput (per\\ntime step) "
175 "capacity and a lifetime capacity defined by a "
176 "total inventory\\nsize. It offers its material as "
177 "a single commodity. If a composition\\nrecipe is "
178 "specified, it provides that single material "
179 "composition to\\nrequesters. If unspecified, the "
180 "source provides materials with the "
181 "exact\\nrequested compositions. The inventory size"
182 " 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_latitude[1] = {-1};
196 cycpp_shape_latitude = std::vector<int>(rawcycpp_shape_latitude, rawcycpp_shape_latitude + 1);
197 int rawcycpp_shape_longitude[1] = {-1};
198 cycpp_shape_longitude = std::vector<int>(rawcycpp_shape_longitude, rawcycpp_shape_longitude + 1);
199 int rawcycpp_shape_outcommod[1] = {-1};
200 cycpp_shape_outcommod = std::vector<int>(rawcycpp_shape_outcommod, rawcycpp_shape_outcommod + 1);
201 int rawcycpp_shape_outrecipe[1] = {-1};
202 cycpp_shape_outrecipe = std::vector<int>(rawcycpp_shape_outrecipe, rawcycpp_shape_outrecipe + 1);
203 int rawcycpp_shape_inventory_size[1] = {-1};
204 cycpp_shape_inventory_size = std::vector<int>(rawcycpp_shape_inventory_size, rawcycpp_shape_inventory_size + 1);
205 int rawcycpp_shape_throughput[1] = {-1};
206 cycpp_shape_throughput = std::vector<int>(rawcycpp_shape_throughput, rawcycpp_shape_throughput + 1);
207 int rawcycpp_shape_package[1] = {-1};
208 cycpp_shape_package = std::vector<int>(rawcycpp_shape_package, rawcycpp_shape_package + 1);
209 int rawcycpp_shape_transport_unit[1] = {-1};
210 cycpp_shape_transport_unit = std::vector<int>(rawcycpp_shape_transport_unit, rawcycpp_shape_transport_unit + 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 if (sub->NMatches("latitude") > 0) {
217 {
218 double latitude_val = cyclus::Query<double>(sub, "latitude");
219 latitude = latitude_val;
220 }
221 } else {
222 double latitude_tmp = 0.0;
223 latitude = latitude_tmp;
224 }
225 if (sub->NMatches("longitude") > 0) {
226 {
227 double longitude_val = cyclus::Query<double>(sub, "longitude");
228 longitude = longitude_val;
229 }
230 } else {
231 double longitude_tmp = 0.0;
232 longitude = longitude_tmp;
233 }
234 {
235 std::string outcommod_val = cyclus::Query<std::string>(sub, "outcommod");
236 outcommod = outcommod_val;
237 }
238 if (sub->NMatches("outrecipe") > 0) {
239 {
240 std::string outrecipe_val = cyclus::Query<std::string>(sub, "outrecipe");
241 outrecipe = outrecipe_val;
242 }
243 } else {
244 std::string outrecipe_tmp("");
245 outrecipe = outrecipe_tmp;
246 }
247 if (sub->NMatches("inventory_size") > 0) {
248 {
249 double inventory_size_val = cyclus::Query<double>(sub, "inventory_size");
250 inventory_size = inventory_size_val;
251 }
252 } else {
253 double inventory_size_tmp = 1e+299;
254 inventory_size = inventory_size_tmp;
255 }
256 if (sub->NMatches("throughput") > 0) {
257 {
258 double throughput_val = cyclus::Query<double>(sub, "throughput");
259 throughput = throughput_val;
260 }
261 } else {
262 double throughput_tmp = 1e+299;
263 throughput = throughput_tmp;
264 }
265 if (sub->NMatches("package") > 0) {
266 {
267 std::string package_val = cyclus::Query<std::string>(sub, "package");
268 package = package_val;
269 }
270 } else {
271 std::string package_tmp("unpackaged");
272 package = package_tmp;
273 }
274 if (sub->NMatches("transport_unit") > 0) {
275 {
276 std::string transport_unit_val = cyclus::Query<std::string>(sub, "transport_unit");
277 transport_unit = transport_unit_val;
278 }
279 } else {
280 std::string transport_unit_tmp("unrestricted");
281 transport_unit = transport_unit_tmp;
282 }
283 di.NewDatum("Info")
284 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
285 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
286 ->AddVal("outcommod", outcommod, &cycpp_shape_outcommod)
287 ->AddVal("outrecipe", outrecipe, &cycpp_shape_outrecipe)
288 ->AddVal("inventory_size", inventory_size, &cycpp_shape_inventory_size)
289 ->AddVal("throughput", throughput, &cycpp_shape_throughput)
290 ->AddVal("package", package, &cycpp_shape_package)
291 ->AddVal("transport_unit", transport_unit, &cycpp_shape_transport_unit)
292 ->Record();
293 };
294
295 virtual void Snapshot(cyclus::DbInit di) {
296 di.NewDatum("Info")
297 ->AddVal("latitude", latitude, &cycpp_shape_latitude)
298 ->AddVal("longitude", longitude, &cycpp_shape_longitude)
299 ->AddVal("outcommod", outcommod, &cycpp_shape_outcommod)
300 ->AddVal("outrecipe", outrecipe, &cycpp_shape_outrecipe)
301 ->AddVal("inventory_size", inventory_size, &cycpp_shape_inventory_size)
302 ->AddVal("throughput", throughput, &cycpp_shape_throughput)
303 ->AddVal("package", package, &cycpp_shape_package)
304 ->AddVal("transport_unit", transport_unit, &cycpp_shape_transport_unit)
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 // Code Injection:
348 #include "toolkit/position.cycpp.h"
349
350 #pragma cyclus var { "tooltip": "source output commodity", "doc": "Output commodity on which the source offers material.", "uilabel": "Output Commodity", "uitype": "outcommodity", }
351#line 93 "/cycamore/src/source.h"
352 std::string outcommod;
353 std::vector<int> cycpp_shape_outcommod;
354#line 94 "/cycamore/src/source.h"
355
356
357 #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", }
358#line 104 "/cycamore/src/source.h"
359 std::string outrecipe;
360 std::vector<int> cycpp_shape_outrecipe;
361#line 105 "/cycamore/src/source.h"
362
363
364 #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", }
365#line 117 "/cycamore/src/source.h"
368#line 118 "/cycamore/src/source.h"
369
370
371 #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", }
372#line 128 "/cycamore/src/source.h"
374 std::vector<int> cycpp_shape_throughput;
375#line 129 "/cycamore/src/source.h"
376
377
378 #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", }
379#line 138 "/cycamore/src/source.h"
380 std::string package;
381 std::vector<int> cycpp_shape_package;
382#line 139 "/cycamore/src/source.h"
383
384
385 #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", }
386#line 150 "/cycamore/src/source.h"
387 std::string transport_unit;
389#line 151 "/cycamore/src/source.h"
390
391
392 #pragma cyclus var { "tooltip":"Material buffer"}
393#line 154 "/cycamore/src/source.h"
394 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
395 std::vector<int> cycpp_shape_inventory;
396
397#line 155 "/cycamore/src/source.h"
398
400};
401
402} // namespace cycamore
403
404#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...
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)
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()