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 std::string fuel_incommod(cyclus::Material::Ptr m);
109 std::string fuel_outcommod(cyclus::Material::Ptr m);
110 std::string fuel_inrecipe(cyclus::Material::Ptr m);
111 std::string fuel_outrecipe(cyclus::Material::Ptr m);
112 double fuel_pref(cyclus::Material::Ptr m);
113
114 bool retired() {
115 return exit_time() != -1 && context()->time() > exit_time();
116 }
117
119 void index_res(cyclus::Resource::Ptr m, std::string incommod);
120
123 bool Discharge();
124
126 void Load();
127
130 void Transmute();
131
133 void RecordSideProduct(bool produce);
134
137 void Transmute(int n_assem);
138
140 void Record(std::string name, std::string val);
141
144 void PushSpent(std::map<std::string, cyclus::toolkit::MatVec> leftover);
145
148 std::map<std::string, cyclus::toolkit::MatVec> PopSpent();
149
152 std::map<std::string, cyclus::toolkit::MatVec> PeekSpent();
153
155 #pragma cyclus var { "uitype": ["oneormore", "incommodity"], "uilabel": "Fresh Fuel Commodity List", "doc": "Ordered list of input commodities on which to requesting fuel.", }
156#line 189 "/cycamore/src/reactor.h"
157 std::vector<std::string> fuel_incommods;
159
160 #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).", }
161#line 196 "/cycamore/src/reactor.h"
162 std::vector<std::string> fuel_inrecipes;
164#line 197 "/cycamore/src/reactor.h"
165
166
167 #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).", }
168#line 206 "/cycamore/src/reactor.h"
169 std::vector<double> fuel_prefs;
170 std::vector<int> cycpp_shape_fuel_prefs;
171
172 #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)." }
173#line 213 "/cycamore/src/reactor.h"
174 std::vector<std::string> fuel_outcommods;
176
177 #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.", }
178#line 222 "/cycamore/src/reactor.h"
179 std::vector<std::string> fuel_outrecipes;
181
182#line 223 "/cycamore/src/reactor.h"
183
185 #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.", }
186#line 231 "/cycamore/src/reactor.h"
187 std::vector<int> recipe_change_times;
189
190 #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"], }
191#line 240 "/cycamore/src/reactor.h"
192 std::vector<std::string> recipe_change_commods;
194
195 #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"], }
196#line 249 "/cycamore/src/reactor.h"
197 std::vector<std::string> recipe_change_in;
199
200 #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"], }
201#line 258 "/cycamore/src/reactor.h"
202 std::vector<std::string> recipe_change_out;
204
205#line 259 "/cycamore/src/reactor.h"
206
208 #pragma cyclus var { "doc": "Mass (kg) of a single assembly.", "uilabel": "Assembly Mass", "uitype": "range", "range": [1.0, 1e5], "units": "kg", }
209#line 268 "/cycamore/src/reactor.h"
211 std::vector<int> cycpp_shape_assem_size;
212#line 269 "/cycamore/src/reactor.h"
213
214
215 #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``.", }
216#line 277 "/cycamore/src/reactor.h"
219
220 #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.", }
221#line 285 "/cycamore/src/reactor.h"
223 std::vector<int> cycpp_shape_n_assem_core;
224
225 #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.", }
226#line 294 "/cycamore/src/reactor.h"
229
230 #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.", }
231#line 304 "/cycamore/src/reactor.h"
234
235#line 305 "/cycamore/src/reactor.h"
236
238 #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", }
239#line 314 "/cycamore/src/reactor.h"
241 std::vector<int> cycpp_shape_cycle_time;
242
243 #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", }
244#line 322 "/cycamore/src/reactor.h"
246 std::vector<int> cycpp_shape_refuel_time;
247
248 #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", }
249#line 330 "/cycamore/src/reactor.h"
251 std::vector<int> cycpp_shape_cycle_step;
252
253#line 331 "/cycamore/src/reactor.h"
254
256 #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", }
257#line 342 "/cycamore/src/reactor.h"
258 double power_cap;
259 std::vector<int> cycpp_shape_power_cap;
260#line 343 "/cycamore/src/reactor.h"
261
262
263 #pragma cyclus var { "default": "power", "uilabel": "Power Commodity Name", "doc": "The name of the 'power' commodity used in conjunction with a " "deployment curve.", }
264#line 350 "/cycamore/src/reactor.h"
265 std::string power_name;
266 std::vector<int> cycpp_shape_power_name;
267
268#line 351 "/cycamore/src/reactor.h"
269
271
272 #pragma cyclus var { "uilabel": "Side Product from Reactor Plant", "default": [], "doc": "Ordered vector of side product the reactor produces with power", }
273#line 359 "/cycamore/src/reactor.h"
274 std::vector<std::string> side_products;
276#line 360 "/cycamore/src/reactor.h"
277
278
279 #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", }
280#line 366 "/cycamore/src/reactor.h"
281 std::vector<double> side_product_quantity;
283#line 367 "/cycamore/src/reactor.h"
284
285
286 #pragma cyclus var {"default": 1, "internal": True, "doc": "True if reactor is a hybrid system (produces side products)", }
287#line 372 "/cycamore/src/reactor.h"
289 std::vector<int> cycpp_shape_hybrid_;
290
291#line 373 "/cycamore/src/reactor.h"
292
293
295 #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.", }
296#line 381 "/cycamore/src/reactor.h"
299
300#line 382 "/cycamore/src/reactor.h"
301
302
304 #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.", }
305#line 391 "/cycamore/src/reactor.h"
306 std::vector<int> pref_change_times;
308
309 #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"], }
310#line 400 "/cycamore/src/reactor.h"
311 std::vector<std::string> pref_change_commods;
313
314 #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.", }
315#line 408 "/cycamore/src/reactor.h"
316 std::vector<double> pref_change_values;
318#line 409 "/cycamore/src/reactor.h"
319
320
321 #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"}
322#line 420 "/cycamore/src/reactor.h"
325
326#line 421 "/cycamore/src/reactor.h"
327
328 // Resource inventories - these must be defined AFTER/BELOW the member vars
329 // referenced (e.g. n_batch_fresh, assem_size, etc.).
330 #pragma cyclus var {"capacity": "n_assem_fresh * assem_size"}
331 cyclus::toolkit::ResBuf<cyclus::Material> fresh;
332 std::vector<int> cycpp_shape_fresh;
333
334#line 426 "/cycamore/src/reactor.h"
335 #pragma cyclus var {"capacity": "n_assem_core * assem_size"}
336 cyclus::toolkit::ResBuf<cyclus::Material> core;
337 std::vector<int> cycpp_shape_core;
338
339#line 428 "/cycamore/src/reactor.h"
340 #pragma cyclus var {"capacity": "n_assem_spent * assem_size"}
341 cyclus::toolkit::ResBuf<cyclus::Material> spent;
342 std::vector<int> cycpp_shape_spent;
343
344#line 430 "/cycamore/src/reactor.h"
345
346
347 // should be hidden in ui (internal only). True if fuel has already been
348 // discharged this cycle.
349 #pragma cyclus var {"default": 0, "doc": "This should NEVER be set manually", "internal": True }
350#line 437 "/cycamore/src/reactor.h"
352 std::vector<int> cycpp_shape_discharged;
353
354#line 438 "/cycamore/src/reactor.h"
355
356 // This variable should be hidden/unavailable in ui. Maps resource object
357 // id's to the index for the incommod through which they were received.
358 #pragma cyclus var {"default": {}, "doc": "This should NEVER be set manually", "internal": True }
359#line 444 "/cycamore/src/reactor.h"
360 std::map<int, int> res_indexes;
361 std::vector<int> cycpp_shape_res_indexes;
362
363#line 445 "/cycamore/src/reactor.h"
364
365 // populated lazily and no need to persist.
366 std::set<std::string> uniq_outcommods_;
367
368 #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." }
369#line 455 "/cycamore/src/reactor.h"
370 double latitude;
371 std::vector<int> cycpp_shape_latitude;
372#line 456 "/cycamore/src/reactor.h"
373
374
375 #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." }
376#line 463 "/cycamore/src/reactor.h"
377 double longitude;
378 std::vector<int> cycpp_shape_longitude;
379
380#line 464 "/cycamore/src/reactor.h"
381
382 cyclus::toolkit::Position coordinates;
383
385 void RecordPosition();
386};
387
388} // namespace cycamore
389
390#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::vector< int > cycpp_shape_longitude
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::vector< int > cycpp_shape_latitude
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
void RecordPosition()
Records an agent's latitude and longitude to the output db.
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
cyclus::toolkit::Position coordinates
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