-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfleet_reactor.h
243 lines (207 loc) · 8.59 KB
/
fleet_reactor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#ifndef CYCAMORE_SRC_FLEET_REACTOR_H_
#define CYCAMORE_SRC_FLEET_REACTOR_H_
#include "cyclus.h"
#include "rwc_version.h"
namespace cycamore {
class FleetReactor : public cyclus::Facility,
public cyclus::toolkit::CommodityProducer {
public:
FleetReactor(cyclus::Context* ctx);
virtual ~FleetReactor(){};
virtual std::string version() {return RWC_VERSION;};
virtual void Tick();
virtual void Tock();
virtual void EnterNotify();
virtual void AcceptMatlTrades(const std::vector<std::pair<
cyclus::Trade<cyclus::Material>, cyclus::Material::Ptr> >& responses);
virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
GetMatlRequests();
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);
#pragma cyclus decl
virtual void Build(Agent* parent);
virtual void Decommission();
virtual bool CheckDecommissionCondition();
private:
FleetReactor* master() {
am_master();
return masters_[prototype()];
}
bool am_master() {
if (am_master_) {
if (masters_.count(prototype()) > 0) {
// in case another agent incorrectly set itself to master already.
masters_[prototype()]->am_master_ = false;
}
masters_[prototype()] = this;
am_master_ = true; // in case we set it to false above
} else if (masters_.count(prototype()) == 0) {
masters_[prototype()] = this;
am_master_ = true;
}
return am_master_;
}
static std::map<std::string, FleetReactor*> masters_;
// this is necessary for cross snapshot-init to remember which agent is the
// master because the master's state evolves differently and so must be the
// same instance from init to init.
#pragma cyclus var {"default": False, "internal": True}
bool am_master_;
std::string fuel_incommod(cyclus::Material::Ptr m);
std::string fuel_outcommod(cyclus::Material::Ptr m);
std::string fuel_inrecipe(cyclus::Material::Ptr m);
std::string fuel_outrecipe(cyclus::Material::Ptr m);
double fuel_pref(cyclus::Material::Ptr m);
/// Store fuel info index for the given resource received on incommod.
void index_res(cyclus::Resource::Ptr m, std::string incommod);
/// Discharge some quantity of material from the core. If qty is less than
/// zero (default), a time step worth of burning/transmuting/discharging is
/// performed for all material.
void Discharge(double qty=-1);
void Retire(double number_of_fleet);
void Deploy(double number_of_fleet);
/// Complement of PopSpent - must be called with all materials passed that
/// were not traded away to other agents.
void PushSpent(std::map<std::string, cyclus::Material::Ptr> leftover);
/// Returns all spent assemblies indexed by outcommod - removing them from
/// the spent fuel buffer.
std::map<std::string, cyclus::Material::Ptr> PopSpent();
/// Returns all spent assemblies indexed by outcommod without removing them
/// from the spent fuel buffer.
std::map<std::string, cyclus::Material::Ptr> PeekSpent();
//////////// power params ////////////
#pragma cyclus var { \
"default": 0, \
"doc": "Amount of electrical power the facility produces when operating normally.", \
"units": "MWe", \
}
double power_cap;
#pragma cyclus var { \
"default": "power", \
"doc": "The name of the 'power' commodity used in conjunction with a deployment curve.", \
}
std::string power_name;
//////////// inventory and core params ////////////
#pragma cyclus var { \
"doc": "Mass of a full core.", \
"units": "kg", \
}
double core_size;
#pragma cyclus var { \
"doc": "Mass of a full batch or the amount of material discharged per cycle.", \
"units": "kg", \
}
int batch_size;
#pragma cyclus var { \
"doc": "number of reactors in the entire fleet", \
"units": "kg", \
"internal": True, \
"default": 0, \
}
double fleet_size;
///////// cycle params ///////////
#pragma cyclus var { \
"doc": "The duration of a full operational cycle (including refueling time) in time steps.", \
"units": "time steps", \
}
int cycle_time;
/////// fuel specifications /////////
#pragma cyclus var { \
"uitype": ["oneormore", "incommodity"], \
"doc": "Ordered list of input commodities on which to requesting fuel.", \
}
std::vector<std::string> fuel_incommods;
#pragma cyclus var { \
"uitype": ["oneormore", "recipe"], \
"doc": "Fresh fuel recipes to request for each of the given fuel input commodities (same order).", \
}
std::vector<std::string> fuel_inrecipes;
#pragma cyclus var { \
"uitype": ["oneormore", "recipe"], \
"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.", \
}
std::vector<std::string> fuel_outrecipes;
#pragma cyclus var { \
"uitype": ["oneormore", "incommodity"], \
"doc": "Output commodities on which to offer spent fuel originally received as each particular " \
" input commodity (same order)." \
}
std::vector<std::string> fuel_outcommods;
#pragma cyclus var { \
"default": [], \
"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).", \
}
std::vector<double> fuel_prefs;
// Resource inventories - these must be defined AFTER/BELOW the member vars
// referenced (e.g. n_batch_fresh, assem_size, etc.).
#pragma cyclus var {"capacity": "core_size * fleet_size"}
cyclus::toolkit::ResBuf<cyclus::Material> core;
#pragma cyclus var {"capacity": 1e299}
cyclus::toolkit::ResBuf<cyclus::Material> spent;
/////////// preference changes ///////////
#pragma cyclus var { \
"default": [], \
"doc": "A time step on which to change the request preference for a " \
"particular fresh fuel type.", \
}
std::vector<int> pref_change_times;
#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.", \
"uitype": ["oneormore", "incommodity"], \
}
std::vector<std::string> pref_change_commods;
#pragma cyclus var { \
"default": [], \
"doc": "The new/changed request preference for a particular fresh fuel." \
" Same order as and direct correspondence to the specified preference change times.", \
}
std::vector<double> pref_change_values;
///////////// recipe changes ///////////
#pragma cyclus var { \
"default": [], \
"doc": "A time step on which to change the input-output recipe pair for a requested fresh fuel.", \
}
std::vector<int> recipe_change_times;
#pragma cyclus var { \
"default": [], \
"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"], \
}
std::vector<std::string> recipe_change_commods;
#pragma cyclus var { \
"default": [], \
"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", "recipe"], \
}
std::vector<std::string> recipe_change_in;
#pragma cyclus var { \
"default": [], \
"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", "recipe"], \
}
std::vector<std::string> recipe_change_out;
// This variable should be hidden/unavailable in ui. Maps resource object
// id's to the index for the incommod through which they were received.
#pragma cyclus var {"default": {}, "doc": "This should NEVER be set manually.", "internal": True}
std::map<int, int> res_indexes;
// populated lazily and no need to persist. In case we have the same out
// commod for separate in commods of fuel, we don't want to double bid. So
// this is used to loop over unique out commods only.
std::set<std::string> uniq_outcommods_;
double newfleet_;
};
} // namespace cycamore
#endif // CYCAMORE_SRC_FLEET_REACTOR_H_