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