CYCAMORE
Loading...
Searching...
No Matches
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#include "cycamore_version.h"
10
11#include "boost/shared_ptr.hpp"
12
13#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
14
15namespace cycamore {
66class Storage
67 : public cyclus::Facility,
68 public cyclus::toolkit::CommodityProducer {
69
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
91 virtual void EnterNotify();
92
94 virtual void Tick();
95
97 virtual void Tock();
98
99 virtual std::string version() { return CYCAMORE_VERSION; }
100
101 protected:
105 void AddMat_(cyclus::Material::Ptr mat);
106
109
112 void ProcessMat_(double cap);
113
116 void ReadyMatl_(int time);
117
118 // --- Storage Members ---
119
121 inline double current_capacity() {
122 return (inventory_tracker.space()); }
123
125 inline double capacity() { return inventory_tracker.capacity(); }
126
128 int ready_time(){ return context()->time() - residence_time; }
129
130 // --- Module Members ---
131
132 #pragma cyclus var {"tooltip":"input commodity",\
133 "doc":"commodities accepted by this facility",\
134 "uilabel":"Input Commodities",\
135 "uitype":["oneormore","incommodity"]}
136 std::vector<std::string> in_commods;
137
138 #pragma cyclus var {"default": [],\
139 "doc":"preferences for each of the given commodities, in the same order."\
140 "Defauts to 1 if unspecified",\
141 "uilabel":"In Commody Preferences", \
142 "range": [None, [CY_NEAR_ZERO, CY_LARGE_DOUBLE]], \
143 "uitype":["oneormore", "range"]}
144 std::vector<double> in_commod_prefs;
145
146 #pragma cyclus var {"tooltip":"output commodity",\
147 "doc":"commodity produced by this facility. Multiple commodity tracking is"\
148 " currently not supported, one output commodity catches all input commodities.",\
149 "uilabel":"Output Commodities",\
150 "uitype":["oneormore","outcommodity"]}
151 std::vector<std::string> out_commods;
152
153 #pragma cyclus var {"default":"",\
154 "tooltip":"input recipe",\
155 "doc":"recipe accepted by this facility, if unspecified a dummy recipe is used",\
156 "uilabel":"Input Recipe",\
157 "uitype":"inrecipe"}
158 std::string in_recipe;
159
160 #pragma cyclus var {"default": 0,\
161 "tooltip":"residence time (timesteps)",\
162 "doc":"the minimum holding time for a received commodity (timesteps).",\
163 "units":"time steps",\
164 "uilabel":"Residence Time", \
165 "uitype": "range", \
166 "range": [0, 12000]}
167 int residence_time;
168
169 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
170 "tooltip":"throughput per timestep (kg)",\
171 "doc":"the max amount that can be moved through the facility per timestep (kg)",\
172 "uilabel":"Throughput",\
173 "uitype": "range", \
174 "range": [0.0, CY_LARGE_DOUBLE], \
175 "units":"kg"}
176 double throughput;
177
178 #pragma cyclus var {"default": CY_LARGE_DOUBLE,\
179 "tooltip":"maximum inventory size (kg)",\
180 "doc":"the maximum amount of material that can be in all storage buffer stages",\
181 "uilabel":"Maximum Inventory Size",\
182 "uitype": "range", \
183 "range": [0.0, CY_LARGE_DOUBLE], \
184 "units":"kg"}
185 double max_inv_size;
186
187 #pragma cyclus var {"default": False,\
188 "tooltip":"Bool to determine how Storage handles batches",\
189 "doc":"Determines if Storage will divide resource objects. Only controls material "\
190 "handling within this facility, has no effect on DRE material handling. "\
191 "If true, batches are handled as discrete quanta, neither split nor combined. "\
192 "Otherwise, batches may be divided during processing. Default to false (continuous))",\
193 "uilabel":"Batch Handling"}
195
196 #pragma cyclus var {"default": "unpackaged", \
197 "tooltip": "Output package", \
198 "doc": "Outgoing material will be packaged when trading.", \
199 "uitype": "package", \
200 "uilabel": "Package"}
201 std::string package;
202
203 #pragma cyclus var {"default": "unrestricted", \
204 "tooltip": "Output transport unit", \
205 "doc": "Outgoing material, after packaging, will be "\
206 "further restricted by transport unit when trading.", \
207 "uitype": "transportunit", \
208 "uilabel": "Transport Unit"}
209 std::string transport_unit;
210
211 #pragma cyclus var {"tooltip":"Incoming material buffer"}
212 cyclus::toolkit::ResBuf<cyclus::Material> inventory;
213
214 #pragma cyclus var {"tooltip":"Output material buffer"}
215 cyclus::toolkit::ResBuf<cyclus::Material> stocks;
216
217 #pragma cyclus var {"tooltip":"Buffer for material held for required residence_time"}
218 cyclus::toolkit::ResBuf<cyclus::Material> ready;
219
221 #pragma cyclus var{"default": [],\
222 "internal": True}
223 std::list<int> entry_times;
224
225 #pragma cyclus var {"tooltip":"Buffer for material still waiting for required residence_time"}
226 cyclus::toolkit::ResBuf<cyclus::Material> processing;
227
228 #pragma cyclus var {"tooltip": "Total Inventory Tracker to restrict maximum agent inventory"}
229 cyclus::toolkit::TotalInvTracker inventory_tracker;
230
231 friend class StorageTest;
232
233 private:
234 // Code Injection
235 #include "toolkit/matl_buy_policy.cycpp.h"
236 #include "toolkit/matl_sell_policy.cycpp.h"
237 #include "toolkit/position.cycpp.h"
238
239};
240
241} // namespace cycamore
242
243#endif // CYCLUS_STORAGES_STORAGE_H_
#define CYCAMORE_VERSION
This Facility is intended to hold materials for a user specified amount of time in order to model a s...
Storage(cyclus::Context *ctx)
void AddMat_(cyclus::Material::Ptr mat)
adds a material into the incoming commodity inventory
double current_capacity()
current maximum amount that can be added to processing
cyclus::toolkit::ResBuf< cyclus::Material > ready
std::vector< double > in_commod_prefs
virtual void Tick()
The handleTick function specific to the Storage.
cyclus::toolkit::ResBuf< cyclus::Material > processing
cyclus::toolkit::TotalInvTracker inventory_tracker
virtual std::string str()
A verbose printer for the Storage Facility.
std::vector< std::string > in_commods
virtual std::string version()
Definition src/storage.h:99
cyclus::toolkit::ResBuf< cyclus::Material > inventory
int ready_time()
returns the time key for ready materials
void ProcessMat_(double cap)
Move as many ready resources as allowable into stocks.
virtual void Tock()
The handleTick function specific to the Storage.
std::vector< std::string > out_commods
std::list< int > entry_times
virtual void EnterNotify()
Sets up the Storage Facility's trade requests.
void ReadyMatl_(int time)
move ready resources from processing to ready at a certain time
void BeginProcessing_()
Move all unprocessed inventory to processing.
cyclus::toolkit::ResBuf< cyclus::Material > stocks
double capacity()
returns total capacity