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
16  : public cyclus::Facility,
17  public cyclus::toolkit::Position {
18 #pragma cyclus note { \
19  "niche": "mixing facility", \
20  "doc": "Mixer mixes N streams with fixed, static, user-specified" \
21  " ratios into a single output stream. The Mixer has N input"\
22  " inventories: one for each streams to be mixed, and one output"\
23  " stream. The supplying of mixed material is constrained by "\
24  " available inventory of mixed material quantities.", \
25  }
26 
27  friend class MixerTest;
28 
29  public:
30  Mixer(cyclus::Context* ctx);
31  virtual ~Mixer(){};
32 
33  virtual void Tick();
34  virtual void Tock(){};
35  virtual void EnterNotify();
36 
37  virtual void AcceptMatlTrades(
38  const std::vector<std::pair<cyclus::Trade<cyclus::Material>,
39  cyclus::Material::Ptr> >& responses);
40 
41  virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
43 
44 #pragma cyclus clone
45 #pragma cyclus initfromcopy
46 #pragma cyclus infiletodb
47 #pragma cyclus initfromdb
48 #pragma cyclus schema
49 #pragma cyclus annotations
50 #pragma cyclus snapshot
51  // the following pragmas are ommitted and the functions are written
52  // manually in order to handle the vector of resource buffers:
53  //
54  // #pragma cyclus snapshotinv
55  // #pragma cyclus initinv
56 
57  virtual cyclus::Inventories SnapshotInv();
58  virtual void InitInv(cyclus::Inventories& inv);
59 
60  protected:
61 #pragma cyclus var { \
62  "alias": ["in_streams", [ "stream", [ "info", "mixing_ratio", "buf_size"], [ "commodities", "commodity", "pref"]]], \
63  "uitype": ["oneormore", [ "pair", ["pair", "double", "double"], ["oneormore", "incommodity", "double"]]], \
64  "uilabel": "", \
65  "doc": "", \
66  }
67  std::vector<std::pair<std::pair<double, double>, std::map<std::string, double> > > streams_;
68 
69  std::vector<std::map<std::string, double> > in_commods;
70  std::vector<double> in_buf_sizes;
71  std::vector<double> mixing_ratios;
72 
73  // custom SnapshotInv and InitInv and EnterNotify are used to persist this
74  // state var.
75  std::map<std::string, cyclus::toolkit::ResBuf<cyclus::Material> > streambufs;
76 
77 
78 #pragma cyclus var { \
79  "doc" : "Commodity on which to offer/supply mixed fuel material.", \
80  "uilabel" : "Output Commodity", "uitype" : "outcommodity", }
82 
83 #pragma cyclus var { \
84  "doc" : "Maximum amount of mixed material that can be stored." \
85  " If full, the facility halts operation until space becomes" \
86  " available.", \
87  "uilabel": "Maximum Leftover Inventory", \
88  "default": 1e299, \
89  "uitype": "range", \
90  "range": [0.0, 1e299], \
91  "units": "kg", \
92  }
93  double out_buf_size;
94 
95 #pragma cyclus var { "capacity" : "out_buf_size", }
96  cyclus::toolkit::ResBuf<cyclus::Material> output;
97 
98 #pragma cyclus var { \
99  "default": 1e299, \
100  "doc": "Maximum number of kg of fuel material that can be mixed per time step.", \
101  "uilabel": "Maximum Throughput", \
102  "uitype": "range", \
103  "range": [0.0, 1e299], \
104  "units": "kg", \
105  }
106  double throughput;
107 
108  // intra-time-step state - no need to be a state var
109  // map<request, inventory name>
110  std::map<cyclus::Request<cyclus::Material>*, std::string> req_inventories_;
111 
113  cyclus::toolkit::MatlSellPolicy sell_policy;
114 
115  private:
116  #pragma cyclus var { \
117  "default": 0.0, \
118  "uilabel": "Geographical latitude in degrees as a double", \
119  "doc": "Latitude of the agent's geographical position. The value should " \
120  "be expressed in degrees as a double." \
121  }
122  double latitude;
123 
124  #pragma cyclus var { \
125  "default": 0.0, \
126  "uilabel": "Geographical longitude in degrees as a double", \
127  "doc": "Longitude of the agent's geographical position. The value should " \
128  "be expressed in degrees as a double." \
129  }
130  double longitude;
131 
132  cyclus::toolkit::Position coordinates;
133 
135  void RecordPosition();
136 };
137 
138 } // namespace cycamore
139 
140 #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)
void RecordPosition()
Records an agent&#39;s latitude and longitude to the output db.
virtual void Tock()
Definition: src/mixer.h:34
virtual cyclus::Inventories SnapshotInv()
std::map< cyclus::Request< cyclus::Material > *, std::string > req_inventories_
virtual ~Mixer()
Definition: src/mixer.h:31
cycamore::GrowthRegion string
cyclus::toolkit::ResBuf< cyclus::Material > output
cyclus::toolkit::MatlSellPolicy sell_policy
Mixer(cyclus::Context *ctx)
cyclus::toolkit::Position coordinates
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