CYCAMORE
src/mixer.h
Go to the documentation of this file.
1 #ifndef CYCAMORE_SRC_MIXER_H_
2 #define CYCAMORE_SRC_MIXER_H_
3 
4 #include <string>
5 #include "cycamore_version.h"
6 #include "cyclus.h"
7 
8 namespace cycamore {
9 
15 class Mixer : public cyclus::Facility {
16 #pragma cyclus note { \
17  "niche": "mixing facility", \
18  "doc": "Mixer mixes N streams with fixed, static, user-specified" \
19  " ratios into a single output stream. The Mixer has N input"\
20  " inventories: one for each streams to be mixed, and one output"\
21  " stream. The supplying of mixed material is constrained by "\
22  " available inventory of mixed material quantities.", \
23  }
24 
25  friend class MixerTest;
26 
27  public:
28  Mixer(cyclus::Context* ctx);
29  virtual ~Mixer(){};
30 
31  virtual void Tick();
32  virtual void Tock(){};
33  virtual void EnterNotify();
34 
35  virtual void AcceptMatlTrades(
36  const std::vector<std::pair<cyclus::Trade<cyclus::Material>,
37  cyclus::Material::Ptr> >& responses);
38 
39  virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
41 
42 #pragma cyclus clone
43 #pragma cyclus initfromcopy
44 #pragma cyclus infiletodb
45 #pragma cyclus initfromdb
46 #pragma cyclus schema
47 #pragma cyclus annotations
48 #pragma cyclus snapshot
49  // the following pragmas are ommitted and the functions are written
50  // manually in order to handle the vector of resource buffers:
51  //
52  // #pragma cyclus snapshotinv
53  // #pragma cyclus initinv
54 
55  virtual cyclus::Inventories SnapshotInv();
56  virtual void InitInv(cyclus::Inventories& inv);
57 
58  protected:
59 #pragma cyclus var { \
60  "alias": ["in_streams", [ "stream", [ "info", "mixing_ratio", "buf_size"], [ "commodities", "commodity", "pref"]]], \
61  "uitype": ["oneormore", [ "pair", ["pair", "double", "double"], ["oneormore", "incommodity", "double"]]], \
62  "uilabel": "", \
63  "doc": "", \
64  }
65  std::vector<std::pair<std::pair<double, double>, std::map<std::string, double> > > streams_;
66 
67  std::vector<std::map<std::string, double> > in_commods;
68  std::vector<double> in_buf_sizes;
69  std::vector<double> mixing_ratios;
70 
71  // custom SnapshotInv and InitInv and EnterNotify are used to persist this
72  // state var.
73  std::map<std::string, cyclus::toolkit::ResBuf<cyclus::Material> > streambufs;
74 
75 
76 #pragma cyclus var { \
77  "doc" : "Commodity on which to offer/supply mixed fuel material.", \
78  "uilabel" : "Output Commodity", "uitype" : "outcommodity", }
80 
81 #pragma cyclus var { \
82  "doc" : "Maximum amount of mixed material that can be stored." \
83  " If full, the facility halts operation until space becomes" \
84  " available.", \
85  "uilabel": "Maximum Leftover Inventory", \
86  "default": 1e299, \
87  "uitype": "range", \
88  "range": [0.0, 1e299], \
89  "units": "kg", \
90  }
91  double out_buf_size;
92 
93 #pragma cyclus var { "capacity" : "out_buf_size", }
94  cyclus::toolkit::ResBuf<cyclus::Material> output;
95 
96 #pragma cyclus var { \
97  "default": 1e299, \
98  "doc": "Maximum number of kg of fuel material that can be mixed per time step.", \
99  "uilabel": "Maximum Throughput", \
100  "uitype": "range", \
101  "range": [0.0, 1e299], \
102  "units": "kg", \
103  }
104  double throughput;
105 
106  // intra-time-step state - no need to be a state var
107  // map<request, inventory name>
108  std::map<cyclus::Request<cyclus::Material>*, std::string> req_inventories_;
109 
111  cyclus::toolkit::MatlSellPolicy sell_policy;
112 };
113 
114 } // namespace cycamore
115 
116 #endif // CYCAMORE_SRC_MIXER_H_
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
std::vector< double > in_buf_sizes
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
virtual void Tock()
Definition: src/mixer.h:32
virtual cyclus::Inventories SnapshotInv()
std::map< cyclus::Request< cyclus::Material > *, std::string > req_inventories_
virtual ~Mixer()
Definition: src/mixer.h:29
cycamore::GrowthRegion string
cyclus::toolkit::ResBuf< cyclus::Material > output
cyclus::toolkit::MatlSellPolicy sell_policy
Mixer(cyclus::Context *ctx)
std::vector< double > mixing_ratios
virtual void InitInv(cyclus::Inventories &inv)
std::map< std::string, cyclus::toolkit::ResBuf< cyclus::Material > > streambufs
std::vector< std::pair< std::pair< double, double >, std::map< std::string, double > > > streams_
std::vector< std::map< std::string, double > > in_commods