CYCAMORE
Loading...
Searching...
No Matches
src/sink.h
Go to the documentation of this file.
1#ifndef CYCAMORE_SRC_SINK_H_
2#define CYCAMORE_SRC_SINK_H_
3
4#include <algorithm>
5#include <string>
6#include <utility>
7#include <vector>
8
9#include "cyclus.h"
10#include "cycamore_version.h"
11
12#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
13
14namespace cycamore {
15
16class Context;
17
23class Sink
24 : public cyclus::Facility,
25 public cyclus::toolkit::Position {
26 public:
27 Sink(cyclus::Context* ctx);
28
29 virtual ~Sink();
30
31 virtual std::string version() { return CYCAMORE_VERSION; }
32
33 #pragma cyclus note { \
34 "doc": \
35 " A sink facility that accepts materials and products with a fixed\n"\
36 " throughput (per time step) capacity and a lifetime capacity defined by\n"\
37 " a total inventory size. The inventory size and throughput capacity\n"\
38 " both default to infinite. If a recipe is provided, it will request\n"\
39 " material with that recipe. Requests are made for any number of\n"\
40 " specified commodities.\n" \
41 }
42
43 #pragma cyclus decl
44
45 virtual std::string str();
46
47 virtual void EnterNotify();
48
49 virtual void Tick();
50
51 virtual void Tock();
52
55 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
57
61 virtual std::set<cyclus::RequestPortfolio<cyclus::Product>::Ptr>
63
65 virtual void AcceptMatlTrades(
66 const std::vector< std::pair<cyclus::Trade<cyclus::Material>,
67 cyclus::Material::Ptr> >& responses);
68
70 virtual void AcceptGenRsrcTrades(
71 const std::vector< std::pair<cyclus::Trade<cyclus::Product>,
72 cyclus::Product::Ptr> >& responses);
73
75 virtual void SetRequestAmt();
76
78 virtual void SetNextBuyTime();
79
82 inline void AddCommodity(std::string name) { in_commods.push_back(name); }
83
86 inline void SetMaxInventorySize(double size) {
87 max_inv_size = size;
88 inventory.capacity(size);
89 }
90
92 inline double MaxInventorySize() const { return inventory.capacity(); }
93
95 inline double InventorySize() const { return inventory.quantity(); }
96
98 inline double SpaceAvailable() const {
99 return std::min(capacity, std::max(0.0, inventory.space()));
100 }
101
104 inline void Capacity(double cap) { capacity = cap; }
105
107 inline double Capacity() const { return capacity; }
108
110 inline const std::vector<std::string>&
111 input_commodities() const { return in_commods; }
112
114 inline const std::vector<double>&
116
117 private:
118 double requestAmt;
119 int nextBuyTime;
121 #pragma cyclus var {"tooltip": "input commodities", \
122 "doc": "commodities that the sink facility accepts", \
123 "uilabel": "List of Input Commodities", \
124 "uitype": ["oneormore", "incommodity"]}
125 std::vector<std::string> in_commods;
126
127 #pragma cyclus var {"default": [],\
128 "doc":"preferences for each of the given commodities, in the same order."\
129 "Defauts to 1 if unspecified",\
130 "uilabel":"In Commody Preferences", \
131 "range": [None, [CY_NEAR_ZERO, CY_LARGE_DOUBLE]], \
132 "uitype":["oneormore", "range"]}
133 std::vector<double> in_commod_prefs;
134
135 #pragma cyclus var {"default": "", \
136 "tooltip": "requested composition", \
137 "doc": "name of recipe to use for material requests, " \
138 "where the default (empty string) is to accept " \
139 "everything", \
140 "uilabel": "Input Recipe", \
141 "uitype": "inrecipe"}
142 std::string recipe_name;
143
145 #pragma cyclus var {"default": CY_LARGE_DOUBLE, \
146 "tooltip": "sink maximum inventory size", \
147 "uilabel": "Maximum Inventory", \
148 "uitype": "range", \
149 "range": [0.0, CY_LARGE_DOUBLE], \
150 "doc": "total maximum inventory size of sink facility"}
151 double max_inv_size;
152
154 #pragma cyclus var {"default": CY_LARGE_DOUBLE, \
155 "tooltip": "sink capacity", \
156 "uilabel": "Maximum Throughput", \
157 "uitype": "range", \
158 "range": [0.0, CY_LARGE_DOUBLE], \
159 "doc": "capacity the sink facility can " \
160 "accept at each time step"}
161 double capacity;
162
164 #pragma cyclus var {'capacity': 'max_inv_size'}
165 cyclus::toolkit::ResBuf<cyclus::Resource> inventory;
166
168 #pragma cyclus var {"default": "None", \
169 "tooltip": "type of random behavior when setting the " \
170 "size of the request", \
171 "uitype": "combobox", \
172 "uilabel": "Random Size", \
173 "categorical": ["None", "UniformReal", "UniformInt", "NormalReal", "NormalInt"], \
174 "doc": "type of random behavior to use. Default None, " \
175 "other options are 'UniformReal', 'UniformInt', " \
176 "'NormalReal', and 'NormalInt'"}
177 std::string random_size_type;
178
179 // random size mean (as a fraction of available space)
180 #pragma cyclus var {"default": 1.0, \
181 "tooltip": "fraction of available space to determine the mean", \
182 "uilabel": "Random Size Mean", \
183 "uitype": "range", \
184 "range": [0.0, CY_LARGE_DOUBLE], \
185 "doc": "When a normal distribution is used to determine the " \
186 "size of the request, this is the fraction of available " \
187 "space to use as the mean. Default 1.0. Note " \
188 "that values significantly above 1 without a " \
189 "correspondingly large std dev may result in " \
190 "inefficient use of the random number generator."}
191 double random_size_mean;
192
193 // random size std dev (as a fraction of available space)
194 #pragma cyclus var {"default": 0.1, \
195 "tooltip": "fraction of available space to determine the std dev", \
196 "uilabel": "Random Size Std Dev", \
197 "uitype": "range", \
198 "range": [0.0, CY_LARGE_DOUBLE], \
199 "doc": "When a normal distribution is used to determine the " \
200 "size of the request, this is the fraction of available " \
201 "space to use as the standard deviation. Default 0.1"}
202 double random_size_stddev;
203
204 // random status (frequencing/timing of request)
205 #pragma cyclus var {"default": "None", \
206 "tooltip": "type of random behavior when setting the " \
207 "timing of the request", \
208 "uitype": "combobox", \
209 "uilabel": "Random Timing", \
210 "categorical": ["None", "UniformInt", "NormalInt"], \
211 "doc": "type of random behavior to use. Default None, " \
212 "other options are, 'UniformInt', and 'NormalInt'. " \
213 "When using 'UniformInt', also set "\
214 "'random_frequency_min' and 'random_frequency_max'. " \
215 "For 'NormalInt', set 'random_frequency_mean' and " \
216 "'random_fequency_stddev', min and max values are " \
217 "optional. "}
218 std::string random_frequency_type;
219
220 // random frequency mean
221 #pragma cyclus var {"default": 1, \
222 "tooltip": "mean of the random frequency", \
223 "uilabel": "Random Frequency Mean", \
224 "uitype": "range", \
225 "range": [0.0, CY_LARGE_DOUBLE], \
226 "doc": "When a normal distribution is used to determine the " \
227 "frequency of the request, this is the mean. Default 1"}
229
230 // random frequency std dev
231 #pragma cyclus var {"default": 1, \
232 "tooltip": "std dev of the random frequency", \
233 "uilabel": "Random Frequency Std Dev", \
234 "uitype": "range", \
235 "range": [0.0, CY_LARGE_DOUBLE], \
236 "doc": "When a normal distribution is used to determine the " \
237 "frequency of the request, this is the standard deviation. Default 1"}
239
240 // random frequency lower bound
241 #pragma cyclus var {"default": 1, \
242 "tooltip": "lower bound of the random frequency", \
243 "uilabel": "Random Frequency Lower Bound", \
244 "uitype": "range", \
245 "range": [1, CY_LARGE_INT], \
246 "doc": "When a random distribution is used to determine the " \
247 "frequency of the request, this is the lower bound. Default 1"}
249
250 // random frequency upper bound
251 #pragma cyclus var {"default": CY_LARGE_INT, \
252 "tooltip": "upper bound of the random frequency", \
253 "uilabel": "Random Frequency Upper Bound", \
254 "uitype": "range", \
255 "range": [1, CY_LARGE_INT], \
256 "doc": "When a random distribution is used to determine the " \
257 f"frequency of the request, this is the upper bound. Default {CY_LARGE_INT} (CY_LARGE_INT)"}
259
260 #pragma cyclus var { \
261 "default": True, \
262 "tooltip": "Whether to persist packaging in the sink.", \
263 "doc": "Boolean value about whether to keep packaging. If true, " \
264 "packaging will not be stripped upon acceptance into the " \
265 "sink. If false, package type will be stripped immediately " \
266 "upon acceptance. Has no effect if the incoming material is not " \
267 "packaged.", \
268 "uilabel": "Keep Packaging", \
269 "uitype": "bool"}
270 bool keep_packaging;
271
272 #pragma cyclus var { \
273 "default": 0.0, \
274 "uilabel": "Geographical latitude in degrees as a double", \
275 "doc": "Latitude of the agent's geographical position. The value should " \
276 "be expressed in degrees as a double." \
277 }
278 double latitude;
279
280 #pragma cyclus var { \
281 "default": 0.0, \
282 "uilabel": "Geographical longitude in degrees as a double", \
283 "doc": "Longitude of the agent's geographical position. The value should " \
284 "be expressed in degrees as a double." \
285 }
286 double longitude;
287
288 cyclus::toolkit::Position coordinates;
289
291};
292
293} // namespace cycamore
294
295#endif // CYCAMORE_SRC_SINK_H_
#define CYCAMORE_VERSION
virtual std::set< cyclus::RequestPortfolio< cyclus::Product >::Ptr > GetGenRsrcRequests()
SinkFacilities request Products of their given commodity.
cyclus::toolkit::ResBuf< cyclus::Resource > inventory
this facility holds material in storage.
Sink(cyclus::Context *ctx)
std::vector< std::string > in_commods
all facilities must have at least one input commodity
std::vector< double > in_commod_prefs
std::string random_frequency_type
virtual void AcceptGenRsrcTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Product >, cyclus::Product::Ptr > > &responses)
SinkFacilities place accepted trade Materials in their Inventory.
virtual void SetRequestAmt()
SinkFacilities update request amount using random behavior.
const std::vector< double > & input_commodity_preferences() const
Definition src/sink.h:115
void SetMaxInventorySize(double size)
sets the size of the storage inventory for received material
Definition src/sink.h:86
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
SinkFacilities request Materials of their given commodity.
std::string random_size_type
random status (size of request)
double capacity
monthly acceptance capacity
cyclus::toolkit::Position coordinates
double SpaceAvailable() const
determines the amount to request
Definition src/sink.h:98
virtual void SetNextBuyTime()
SinkFacilities update request time using random behavior.
virtual void Tick()
double InventorySize() const
Definition src/sink.h:95
virtual void Tock()
double Capacity() const
Definition src/sink.h:107
double max_inv_size
max inventory size
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
SinkFacilities place accepted trade Materials in their Inventory.
virtual void EnterNotify()
virtual std::string version()
Definition src/sink.h:31
virtual std::string str()
double MaxInventorySize() const
Definition src/sink.h:92
virtual ~Sink()
const std::vector< std::string > & input_commodities() const
Definition src/sink.h:111
void AddCommodity(std::string name)
add a commodity to the set of input commodities
Definition src/sink.h:82
void Capacity(double cap)
sets the capacity of a material generated at any given time step
Definition src/sink.h:104
void RecordPosition()