CYCAMORE
Loading...
Searching...
No Matches
build/cycamore/reactor.h
Go to the documentation of this file.
1
2#line 1 "/cycamore/src/reactor.h"
3#ifndef CYCAMORE_SRC_REACTOR_H_
4#define CYCAMORE_SRC_REACTOR_H_
5
6#include "cyclus.h"
7#include "cycamore_version.h"
8
9namespace cycamore {
10
56
57class Reactor : public cyclus::Facility,
58 public cyclus::toolkit::CommodityProducer,
59 public cyclus::toolkit::Position {
60#pragma cyclus note { "niche": "reactor", "doc": "Reactor is a simple, general reactor based on static compositional" " transformations to model fuel burnup. The user specifies a set of input" " fuels and corresponding burnt compositions that fuel is transformed to when" " it is discharged from the core. No incremental transmutation takes place." " Rather, at the end of an operational cycle, the batch being discharged from" " the core is instantaneously transmuted from its original fresh fuel" " composition into its spent fuel form." "\n\n" "Each fuel is identified by a specific input commodity and has an associated" " input recipe (nuclide composition), output recipe, output commidity, and" " preference. The preference identifies which input fuels are preferred when" " requesting. Changes in these preferences can be specified as a function of" " time using the pref_change variables. Changes in the input-output recipe" " compositions can also be specified as a function of time using the" " recipe_change variables." "\n\n" "The reactor treats fuel as individual assemblies that are never split," " combined or otherwise treated in any non-discrete way. Fuel is requested" " in full-or-nothing assembly sized quanta. If real-world assembly modeling" " is unnecessary, parameters can be adjusted (e.g. n_assem_core, assem_size," " n_assem_batch). At the end of every cycle, a full batch is discharged from" " the core consisting of n_assem_batch assemblies of assem_size kg. The" " reactor also has a specifiable refueling time period following the end of" " each cycle at the end of which it will resume operation on the next cycle" " *if* it has enough fuel for a full core; otherwise it waits until it has" " enough fresh fuel assemblies." "\n\n" "In addition to its core, the reactor has an on-hand fresh fuel inventory" " and a spent fuel inventory whose capacities are specified by n_assem_fresh" " and n_assem_spent respectively. Each time step the reactor will attempt to" " acquire enough fresh fuel to fill its fresh fuel inventory (and its core if" " the core isn't currently full). If the fresh fuel inventory has zero" " capacity, fuel will be ordered just-in-time after the end of each" " operational cycle before the next begins. If the spent fuel inventory" " becomes full, the reactor will halt operation at the end of the next cycle" " until there is more room. Each time step, the reactor will try to trade" " away as much of its spent fuel inventory as possible." "\n\n" "When the reactor reaches the end of its lifetime, it will discharge all" " material from its core and trade away all its spent fuel as quickly as" " possible. Full decommissioning will be delayed until all spent fuel is" " gone. If the reactor has a full core when it is decommissioned (i.e. is" " mid-cycle) when the reactor is decommissioned, half (rounded up to nearest" " int) of its assemblies are transmuted to their respective burnt" " compositions." "", }
61#line 108 "/cycamore/src/reactor.h"
62
63 public:
64 Reactor(cyclus::Context* ctx);
65 virtual ~Reactor(){};
66
67 virtual std::string version() { return CYCAMORE_VERSION; }
68
69 virtual void Tick();
70 virtual void Tock();
71 virtual void EnterNotify();
72 virtual bool CheckDecommissionCondition();
73
74 virtual void AcceptMatlTrades(const std::vector<std::pair<
75 cyclus::Trade<cyclus::Material>, cyclus::Material::Ptr> >& responses);
76
77 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
79
80 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr> GetMatlBids(
81 cyclus::CommodMap<cyclus::Material>::type& commod_requests);
82
83 virtual void GetMatlTrades(
84 const std::vector<cyclus::Trade<cyclus::Material> >& trades,
85 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
86 cyclus::Material::Ptr> >& responses);
87 virtual void InitFrom(cycamore::Reactor* m);
88#line 133 "/cycamore/src/reactor.h"
89
90 virtual void InitFrom(cyclus::QueryableBackend* b);
91
92 virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di);
93
94 virtual cyclus::Agent* Clone();
95
96 virtual std::string schema();
97
98 virtual Json::Value annotations();
99
100 virtual void InitInv(cyclus::Inventories& inv);
101
102 virtual cyclus::Inventories SnapshotInv();
103
104 virtual void Snapshot(cyclus::DbInit di);
105#line 135 "/cycamore/src/reactor.h"
106
107 private:
108 // Code Injection:
109 #include "toolkit/position.cycpp.h"
110
111 std::string fuel_incommod(cyclus::Material::Ptr m);
112 std::string fuel_outcommod(cyclus::Material::Ptr m);
113 std::string fuel_inrecipe(cyclus::Material::Ptr m);
114 std::string fuel_outrecipe(cyclus::Material::Ptr m);
115 double fuel_pref(cyclus::Material::Ptr m);
116
117 bool retired() {
118 return exit_time() != -1 && context()->time() > exit_time();
119 }
120
122 void index_res(cyclus::Resource::Ptr m, std::string incommod);
123
126 bool Discharge();
127
129 void Load();
130
133 void Transmute();
134
136 void RecordSideProduct(bool produce);
137
140 void Transmute(int n_assem);
141
143 void Record(std::string name, std::string val);
144
147 void PushSpent(std::map<std::string, cyclus::toolkit::MatVec> leftover);
148
151 std::map<std::string, cyclus::toolkit::MatVec> PopSpent();
152
155 std::map<std::string, cyclus::toolkit::MatVec> PeekSpent();
156
158 #pragma cyclus var { "uitype": ["oneormore", "incommodity"], "uilabel": "Fresh Fuel Commodity List", "doc": "Ordered list of input commodities on which to requesting fuel.", }
159#line 192 "/cycamore/src/reactor.h"
160 std::vector<std::string> fuel_incommods;
162#line 193 "/cycamore/src/reactor.h"
163
164
165 #pragma cyclus var { "uitype": ["oneormore", "inrecipe"], "uilabel": "Fresh Fuel Recipe List", "doc": "Fresh fuel recipes to request for each of the given fuel input " "commodities (same order).", }
166#line 200 "/cycamore/src/reactor.h"
167 std::vector<std::string> fuel_inrecipes;
169#line 201 "/cycamore/src/reactor.h"
170
171
172 #pragma cyclus var { "default": [], "uilabel": "Fresh Fuel Preference List", "doc": "The preference for each type of fresh fuel requested corresponding" " to each input commodity (same order). If no preferences are " "specified, 1.0 is used for all fuel " "requests (default).", }
173#line 210 "/cycamore/src/reactor.h"
174 std::vector<double> fuel_prefs;
175 std::vector<int> cycpp_shape_fuel_prefs;
176#line 211 "/cycamore/src/reactor.h"
177
178
179 #pragma cyclus var { "uitype": ["oneormore", "outcommodity"], "uilabel": "Spent Fuel Commodity List", "doc": "Output commodities on which to offer spent fuel originally " "received as each particular input commodity (same order)." }
180#line 218 "/cycamore/src/reactor.h"
181 std::vector<std::string> fuel_outcommods;
183#line 219 "/cycamore/src/reactor.h"
184
185
186 #pragma cyclus var { "uitype": ["oneormore", "outrecipe"], "uilabel": "Spent Fuel Recipe List", "doc": "Spent fuel recipes corresponding to the given fuel input " "commodities (same order)." " Fuel received via a particular input commodity is transmuted to " "the recipe specified here after being burned during a cycle.", }
187#line 228 "/cycamore/src/reactor.h"
188 std::vector<std::string> fuel_outrecipes;
190
191#line 229 "/cycamore/src/reactor.h"
192
194 #pragma cyclus var { "default": [], "uilabel": "Time to Change Fresh/Spent Fuel Recipe", "doc": "A time step on which to change the input-output recipe pair for " "a requested fresh fuel.", }
195#line 237 "/cycamore/src/reactor.h"
196 std::vector<int> recipe_change_times;
198#line 238 "/cycamore/src/reactor.h"
199
200
201 #pragma cyclus var { "default": [], "uilabel": "Commodity for Changed Fresh/Spent Fuel Recipe", "doc": "The input commodity indicating fresh fuel for which recipes will " "be changed. Same order as and direct correspondence to the " "specified recipe change times.", "uitype": ["oneormore", "incommodity"], }
202#line 247 "/cycamore/src/reactor.h"
203 std::vector<std::string> recipe_change_commods;
205#line 248 "/cycamore/src/reactor.h"
206
207
208 #pragma cyclus var { "default": [], "uilabel": "New Recipe for Fresh Fuel", "doc": "The new input recipe to use for this recipe change." " Same order as and direct correspondence to the specified recipe " "change times.", "uitype": ["oneormore", "inrecipe"], }
209#line 257 "/cycamore/src/reactor.h"
210 std::vector<std::string> recipe_change_in;
212#line 258 "/cycamore/src/reactor.h"
213
214
215 #pragma cyclus var { "default": [], "uilabel": "New Recipe for Spent Fuel", "doc": "The new output recipe to use for this recipe change." " Same order as and direct correspondence to the specified recipe " "change times.", "uitype": ["oneormore", "outrecipe"], }
216#line 267 "/cycamore/src/reactor.h"
217 std::vector<std::string> recipe_change_out;
219
220#line 268 "/cycamore/src/reactor.h"
221
223 #pragma cyclus var { "doc": "Mass (kg) of a single assembly.", "uilabel": "Assembly Mass", "uitype": "range", "range": [1.0, 1e5], "units": "kg", }
224#line 277 "/cycamore/src/reactor.h"
226 std::vector<int> cycpp_shape_assem_size;
227#line 278 "/cycamore/src/reactor.h"
228
229
230 #pragma cyclus var { "uilabel": "Number of Assemblies per Batch", "doc": "Number of assemblies that constitute a single batch. " "This is the number of assemblies discharged from the core fully " "burned each cycle." "Batch size is equivalent to ``n_assem_batch / n_assem_core``.", }
231#line 286 "/cycamore/src/reactor.h"
234#line 287 "/cycamore/src/reactor.h"
235
236
237 #pragma cyclus var { "default": 3, "uilabel": "Number of Assemblies in Core", "uitype": "range", "range": [1,3], "doc": "Number of assemblies that constitute a full core.", }
238#line 295 "/cycamore/src/reactor.h"
240 std::vector<int> cycpp_shape_n_assem_core;
241#line 296 "/cycamore/src/reactor.h"
242
243
244 #pragma cyclus var { "default": 0, "uilabel": "Minimum Fresh Fuel Inventory", "uitype": "range", "range": [0,3], "units": "assemblies", "doc": "Number of fresh fuel assemblies to keep on-hand if possible.", }
245#line 305 "/cycamore/src/reactor.h"
248#line 306 "/cycamore/src/reactor.h"
249
250
251 #pragma cyclus var { "default": 1000000000, "uilabel": "Maximum Spent Fuel Inventory", "uitype": "range", "range": [0, 1000000000], "units": "assemblies", "doc": "Number of spent fuel assemblies that can be stored on-site before" " reactor operation stalls.", }
252#line 316 "/cycamore/src/reactor.h"
255
256#line 317 "/cycamore/src/reactor.h"
257
259 #pragma cyclus var { "default": 18, "doc": "The duration of a full operational cycle (excluding refueling " "time) in time steps.", "uilabel": "Cycle Length", "units": "time steps", }
260#line 326 "/cycamore/src/reactor.h"
262 std::vector<int> cycpp_shape_cycle_time;
263#line 327 "/cycamore/src/reactor.h"
264
265
266 #pragma cyclus var { "default": 1, "doc": "The duration of a full refueling period - the minimum time between" " the end of a cycle and the start of the next cycle.", "uilabel": "Refueling Outage Duration", "units": "time steps", }
267#line 335 "/cycamore/src/reactor.h"
269 std::vector<int> cycpp_shape_refuel_time;
270#line 336 "/cycamore/src/reactor.h"
271
272
273 #pragma cyclus var { "default": 0, "doc": "Number of time steps since the start of the last cycle." " Only set this if you know what you are doing", "uilabel": "Time Since Start of Last Cycle", "units": "time steps", }
274#line 344 "/cycamore/src/reactor.h"
276 std::vector<int> cycpp_shape_cycle_step;
277
278#line 345 "/cycamore/src/reactor.h"
279
281 #pragma cyclus var { "default": 0, "doc": "Amount of electrical power the facility produces when operating " "normally.", "uilabel": "Nominal Reactor Power", "uitype": "range", "range": [0.0, 2000.00], "units": "MWe", }
282#line 356 "/cycamore/src/reactor.h"
283 double power_cap;
284 std::vector<int> cycpp_shape_power_cap;
285#line 357 "/cycamore/src/reactor.h"
286
287
288 #pragma cyclus var { "default": "power", "uilabel": "Power Commodity Name", "doc": "The name of the 'power' commodity used in conjunction with a " "deployment curve.", }
289#line 364 "/cycamore/src/reactor.h"
290 std::string power_name;
291 std::vector<int> cycpp_shape_power_name;
292
293#line 365 "/cycamore/src/reactor.h"
294
296
297 #pragma cyclus var { "uilabel": "Side Product from Reactor Plant", "default": [], "doc": "Ordered vector of side product the reactor produces with power", }
298#line 373 "/cycamore/src/reactor.h"
299 std::vector<std::string> side_products;
301#line 374 "/cycamore/src/reactor.h"
302
303
304 #pragma cyclus var { "uilabel": "Quantity of Side Product from Reactor Plant", "default": [], "doc": "Ordered vector of the quantity of side product the reactor produces with power", }
305#line 380 "/cycamore/src/reactor.h"
306 std::vector<double> side_product_quantity;
308#line 381 "/cycamore/src/reactor.h"
309
310
311 #pragma cyclus var {"default": 1, "internal": True, "doc": "True if reactor is a hybrid system (produces side products)", }
312#line 386 "/cycamore/src/reactor.h"
314 std::vector<int> cycpp_shape_hybrid_;
315
316#line 387 "/cycamore/src/reactor.h"
317
318
320 #pragma cyclus var {"default": 0, "uilabel": "Boolean for transmutation behavior upon decommissioning.", "doc": "If true, the archetype transmutes all assemblies upon decommissioning " "If false, the archetype only transmutes half.", }
321#line 395 "/cycamore/src/reactor.h"
324
325#line 396 "/cycamore/src/reactor.h"
326
327
329 #pragma cyclus var { "default": [], "uilabel": "Time to Change Fresh Fuel Preference", "doc": "A time step on which to change the request preference for a " "particular fresh fuel type.", }
330#line 405 "/cycamore/src/reactor.h"
331 std::vector<int> pref_change_times;
333#line 406 "/cycamore/src/reactor.h"
334
335
336 #pragma cyclus var { "default": [], "doc": "The input commodity for a particular fuel preference change. " "Same order as and direct correspondence to the specified " "preference change times.", "uilabel": "Commodity for Changed Fresh Fuel Preference", "uitype": ["oneormore", "incommodity"], }
337#line 415 "/cycamore/src/reactor.h"
338 std::vector<std::string> pref_change_commods;
340#line 416 "/cycamore/src/reactor.h"
341
342
343 #pragma cyclus var { "default": [], "uilabel": "Changed Fresh Fuel Preference", "doc": "The new/changed request preference for a particular fresh fuel." " Same order as and direct correspondence to the specified " "preference change times.", }
344#line 424 "/cycamore/src/reactor.h"
345 std::vector<double> pref_change_values;
347#line 425 "/cycamore/src/reactor.h"
348
349
350 #pragma cyclus var { "default": True, "tooltip": "Whether to persist packaging throughout the reactor", "doc": "Boolean value about whether to keep packaging. If true, " "packaging will not be stripped upon acceptance into the " "reactor. If false, package type will be stripped immediately " "upon acceptance. Has no effect if the incoming material is not " "packaged.", "uilabel": "Keep Packaging", "uitype": "bool"}
351#line 436 "/cycamore/src/reactor.h"
354
355#line 437 "/cycamore/src/reactor.h"
356
357 // Resource inventories - these must be defined AFTER/BELOW the member vars
358 // referenced (e.g. n_batch_fresh, assem_size, etc.).
359 #pragma cyclus var {"capacity": "n_assem_fresh * assem_size"}
360 cyclus::toolkit::ResBuf<cyclus::Material> fresh;
361 std::vector<int> cycpp_shape_fresh;
362
363#line 442 "/cycamore/src/reactor.h"
364 #pragma cyclus var {"capacity": "n_assem_core * assem_size"}
365 cyclus::toolkit::ResBuf<cyclus::Material> core;
366 std::vector<int> cycpp_shape_core;
367
368#line 444 "/cycamore/src/reactor.h"
369 #pragma cyclus var {"capacity": "n_assem_spent * assem_size"}
370 cyclus::toolkit::ResBuf<cyclus::Material> spent;
371 std::vector<int> cycpp_shape_spent;
372
373#line 446 "/cycamore/src/reactor.h"
374
375
376 // should be hidden in ui (internal only). True if fuel has already been
377 // discharged this cycle.
378 #pragma cyclus var {"default": 0, "doc": "This should NEVER be set manually", "internal": True }
379#line 453 "/cycamore/src/reactor.h"
381 std::vector<int> cycpp_shape_discharged;
382
383#line 454 "/cycamore/src/reactor.h"
384
385 // This variable should be hidden/unavailable in ui. Maps resource object
386 // id's to the index for the incommod through which they were received.
387 #pragma cyclus var {"default": {}, "doc": "This should NEVER be set manually", "internal": True }
388#line 460 "/cycamore/src/reactor.h"
389 std::map<int, int> res_indexes;
390 std::vector<int> cycpp_shape_res_indexes;
391
392#line 461 "/cycamore/src/reactor.h"
393
394 // populated lazily and no need to persist.
395 std::set<std::string> uniq_outcommods_;
396};
397
398} // namespace cycamore
399
400#endif // CYCAMORE_SRC_REACTOR_H_
#define CYCAMORE_VERSION
Reactor is a simple, general reactor based on static compositional transformations to model fuel burn...
std::string fuel_incommod(cyclus::Material::Ptr m)
std::vector< int > cycpp_shape_discharged
std::vector< int > cycpp_shape_pref_change_times
std::vector< int > cycpp_shape_refuel_time
std::vector< double > side_product_quantity
std::vector< std::string > recipe_change_in
virtual void Snapshot(cyclus::DbInit di)
std::vector< int > recipe_change_times
std::vector< int > cycpp_shape_fuel_prefs
std::vector< int > cycpp_shape_res_indexes
std::vector< int > cycpp_shape_recipe_change_out
void index_res(cyclus::Resource::Ptr m, std::string incommod)
Store fuel info index for the given resource received on incommod.
virtual void InitInv(cyclus::Inventories &inv)
std::vector< std::string > side_products
std::map< std::string, cyclus::toolkit::MatVec > PopSpent()
Returns all spent assemblies indexed by outcommod - removing them from the spent fuel buffer.
virtual void InfileToDb(cyclus::InfileTree *tree, cyclus::DbInit di)
virtual Json::Value annotations()
void RecordSideProduct(bool produce)
Records production of side products from the reactor.
std::vector< int > cycpp_shape_fuel_outrecipes
std::vector< std::string > fuel_outrecipes
std::vector< std::string > pref_change_commods
virtual void GetMatlTrades(const std::vector< cyclus::Trade< cyclus::Material > > &trades, std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
std::vector< int > cycpp_shape_decom_transmute_all
std::vector< int > cycpp_shape_pref_change_commods
bool Discharge()
Discharge a batch from the core if there is room in the spent fuel inventory.
void Transmute()
Transmute the batch that is about to be discharged from the core to its fully burnt state as defined ...
virtual cyclus::Agent * Clone()
cyclus::toolkit::ResBuf< cyclus::Material > spent
std::vector< std::string > recipe_change_out
std::map< int, int > res_indexes
std::vector< int > cycpp_shape_fresh
std::vector< int > cycpp_shape_cycle_step
std::vector< int > cycpp_shape_hybrid_
std::vector< int > cycpp_shape_keep_packaging
std::vector< double > pref_change_values
void Record(std::string name, std::string val)
Records a reactor event to the output db with the given name and note val.
std::vector< int > cycpp_shape_spent
cyclus::toolkit::ResBuf< cyclus::Material > core
double fuel_pref(cyclus::Material::Ptr m)
virtual cyclus::Inventories SnapshotInv()
std::map< std::string, cyclus::toolkit::MatVec > PeekSpent()
Returns all spent assemblies indexed by outcommod without removing them from the spent fuel buffer.
std::string fuel_inrecipe(cyclus::Material::Ptr m)
std::vector< std::string > fuel_outcommods
std::vector< int > cycpp_shape_recipe_change_commods
std::vector< int > cycpp_shape_cycle_time
std::vector< int > cycpp_shape_recipe_change_times
virtual std::string version()
virtual void InitFrom(cycamore::Reactor *m)
std::vector< int > cycpp_shape_recipe_change_in
std::vector< int > cycpp_shape_side_products
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
std::vector< int > pref_change_times
std::string fuel_outcommod(cyclus::Material::Ptr m)
std::vector< int > cycpp_shape_n_assem_core
virtual std::set< cyclus::BidPortfolio< cyclus::Material >::Ptr > GetMatlBids(cyclus::CommodMap< cyclus::Material >::type &commod_requests)
std::vector< int > cycpp_shape_power_cap
virtual bool CheckDecommissionCondition()
std::vector< int > cycpp_shape_n_assem_fresh
std::vector< int > cycpp_shape_pref_change_values
std::vector< int > cycpp_shape_core
std::vector< int > cycpp_shape_n_assem_spent
std::vector< int > cycpp_shape_n_assem_batch
std::vector< int > cycpp_shape_fuel_outcommods
void Load()
Top up core inventory as much as possible.
std::string fuel_outrecipe(cyclus::Material::Ptr m)
std::vector< int > cycpp_shape_power_name
void PushSpent(std::map< std::string, cyclus::toolkit::MatVec > leftover)
Complement of PopSpent - must be called with all materials passed that were not traded away to other ...
std::vector< double > fuel_prefs
cyclus::toolkit::ResBuf< cyclus::Material > fresh
virtual std::string schema()
std::vector< int > cycpp_shape_fuel_inrecipes
std::set< std::string > uniq_outcommods_
std::vector< std::string > fuel_incommods
std::vector< int > cycpp_shape_assem_size
std::vector< std::string > fuel_inrecipes
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
Reactor(cyclus::Context *ctx)
std::vector< int > cycpp_shape_fuel_incommods
std::vector< int > cycpp_shape_side_product_quantity
std::vector< std::string > recipe_change_commods