CYCAMORE
Loading...
Searching...
No Matches
src/fuel_fab.h
Go to the documentation of this file.
1#ifndef CYCAMORE_SRC_FUEL_FAB_H_
2#define CYCAMORE_SRC_FUEL_FAB_H_
3
4#include <string>
5#include "cyclus.h"
6#include "cycamore_version.h"
7
8#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
9
10namespace cycamore {
11
58class FuelFab
59 : public cyclus::Facility,
60 public cyclus::toolkit::Position {
61#pragma cyclus note { \
62"niche": "fabrication", \
63"doc": \
64 "FuelFab takes in 2 streams of material and mixes them in ratios in order to" \
65 " supply material that matches some neutronics properties of reqeusted" \
66 " material. It uses an equivalence type method [1]" \
67 " inspired by a similar approach in the COSI fuel cycle simulator." \
68 "\n\n" \
69 "The FuelFab has 3 input inventories: fissile stream, filler stream, and an" \
70 " optional top-up inventory. All materials received into each inventory are" \
71 " always combined into a single material (i.e. a single fissile material, a" \
72 " single filler material, etc.). The input streams and requested fuel" \
73 " composition are each assigned weights based on summing:" \
74 "\n\n" \
75 " N * (p_i - p_U238) / (p_Pu239 - p_U238)" \
76 "\n\n" \
77 "for each nuclide where:" \
78 "\n" \
79 "\n - p = nu*sigma_f - sigma_a for the nuclide" \
80 "\n - p_U238 is p for pure U238" \
81 "\n - p_Pu239 is p for pure Pu239" \
82 "\n - N is the nuclide's atom fraction" \
83 "\n - nu is the average # neutrons per fission" \
84 "\n - sigma_f is the microscopic fission cross-section" \
85 "\n - sigma_a is the microscopic neutron absorption cross-section" \
86 "\n\n" \
87 "The cross sections are from the simple cross section library in PyNE. They" \
88 " can be set to either a thermal or fast neutron spectrum. A linear" \
89 " interpolation is performed using the weights of the fissile, filler, and" \
90 " target streams. The interpolation is used to compute a mixing ratio of the" \
91 " input streams that matches the target weight. In the event that the target" \
92 " weight is higher than the fissile stream weight, the FuelFab will attempt" \
93 " to use the top-up and fissile input streams together instead of the fissile" \
94 " and filler streams. All supplied material will always have the same weight" \
95 " as the requested material." \
96 "\n\n" \
97 "The supplying of mixed material is constrained by available inventory" \
98 " quantities and a per time step throughput limit. Requests for fuel" \
99 " material larger than the throughput can never be met. Fissile inventory" \
100 " can be requested/received via one or more commodities. The DRE request" \
101 " preference for each of these commodities can also optionally be specified." \
102 " By default, the top-up inventory size is zero, and it is not used for" \
103 " mixing. " \
104 "\n\n" \
105 "[1] Baker, A. R., and R. W. Ross. \"Comparison of the value of plutonium and" \
106 " uranium isotopes in fast reactors.\" Proceedings of the Conference on" \
107 " Breeding. Economics, and Safety in Large Fast Power Reactors. 1963." \
108 "", \
110 public:
111 FuelFab(cyclus::Context* ctx);
112 virtual ~FuelFab(){};
113
114 virtual std::string version() { return CYCAMORE_VERSION; }
115
116#pragma cyclus
118 virtual void Tick(){};
119 virtual void Tock(){};
120 virtual void EnterNotify();
121
122 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr> GetMatlBids(
123 cyclus::CommodMap<cyclus::Material>::type& commod_requests);
124
125 virtual void GetMatlTrades(
126 const std::vector<cyclus::Trade<cyclus::Material> >& trades,
127 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
128 cyclus::Material::Ptr> >& responses);
129
130 virtual void AcceptMatlTrades(const std::vector<std::pair<
131 cyclus::Trade<cyclus::Material>, cyclus::Material::Ptr> >& responses);
133 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
135
136 private:
137 // Code Injection:
138 #include "toolkit/position.cycpp.h"
139
140 #pragma cyclus var { \
141 "doc": "Ordered list of commodities on which to requesting filler stream material.", \
142 "uilabel": "Filler Stream Commodities", \
143 "uitype": ["oneormore", "incommodity"], \
144 }
145 std::vector<std::string> fill_commods;
146
147 #pragma cyclus var { \
148 "default": [], \
149 "uilabel": "Filler Stream Preferences", \
150 "doc": "Filler stream commodity request preferences for each of the given filler commodities (same order)." \
151 " If unspecified, default is to use 1.0 for all preferences.", \
152 }
153 std::vector<double> fill_commod_prefs;
154
155 #pragma cyclus var { \
156 "doc": "Name of recipe to be used in filler material stream requests.", \
157 "uilabel": "Filler Stream Recipe", \
158 "uitype": "inrecipe", \
159 }
160 std::string fill_recipe;
161
162 #pragma cyclus var { \
163 "doc": "Size of filler material stream inventory.", \
164 "uilabel": "Filler Stream Inventory Capacity", \
165 "units": "kg", \
166 }
167 double fill_size;
168
169 #pragma cyclus var {"capacity": "fill_size"}
170 cyclus::toolkit::ResBuf<cyclus::Material> fill;
171
172 #pragma cyclus var { \
173 "doc": "Ordered list of commodities on which to requesting fissile stream material.", \
174 "uilabel": "Fissile Stream Commodities", \
175 "uitype": ["oneormore", "incommodity"], \
176 }
177 std::vector<std::string> fiss_commods;
178
179 #pragma cyclus var { \
180 "default": [], \
181 "uilabel": "Fissile Stream Preferences", \
182 "doc": "Fissile stream commodity request preferences for each of the given fissile commodities (same order)." \
183 " If unspecified, default is to use 1.0 for all preferences.", \
184 }
185 std::vector<double> fiss_commod_prefs;
186
187 #pragma cyclus var { \
188 "doc": "Name for recipe to be used in fissile stream requests." \
189 " Empty string results in use of an empty dummy recipe.", \
190 "uitype": "inrecipe", \
191 "uilabel": "Fissile Stream Recipe", \
192 "default": "", \
193 }
194 std::string fiss_recipe;
195
196 #pragma cyclus var { \
197 "doc": "Size of fissile material stream inventory.", \
198 "uilabel": "Fissile Stream Inventory Capacity", \
199 "units": "kg", \
200 }
201 double fiss_size;
202
203 #pragma cyclus var {"capacity": "fiss_size"}
204 cyclus::toolkit::ResBuf<cyclus::Material> fiss;
205
206 #pragma cyclus var { \
207 "doc": "Commodity on which to request material for top-up stream." \
208 " This MUST be set if 'topup_size > 0'.", \
209 "uilabel": "Top-up Stream Commodity", \
210 "default": "", \
211 "uitype": "incommodity", \
212 }
213 std::string topup_commod;
214
215 #pragma cyclus var { \
216 "doc": "Top-up material stream request preference.", \
217 "uilabel": "Top-up Stream Preference", \
218 "default": 1.0, \
219 }
220 double topup_pref; // default must be in range (0, cyclus::kDefaultPref)
221
222 #pragma cyclus var { \
223 "doc": "Name of recipe to be used in top-up material stream requests." \
224 " This MUST be set if 'topup_size > 0'.", \
225 "uilabel": "Top-up Stream Recipe", \
226 "uitype": "inrecipe", \
227 "default": "", \
228 }
229 std::string topup_recipe;
230
231 #pragma cyclus var { \
232 "doc": "Size of top-up material stream inventory.", \
233 "uilabel": "Top-up Stream Inventory Capacity", \
234 "units": "kg", \
235 "default": 0, \
236 }
237 double topup_size;
238
239 #pragma cyclus var {"capacity": "topup_size"}
240 cyclus::toolkit::ResBuf<cyclus::Material> topup;
241
242 #pragma cyclus var { \
243 "doc": "Commodity on which to offer/supply mixed fuel material.", \
244 "uilabel": "Output Commodity", \
245 "uitype": "outcommodity", \
246 }
247 std::string outcommod;
248
249 #pragma cyclus var { \
250 "doc": "Maximum number of kg of fuel material that can be supplied per time step.", \
251 "uilabel": "Maximum Throughput", \
252 "units": "kg", \
253 "default": CY_LARGE_DOUBLE, \
254 "uitype": "range", \
255 "range": [0.0, CY_LARGE_DOUBLE], \
256 }
257 double throughput;
258
259 #pragma cyclus var { \
260 "uilabel": "Spectrum type", \
261 "uitype": "combobox", \
262 "categorical": ["fission_spectrum_ave", "thermal"], \
263 "doc": "The type of cross-sections to use for composition property calculation." \
264 " Use 'fission_spectrum_ave' for fast reactor compositions or 'thermal' for thermal reactors.", \
265 }
266 std::string spectrum;
267
268 // intra-time-step state - no need to be a state var
269 // map<request, inventory name>
270 std::map<cyclus::Request<cyclus::Material>*, std::string> req_inventories_;
271
272};
273
274double CosiWeight(cyclus::Composition::Ptr c, const std::string& spectrum);
275bool ValidWeights(double w_low, double w_tgt, double w_high);
276double LowFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO);
277double HighFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO);
278double AtomToMassFrac(double atomfrac, cyclus::Composition::Ptr c1, cyclus::Composition::Ptr c2);
279
280} // namespace cycamore
281
282
283#endif // CYCAMORE_SRC_FUEL_FAB_H_
#define CYCAMORE_VERSION
FuelFab takes in 2 streams of material and mixes them in ratios in order to supply material that matc...
FuelFab(cyclus::Context *ctx)
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
cyclus::toolkit::ResBuf< cyclus::Material > fill
std::map< cyclus::Request< cyclus::Material > *, std::string > req_inventories_
virtual void GetMatlTrades(const std::vector< cyclus::Trade< cyclus::Material > > &trades, std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
std::vector< double > fill_commod_prefs
virtual std::set< cyclus::BidPortfolio< cyclus::Material >::Ptr > GetMatlBids(cyclus::CommodMap< cyclus::Material >::type &commod_requests)
cyclus::toolkit::ResBuf< cyclus::Material > topup
cyclus::toolkit::ResBuf< cyclus::Material > fiss
std::vector< std::string > fiss_commods
std::vector< std::string > fill_commods
std::vector< double > fiss_commod_prefs
virtual std::string version()
double HighFrac(double w_low, double w_target, double w_high, double eps)
double CosiWeight(Composition::Ptr c, const std::string &spectrum)
bool ValidWeights(double w_low, double w_target, double w_high)
double AtomToMassFrac(double atomfrac, Composition::Ptr c1, Composition::Ptr c2)
double LowFrac(double w_low, double w_target, double w_high, double eps)