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 cyclus::toolkit::Position {
70  public:
72  Storage(cyclus::Context* ctx);
73 
74  #pragma cyclus decl
75 
76  #pragma cyclus note {"doc": "Storage is a simple facility which accepts any number of commodities " \
77  "and holds them for a user specified amount of time. The commodities accepted "\
78  "are chosen based on the specified preferences list. Once the desired amount of material "\
79  "has entered the facility it is passed into a 'processing' buffer where it is held until "\
80  "the residence time has passed. The material is then passed into a 'ready' buffer where it is "\
81  "queued for removal. Currently, all input commodities are lumped into a single output commodity. "\
82  "Storage also has the functionality to handle materials in discrete or continuous batches. Discrete "\
83  "mode, which is the default, does not split or combine material batches. Continuous mode, however, "\
84  "divides material batches if necessary in order to push materials through the facility as quickly "\
85  "as possible."}
86 
88  virtual std::string str();
89 
90  // --- Facility Members ---
91 
92  // --- Agent Members ---
94  virtual void EnterNotify();
95 
97  virtual void Tick();
98 
100  virtual void Tock();
101 
102  protected:
106  void AddMat_(cyclus::Material::Ptr mat);
107 
109  void BeginProcessing_();
110 
113  void ProcessMat_(double cap);
114 
117  void ReadyMatl_(int time);
118 
119  /* --- Storage Members --- */
120 
122  inline double current_capacity() const {
123  return (max_inv_size - processing.quantity() - stocks.quantity()); }
124 
126  int ready_time(){ return context()->time() - residence_time; }
127 
128  /* --- Module Members --- */
129 
130  #pragma cyclus var {"tooltip":"input commodity",\
131  "doc":"commodities accepted by this facility",\
132  "uilabel":"Input Commodities",\
133  "uitype":["oneormore","incommodity"]}
134  std::vector<std::string> in_commods;
135 
136  #pragma cyclus var {"default": [],\
137  "doc":"preferences for each of the given commodities, in the same order."\
138  "Defauts to 1 if unspecified",\
139  "uilabel":"In Commody Preferences", \
140  "range": [None, [1e-299, 1e299]], \
141  "uitype":["oneormore", "range"]}
142  std::vector<double> in_commod_prefs;
143 
144  #pragma cyclus var {"tooltip":"output commodity",\
145  "doc":"commodity produced by this facility. Multiple commodity tracking is"\
146  " currently not supported, one output commodity catches all input commodities.",\
147  "uilabel":"Output Commodities",\
148  "uitype":["oneormore","outcommodity"]}
149  std::vector<std::string> out_commods;
150 
151  #pragma cyclus var {"default":"",\
152  "tooltip":"input recipe",\
153  "doc":"recipe accepted by this facility, if unspecified a dummy recipe is used",\
154  "uilabel":"Input Recipe",\
155  "uitype":"inrecipe"}
157 
158  #pragma cyclus var {"default": 0,\
159  "tooltip":"residence time (timesteps)",\
160  "doc":"the minimum holding time for a received commodity (timesteps).",\
161  "units":"time steps",\
162  "uilabel":"Residence Time", \
163  "uitype": "range", \
164  "range": [0, 12000]}
165  int residence_time;
166 
167  #pragma cyclus var {"default": 1e299,\
168  "tooltip":"throughput per timestep (kg)",\
169  "doc":"the max amount that can be moved through the facility per timestep (kg)",\
170  "uilabel":"Throughput",\
171  "uitype": "range", \
172  "range": [0.0, 1e299], \
173  "units":"kg"}
174  double throughput;
175 
176  #pragma cyclus var {"default": 1e299,\
177  "tooltip":"maximum inventory size (kg)",\
178  "doc":"the maximum amount of material that can be in all storage buffer stages",\
179  "uilabel":"Maximum Inventory Size",\
180  "uitype": "range", \
181  "range": [0.0, 1e299], \
182  "units":"kg"}
183  double max_inv_size;
184 
185  #pragma cyclus var {"default": False,\
186  "tooltip":"Bool to determine how Storage handles batches",\
187  "doc":"Determines if Storage will divide resource objects. Only controls material "\
188  "handling within this facility, has no effect on DRE material handling. "\
189  "If true, batches are handled as discrete quanta, neither split nor combined. "\
190  "Otherwise, batches may be divided during processing. Default to false (continuous))",\
191  "uilabel":"Batch Handling"}
192  bool discrete_handling;
193 
194  #pragma cyclus var {"tooltip":"Incoming material buffer"}
195  cyclus::toolkit::ResBuf<cyclus::Material> inventory;
196 
197  #pragma cyclus var {"tooltip":"Output material buffer"}
198  cyclus::toolkit::ResBuf<cyclus::Material> stocks;
199 
200  #pragma cyclus var {"tooltip":"Buffer for material held for required residence_time"}
201  cyclus::toolkit::ResBuf<cyclus::Material> ready;
202 
204  #pragma cyclus var{"default": [],\
205  "internal": True}
206  std::list<int> entry_times;
207 
208  #pragma cyclus var {"tooltip":"Buffer for material still waiting for required residence_time"}
209  cyclus::toolkit::ResBuf<cyclus::Material> processing;
210 
212  cyclus::toolkit::MatlBuyPolicy buy_policy;
213 
215  cyclus::toolkit::MatlSellPolicy sell_policy;
216 
217  #pragma cyclus var { \
218  "default": 0.0, \
219  "uilabel": "Geographical latitude in degrees as a double", \
220  "doc": "Latitude of the agent's geographical position. The value should " \
221  "be expressed in degrees as a double." \
222  }
223  double latitude;
224 
225  #pragma cyclus var { \
226  "default": 0.0, \
227  "uilabel": "Geographical longitude in degrees as a double", \
228  "doc": "Longitude of the agent's geographical position. The value should " \
229  "be expressed in degrees as a double." \
230  }
231  double longitude;
232 
233  cyclus::toolkit::Position coordinates;
234 
235  void RecordPosition();
236 
237  friend class StorageTest;
238 };
239 
240 } // namespace storage
241 
242 #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
double current_capacity() const
current maximum amount that can be added to processing
Definition: src/storage.h:122
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:126
cyclus::toolkit::ResBuf< cyclus::Material > stocks
cyclus::toolkit::MatlSellPolicy sell_policy
cyclus::toolkit::Position coordinates
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
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)