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