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 // Code Injection:
119 #include "toolkit/position.cycpp.h"
120
121 double requestAmt;
122 int nextBuyTime;
124 #pragma cyclus var {"tooltip": "input commodities", \
125 "doc": "commodities that the sink facility accepts", \
126 "uilabel": "List of Input Commodities", \
127 "uitype": ["oneormore", "incommodity"]}
128 std::vector<std::string> in_commods;
129
130 #pragma cyclus var {"default": [],\
131 "doc":"preferences for each of the given commodities, in the same order."\
132 "Defauts to 1 if unspecified",\
133 "uilabel":"In Commody Preferences", \
134 "range": [None, [CY_NEAR_ZERO, CY_LARGE_DOUBLE]], \
135 "uitype":["oneormore", "range"]}
136 std::vector<double> in_commod_prefs;
137
138 #pragma cyclus var {"default": "", \
139 "tooltip": "requested composition", \
140 "doc": "name of recipe to use for material requests, " \
141 "where the default (empty string) is to accept " \
142 "everything", \
143 "uilabel": "Input Recipe", \
144 "uitype": "inrecipe"}
145 std::string recipe_name;
146
148 #pragma cyclus var {"default": CY_LARGE_DOUBLE, \
149 "tooltip": "sink maximum inventory size", \
150 "uilabel": "Maximum Inventory", \
151 "uitype": "range", \
152 "range": [0.0, CY_LARGE_DOUBLE], \
153 "doc": "total maximum inventory size of sink facility"}
154 double max_inv_size;
155
157 #pragma cyclus var {"default": CY_LARGE_DOUBLE, \
158 "tooltip": "sink capacity", \
159 "uilabel": "Maximum Throughput", \
160 "uitype": "range", \
161 "range": [0.0, CY_LARGE_DOUBLE], \
162 "doc": "capacity the sink facility can " \
163 "accept at each time step"}
164 double capacity;
165
167 #pragma cyclus var {'capacity': 'max_inv_size'}
168 cyclus::toolkit::ResBuf<cyclus::Resource> inventory;
169
171 #pragma cyclus var {"default": "None", \
172 "tooltip": "type of random behavior when setting the " \
173 "size of the request", \
174 "uitype": "combobox", \
175 "uilabel": "Random Size", \
176 "categorical": ["None", "UniformReal", "UniformInt", "NormalReal", "NormalInt"], \
177 "doc": "type of random behavior to use. Default None, " \
178 "other options are 'UniformReal', 'UniformInt', " \
179 "'NormalReal', and 'NormalInt'"}
180 std::string random_size_type;
181
182 // random size mean (as a fraction of available space)
183 #pragma cyclus var {"default": 1.0, \
184 "tooltip": "fraction of available space to determine the mean", \
185 "uilabel": "Random Size Mean", \
186 "uitype": "range", \
187 "range": [0.0, CY_LARGE_DOUBLE], \
188 "doc": "When a normal distribution is used to determine the " \
189 "size of the request, this is the fraction of available " \
190 "space to use as the mean. Default 1.0. Note " \
191 "that values significantly above 1 without a " \
192 "correspondingly large std dev may result in " \
193 "inefficient use of the random number generator."}
194 double random_size_mean;
195
196 // random size std dev (as a fraction of available space)
197 #pragma cyclus var {"default": 0.1, \
198 "tooltip": "fraction of available space to determine the std dev", \
199 "uilabel": "Random Size Std Dev", \
200 "uitype": "range", \
201 "range": [0.0, CY_LARGE_DOUBLE], \
202 "doc": "When a normal distribution is used to determine the " \
203 "size of the request, this is the fraction of available " \
204 "space to use as the standard deviation. Default 0.1"}
205 double random_size_stddev;
206
207 // random status (frequencing/timing of request)
208 #pragma cyclus var {"default": "None", \
209 "tooltip": "type of random behavior when setting the " \
210 "timing of the request", \
211 "uitype": "combobox", \
212 "uilabel": "Random Timing", \
213 "categorical": ["None", "UniformInt", "NormalInt"], \
214 "doc": "type of random behavior to use. Default None, " \
215 "other options are, 'UniformInt', and 'NormalInt'. " \
216 "When using 'UniformInt', also set "\
217 "'random_frequency_min' and 'random_frequency_max'. " \
218 "For 'NormalInt', set 'random_frequency_mean' and " \
219 "'random_fequency_stddev', min and max values are " \
220 "optional. "}
221 std::string random_frequency_type;
222
223 // random frequency mean
224 #pragma cyclus var {"default": 1, \
225 "tooltip": "mean of the random frequency", \
226 "uilabel": "Random Frequency Mean", \
227 "uitype": "range", \
228 "range": [0.0, CY_LARGE_DOUBLE], \
229 "doc": "When a normal distribution is used to determine the " \
230 "frequency of the request, this is the mean. Default 1"}
232
233 // random frequency std dev
234 #pragma cyclus var {"default": 1, \
235 "tooltip": "std dev of the random frequency", \
236 "uilabel": "Random Frequency Std Dev", \
237 "uitype": "range", \
238 "range": [0.0, CY_LARGE_DOUBLE], \
239 "doc": "When a normal distribution is used to determine the " \
240 "frequency of the request, this is the standard deviation. Default 1"}
242
243 // random frequency lower bound
244 #pragma cyclus var {"default": 1, \
245 "tooltip": "lower bound of the random frequency", \
246 "uilabel": "Random Frequency Lower Bound", \
247 "uitype": "range", \
248 "range": [1, CY_LARGE_INT], \
249 "doc": "When a random distribution is used to determine the " \
250 "frequency of the request, this is the lower bound. Default 1"}
252
253 // random frequency upper bound
254 #pragma cyclus var {"default": CY_LARGE_INT, \
255 "tooltip": "upper bound of the random frequency", \
256 "uilabel": "Random Frequency Upper Bound", \
257 "uitype": "range", \
258 "range": [1, CY_LARGE_INT], \
259 "doc": "When a random distribution is used to determine the " \
260 f"frequency of the request, this is the upper bound. Default {CY_LARGE_INT} (CY_LARGE_INT)"}
262
263 #pragma cyclus var { \
264 "default": True, \
265 "tooltip": "Whether to persist packaging in the sink.", \
266 "doc": "Boolean value about whether to keep packaging. If true, " \
267 "packaging will not be stripped upon acceptance into the " \
268 "sink. If false, package type will be stripped immediately " \
269 "upon acceptance. Has no effect if the incoming material is not " \
270 "packaged.", \
271 "uilabel": "Keep Packaging", \
272 "uitype": "bool"}
273 bool keep_packaging;
274
275};
276
277} // namespace cycamore
278
279#endif // CYCAMORE_SRC_SINK_H_
#define CYCAMORE_VERSION
This facility acts as a sink of materials and products with a fixed throughput (per time step) capaci...
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
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