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