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 #pragma cyclus var { \
138 "doc": "Ordered list of commodities on which to requesting filler stream material.", \
139 "uilabel": "Filler Stream Commodities", \
140 "uitype": ["oneormore", "incommodity"], \
141 }
142 std::vector<std::string> fill_commods;
143 #pragma cyclus var { \
144 "default": [], \
145 "uilabel": "Filler Stream Preferences", \
146 "doc": "Filler stream commodity request preferences for each of the given filler commodities (same order)." \
147 " If unspecified, default is to use 1.0 for all preferences.", \
148 }
149 std::vector<double> fill_commod_prefs;
150 #pragma cyclus var { \
151 "doc": "Name of recipe to be used in filler material stream requests.", \
152 "uilabel": "Filler Stream Recipe", \
153 "uitype": "inrecipe", \
154 }
155 std::string fill_recipe;
156 #pragma cyclus var { \
157 "doc": "Size of filler material stream inventory.", \
158 "uilabel": "Filler Stream Inventory Capacity", \
159 "units": "kg", \
160 }
161 double fill_size;
162 #pragma cyclus var {"capacity": "fill_size"}
163 cyclus::toolkit::ResBuf<cyclus::Material> fill;
164
165 #pragma cyclus var { \
166 "doc": "Ordered list of commodities on which to requesting fissile stream material.", \
167 "uilabel": "Fissile Stream Commodities", \
168 "uitype": ["oneormore", "incommodity"], \
169 }
170 std::vector<std::string> fiss_commods;
171 #pragma cyclus var { \
172 "default": [], \
173 "uilabel": "Fissile Stream Preferences", \
174 "doc": "Fissile stream commodity request preferences for each of the given fissile commodities (same order)." \
175 " If unspecified, default is to use 1.0 for all preferences.", \
176 }
177 std::vector<double> fiss_commod_prefs;
178 #pragma cyclus var { \
179 "doc": "Name for recipe to be used in fissile stream requests." \
180 " Empty string results in use of an empty dummy recipe.", \
181 "uitype": "inrecipe", \
182 "uilabel": "Fissile Stream Recipe", \
183 "default": "", \
184 }
185 std::string fiss_recipe;
186 #pragma cyclus var { \
187 "doc": "Size of fissile material stream inventory.", \
188 "uilabel": "Fissile Stream Inventory Capacity", \
189 "units": "kg", \
190 }
191 double fiss_size;
192 #pragma cyclus var {"capacity": "fiss_size"}
193 cyclus::toolkit::ResBuf<cyclus::Material> fiss;
194
195 #pragma cyclus var { \
196 "doc": "Commodity on which to request material for top-up stream." \
197 " This MUST be set if 'topup_size > 0'.", \
198 "uilabel": "Top-up Stream Commodity", \
199 "default": "", \
200 "uitype": "incommodity", \
201 }
202 std::string topup_commod;
203 #pragma cyclus var { \
204 "doc": "Top-up material stream request preference.", \
205 "uilabel": "Top-up Stream Preference", \
206 "default": 1.0, \
207 }
208 double topup_pref; // default must be in range (0, cyclus::kDefaultPref)
209
210 #pragma cyclus var { \
211 "doc": "Name of recipe to be used in top-up material stream requests." \
212 " This MUST be set if 'topup_size > 0'.", \
213 "uilabel": "Top-up Stream Recipe", \
214 "uitype": "inrecipe", \
215 "default": "", \
216 }
217 std::string topup_recipe;
218 #pragma cyclus var { \
219 "doc": "Size of top-up material stream inventory.", \
220 "uilabel": "Top-up Stream Inventory Capacity", \
221 "units": "kg", \
222 "default": 0, \
223 }
224 double topup_size;
225 #pragma cyclus var {"capacity": "topup_size"}
226 cyclus::toolkit::ResBuf<cyclus::Material> topup;
227
228 #pragma cyclus var { \
229 "doc": "Commodity on which to offer/supply mixed fuel material.", \
230 "uilabel": "Output Commodity", \
231 "uitype": "outcommodity", \
232 }
233 std::string outcommod;
234
235 #pragma cyclus var { \
236 "doc": "Maximum number of kg of fuel material that can be supplied per time step.", \
237 "uilabel": "Maximum Throughput", \
238 "units": "kg", \
239 "default": CY_LARGE_DOUBLE, \
240 "uitype": "range", \
241 "range": [0.0, CY_LARGE_DOUBLE], \
242 }
243 double throughput;
244
245 #pragma cyclus var { \
246 "uilabel": "Spectrum type", \
247 "uitype": "combobox", \
248 "categorical": ["fission_spectrum_ave", "thermal"], \
249 "doc": "The type of cross-sections to use for composition property calculation." \
250 " Use 'fission_spectrum_ave' for fast reactor compositions or 'thermal' for thermal reactors.", \
251 }
252 std::string spectrum;
253
254 // intra-time-step state - no need to be a state var
255 // map<request, inventory name>
256 std::map<cyclus::Request<cyclus::Material>*, std::string> req_inventories_;
257
258 #pragma cyclus var { \
259 "default": 0.0, \
260 "uilabel": "Geographical latitude in degrees as a double", \
261 "doc": "Latitude of the agent's geographical position. The value should " \
262 "be expressed in degrees as a double." \
263 }
264 double latitude;
265
266 #pragma cyclus var { \
267 "default": 0.0, \
268 "uilabel": "Geographical longitude in degrees as a double", \
269 "doc": "Longitude of the agent's geographical position. The value should " \
270 "be expressed in degrees as a double." \
271 }
272 double longitude;
273
274 cyclus::toolkit::Position coordinates;
277 void RecordPosition();
278};
279
280double CosiWeight(cyclus::Composition::Ptr c, const std::string& spectrum);
281bool ValidWeights(double w_low, double w_tgt, double w_high);
282double LowFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO);
283double HighFrac(double w_low, double w_tgt, double w_high, double eps = cyclus::CY_NEAR_ZERO);
284double AtomToMassFrac(double atomfrac, cyclus::Composition::Ptr c1, cyclus::Composition::Ptr c2);
285
286} // namespace cycamore
287
288
289#endif // CYCAMORE_SRC_FUEL_FAB_H_
#define CYCAMORE_VERSION
FuelFab(cyclus::Context *ctx)
void RecordPosition()
Records an agent's latitude and longitude to the output db.
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
cyclus::toolkit::Position coordinates
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)