CYCAMORE
src/storage.h
Go to the documentation of this file.
1 #ifndef CYCLUS_STORAGES_STORAGE_H_
2 #define CYCLUS_STORAGES_STORAGE_H_
3 
4 #include <string>
5 #include <list>
6 #include <vector>
7 
8 #include "cyclus.h"
9 
10 // forward declaration
11 namespace storage {
12 class Storage;
13 } // namespace storage
14 
15 
16 namespace storage {
66 class Storage
67  : public cyclus::Facility,
68  public cyclus::toolkit::CommodityProducer {
69  public:
71  Storage(cyclus::Context* ctx);
72 
73  #pragma cyclus decl
74 
75  #pragma cyclus note {"doc": "Storage is a simple facility which accepts any number of commodities " \
76  "and holds them for a user specified amount of time. The commodities accepted "\
77  "are chosen based on the specified preferences list. Once the desired amount of material "\
78  "has entered the facility it is passed into a 'processing' buffer where it is held until "\
79  "the residence time has passed. The material is then passed into a 'ready' buffer where it is "\
80  "queued for removal. Currently, all input commodities are lumped into a single output commodity. "\
81  "Storage also has the functionality to handle materials in discrete or continuous batches. Discrete "\
82  "mode, which is the default, does not split or combine material batches. Continuous mode, however, "\
83  "divides material batches if necessary in order to push materials through the facility as quickly "\
84  "as possible."}
85 
87  virtual std::string str();
88 
89  // --- Facility Members ---
90 
91  // --- Agent Members ---
93  virtual void EnterNotify();
94 
96  virtual void Tick();
97 
99  virtual void Tock();
100 
101  protected:
105  void AddMat_(cyclus::Material::Ptr mat);
106 
108  void BeginProcessing_();
109 
112  void ProcessMat_(double cap);
113 
116  void ReadyMatl_(int time);
117 
118  /* --- Storage Members --- */
119 
121  inline double current_capacity() const {
122  return (max_inv_size - processing.quantity() - stocks.quantity()); }
123 
125  int ready_time(){ return context()->time() - residence_time; }
126 
127  /* --- Module Members --- */
128 
129  #pragma cyclus var {"tooltip":"input commodity",\
130  "doc":"commodities accepted by this facility",\
131  "uilabel":"Input Commodities",\
132  "uitype":["oneormore","incommodity"]}
133  std::vector<std::string> in_commods;
134 
135  #pragma cyclus var {"default": [],\
136  "doc":"preferences for each of the given commodities, in the same order."\
137  "Defauts to 1 if unspecified",\
138  "uilabel":"In Commody Preferences", \
139  "range": [None, [1e-299, 1e299]], \
140  "uitype":["oneormore", "range"]}
141  std::vector<double> in_commod_prefs;
142 
143  #pragma cyclus var {"tooltip":"output commodity",\
144  "doc":"commodity produced by this facility. Multiple commodity tracking is"\
145  " currently not supported, one output commodity catches all input commodities.",\
146  "uilabel":"Output Commodities",\
147  "uitype":["oneormore","outcommodity"]}
148  std::vector<std::string> out_commods;
149 
150  #pragma cyclus var {"default":"",\
151  "tooltip":"input recipe",\
152  "doc":"recipe accepted by this facility, if unspecified a dummy recipe is used",\
153  "uilabel":"Input Recipe",\
154  "uitype":"recipe"}
156 
157  #pragma cyclus var {"default": 0,\
158  "tooltip":"residence time (timesteps)",\
159  "doc":"the minimum holding time for a received commodity (timesteps).",\
160  "units":"time steps",\
161  "uilabel":"Residence Time", \
162  "uitype": "range", \
163  "range": [0, 12000]}
164  int residence_time;
165 
166  #pragma cyclus var {"default": 1e299,\
167  "tooltip":"throughput per timestep (kg)",\
168  "doc":"the max amount that can be moved through the facility per timestep (kg)",\
169  "uilabel":"Throughput",\
170  "uitype": "range", \
171  "range": [0.0, 1e299], \
172  "units":"kg"}
173  double throughput;
174 
175  #pragma cyclus var {"default": 1e299,\
176  "tooltip":"maximum inventory size (kg)",\
177  "doc":"the maximum amount of material that can be in all storage buffer stages",\
178  "uilabel":"Maximum Inventory Size",\
179  "uitype": "range", \
180  "range": [0.0, 1e299], \
181  "units":"kg"}
182  double max_inv_size;
183 
184  #pragma cyclus var {"default": False,\
185  "tooltip":"Bool to determine how Storage handles batches",\
186  "doc":"Determines if Storage will divide resource objects. Only controls material "\
187  "handling within this facility, has no effect on DRE material handling. "\
188  "If true, batches are handled as discrete quanta, neither split nor combined. "\
189  "Otherwise, batches may be divided during processing. Default to false (continuous))",\
190  "uilabel":"Batch Handling"}
191  bool discrete_handling;
192 
193  #pragma cyclus var {"tooltip":"Incoming material buffer"}
194  cyclus::toolkit::ResBuf<cyclus::Material> inventory;
195 
196  #pragma cyclus var {"tooltip":"Output material buffer"}
197  cyclus::toolkit::ResBuf<cyclus::Material> stocks;
198 
199  #pragma cyclus var {"tooltip":"Buffer for material held for required residence_time"}
200  cyclus::toolkit::ResBuf<cyclus::Material> ready;
201 
203  #pragma cyclus var{"default": [],\
204  "internal": True}
205  std::list<int> entry_times;
206 
207  #pragma cyclus var {"tooltip":"Buffer for material still waiting for required residence_time"}
208  cyclus::toolkit::ResBuf<cyclus::Material> processing;
209 
211  cyclus::toolkit::MatlBuyPolicy buy_policy;
212 
214  cyclus::toolkit::MatlSellPolicy sell_policy;
215 
216 
217  friend class StorageTest;
218 };
219 
220 } // namespace storage
221 
222 #endif // CYCLUS_STORAGES_STORAGE_H_
void AddMat_(cyclus::Material::Ptr mat)
adds a material into the incoming commodity inventory
virtual std::string str()
A verbose printer for the Storage Facility.
cyclus::toolkit::ResBuf< cyclus::Material > ready
virtual void Tock()
The handleTick function specific to the Storage.
virtual void EnterNotify()
Sets up the Storage Facility&#39;s trade requests.
cyclus::toolkit::MatlBuyPolicy buy_policy
virtual void Tick()
The handleTick function specific to the Storage.
std::vector< double > in_commod_prefs
cycamore::GrowthRegion string
int ready_time()
returns the time key for ready materials
Definition: src/storage.h:125
cyclus::toolkit::ResBuf< cyclus::Material > stocks
cyclus::toolkit::MatlSellPolicy sell_policy
cyclus::toolkit::ResBuf< cyclus::Material > processing
cyclus::toolkit::ResBuf< cyclus::Material > inventory
std::vector< std::string > in_commods
void ReadyMatl_(int time)
move ready resources from processing to ready at a certain time
double current_capacity() const
current maximum amount that can be added to processing
Definition: src/storage.h:121
void BeginProcessing_()
Move all unprocessed inventory to processing.
std::vector< std::string > out_commods
void ProcessMat_(double cap)
Move as many ready resources as allowable into stocks.
Storage(cyclus::Context *ctx)