1#ifndef CYCAMORE_SRC_ENRICHMENT_H_
2#define CYCAMORE_SRC_ENRICHMENT_H_
9#pragma cyclus exec from cyclus.system import CY_LARGE_DOUBLE, CY_LARGE_INT, CY_NEAR_ZERO
17class SWUConverter :
public cyclus::Converter<cyclus::Material> {
25 cyclus::Material::Ptr m,
26 cyclus::Arc
const * a = NULL,
27 cyclus::ExchangeTranslationContext<cyclus::Material>
28 const * ctx = NULL)
const {
29 cyclus::toolkit::Assays assays(
feed_, cyclus::toolkit::UraniumAssayMass(m),
31 return cyclus::toolkit::SwuRequired(m->quantity(), assays);
37 return cast != NULL &&
38 feed_ == cast->feed_ &&
51class NatUConverter :
public cyclus::Converter<cyclus::Material> {
61 cyclus::Material::Ptr m,
62 cyclus::Arc
const * a = NULL,
63 cyclus::ExchangeTranslationContext<cyclus::Material>
64 const * ctx = NULL)
const {
65 cyclus::toolkit::Assays assays(
feed_, cyclus::toolkit::UraniumAssayMass(m),
67 cyclus::toolkit::MatQuery mq(m);
68 std::set<cyclus::Nuc> nucs;
69 nucs.insert(922350000);
70 nucs.insert(922380000);
72 double natu_frac = mq.mass_frac(nucs);
73 double natu_req = cyclus::toolkit::FeedQty(m->quantity(), assays);
74 return natu_req / natu_frac;
80 return cast != NULL &&
81 feed_ == cast->feed_ &&
123 :
public cyclus::Facility,
124 public cyclus::toolkit::Position {
125#pragma cyclus note { \
126 "niche": "enrichment facility", \
128 "The Enrichment facility is a simple agent that enriches natural " \
129 "uranium in a Cyclus simulation. It does not explicitly compute " \
130 "the physical enrichment process, rather it calculates the SWU " \
131 "required to convert a source uranium recipe (i.e. natural uranium) " \
132 "into a requested enriched recipe (i.e. 4% enriched uranium), given " \
133 "the natural uranium inventory constraint and its SWU capacity " \
136 "The Enrichment facility requests an input commodity and associated " \
137 "recipe whose quantity is its remaining inventory capacity. All " \
138 "facilities trading the same input commodity (even with different " \
139 "recipes) will offer materials for trade. The Enrichment facility " \
140 "accepts any input materials with enrichments less than its tails assay, "\
141 "as long as some U235 is present, and preference increases with U235 " \
142 "content. If no U235 is present in the offered material, the trade " \
143 "preference is set to -1 and the material is not accepted. Any material " \
144 "components other than U235 and U238 are sent directly to the tails buffer."\
146 "The Enrichment facility will bid on any request for its output commodity "\
147 "up to the maximum allowed enrichment (if not specified, default is 100%) "\
148 "It bids on either the request quantity, or the maximum quanity allowed " \
149 "by its SWU constraint or natural uranium inventory, whichever is lower. " \
150 "If multiple output commodities with different enrichment levels are " \
151 "requested and the facility does not have the SWU or quantity capacity " \
152 "to meet all requests, the requests are fully, then partially filled " \
153 "in unspecified but repeatable order. A request for the product " \
154 "commodity without an associated requested enriched recipe will not be " \
157 "Accumulated tails inventory is offered for trading as a specifiable " \
158 "output commodity.", \
174 virtual std::string
str();
179 virtual void Build(cyclus::Agent* parent);
197 virtual std::set<cyclus::RequestPortfolio<cyclus::Material>::Ptr>
208 const std::vector< std::pair<cyclus::Trade<cyclus::Material>,
209 cyclus::Material::Ptr> >& responses);
214 virtual std::set<cyclus::BidPortfolio<cyclus::Material>::Ptr>
224 const std::vector< cyclus::Trade<cyclus::Material> >& trades,
225 std::vector<std::pair<cyclus::Trade<cyclus::Material>,
226 cyclus::Material::Ptr> >& responses);
247 inline const cyclus::toolkit::ResBuf<cyclus::Material>&
Tails()
const {
266 cyclus::Material::Ptr
Offer_(cyclus::Material::Ptr req);
268 cyclus::Material::Ptr
Enrich_(cyclus::Material::Ptr mat,
double qty);
279 #pragma cyclus var { \
280 "tooltip": "feed commodity", \
281 "doc": "feed commodity that the enrichment facility accepts", \
282 "uilabel": "Feed Commodity", \
283 "uitype": "incommodity" \
287 #pragma cyclus var { \
288 "tooltip": "feed recipe", \
289 "doc": "recipe for enrichment facility feed commodity", \
290 "uilabel": "Feed Recipe", \
291 "uitype": "inrecipe" \
295 #pragma cyclus var { \
296 "tooltip": "product commodity", \
297 "doc": "product commodity that the enrichment facility generates", \
298 "uilabel": "Product Commodity", \
299 "uitype": "outcommodity" \
303 #pragma cyclus var { \
304 "tooltip": "tails commodity", \
305 "doc": "tails commodity supplied by enrichment facility", \
306 "uilabel": "Tails Commodity", \
307 "uitype": "outcommodity" \
311 #pragma cyclus var { \
312 "default": 0.003, "tooltip": "tails assay", \
313 "uilabel": "Tails Assay", \
315 "range": [0.0, 0.003], \
316 "doc": "tails assay from the enrichment process", \
320 #pragma cyclus var { \
321 "default": 0, "tooltip": "initial uranium reserves (kg)", \
322 "uilabel": "Initial Feed Inventory", \
323 "doc": "amount of natural uranium stored at the enrichment " \
324 "facility at the beginning of the simulation (kg)" \
328 #pragma cyclus var { \
329 "default": CY_LARGE_DOUBLE, "tooltip": "max inventory of feed material (kg)", \
330 "uilabel": "Maximum Feed Inventory", \
332 "range": [0.0, CY_LARGE_DOUBLE], \
333 "doc": "maximum total inventory of natural uranium in " \
334 "the enrichment facility (kg)" \
338 #pragma cyclus var { \
340 "tooltip": "maximum allowed enrichment fraction", \
341 "doc": "maximum allowed weight fraction of U235 in product", \
342 "uilabel": "Maximum Allowed Enrichment", \
344 "range": [0.0,1.0], \
345 "schema": '<optional>' \
346 ' <element name="max_enrich">' \
347 ' <data type="double">' \
348 ' <param name="minInclusive">0</param>' \
349 ' <param name="maxInclusive">1</param>' \
356 #pragma cyclus var { \
359 "tooltip": "Rank Material Requests by U235 Content", \
360 "uilabel": "Prefer feed with higher U235 content", \
361 "doc": "turn on preference ordering for input material " \
362 "so that EF chooses higher U235 content first" \
366 #pragma cyclus var { \
367 "default": CY_LARGE_DOUBLE, \
368 "tooltip": "SWU capacity (kgSWU/timestep)", \
369 "uilabel": "SWU Capacity", \
371 "range": [0.0, CY_LARGE_DOUBLE], \
372 "doc": "separative work unit (SWU) capacity of enrichment " \
373 "facility (kgSWU/timestep) " \
379 #pragma cyclus var { 'capacity': 'max_feed_inventory' }
380 cyclus::toolkit::ResBuf<cyclus::Material>
inventory;
381 #pragma cyclus var {}
382 cyclus::toolkit::ResBuf<cyclus::Material>
tails;
392 #pragma cyclus var { \
394 "uilabel": "Geographical latitude in degrees as a double", \
395 "doc": "Latitude of the agent's geographical position. The value should " \
396 "be expressed in degrees as a double." \
400 #pragma cyclus var { \
402 "uilabel": "Geographical longitude in degrees as a double", \
403 "doc": "Longitude of the agent's geographical position. The value should " \
404 "be expressed in degrees as a double." \
void RecordPosition()
Records an agent's latitude and longitude to the output db.
void SwuCapacity(double capacity)
double current_swu_capacity
cyclus::Material::Ptr Enrich_(cyclus::Material::Ptr mat, double qty)
cyclus::Material::Ptr Offer_(cyclus::Material::Ptr req)
Generates a material offer for a given request.
std::string product_commod
void SetMaxInventorySize(double size)
virtual void Tock()
Each facility is prompted to its end-of-time-step stuff on the tock of the timer.
const cyclus::toolkit::ResBuf< cyclus::Material > & Tails() const
cyclus::toolkit::ResBuf< cyclus::Material > tails
bool ValidReq(const cyclus::Material::Ptr mat)
Determines if a particular material is a valid request to respond to.
double intra_timestep_swu_
cyclus::toolkit::Position coordinates
virtual std::set< cyclus::RequestPortfolio< cyclus::Material >::Ptr > GetMatlRequests()
The Enrichment request Materials of its given commodity.
cyclus::Material::Ptr Request_()
generates a request for this facility given its current state.
virtual void AdjustMatlPrefs(cyclus::PrefMap< cyclus::Material >::type &prefs)
The Enrichment adjusts preferences for offers of natural uranium it has received to maximize U-235 co...
double SwuCapacity() const
virtual void AcceptMatlTrades(const std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
The Enrichment place accepted trade Materials in their Inventory.
double FeedAssay()
calculates the feed assay based on the unenriched inventory
virtual std::set< cyclus::BidPortfolio< cyclus::Material >::Ptr > GetMatlBids(cyclus::CommodMap< cyclus::Material >::type &commod_requests)
Responds to each request for this facility's commodity.
virtual void Tick()
Each facility is prompted to do its beginning-of-time-step stuff at the tick of the timer.
virtual std::string str()
Print information about this agent.
void RecordEnrichment_(double natural_u, double swu)
records and enrichment with the cyclus::Recorder
virtual std::string version()
virtual ~Enrichment()
Destructor for the Enrichment class.
virtual void Build(cyclus::Agent *parent)
perform module-specific tasks when entering the simulation
double intra_timestep_feed_
Enrichment(cyclus::Context *ctx)
Constructor for the Enrichment class.
cyclus::toolkit::ResBuf< cyclus::Material > inventory
virtual void GetMatlTrades(const std::vector< cyclus::Trade< cyclus::Material > > &trades, std::vector< std::pair< cyclus::Trade< cyclus::Material >, cyclus::Material::Ptr > > &responses)
respond to each trade with a material enriched to the appropriate level given this facility's invento...
double max_feed_inventory
void AddMat_(cyclus::Material::Ptr mat)
adds a material into the natural uranium inventory
The NatUConverter is a simple Converter class for material to determine the amount of natural uranium...
virtual std::string version()
virtual bool operator==(Converter &other) const
NatUConverter(double feed_commod, double tails)
virtual double convert(cyclus::Material::Ptr m, cyclus::Arc const *a=NULL, cyclus::ExchangeTranslationContext< cyclus::Material > const *ctx=NULL) const
provides a conversion for the amount of natural Uranium required
The SWUConverter is a simple Converter class for material to determine the amount of SWU required for...
virtual double convert(cyclus::Material::Ptr m, cyclus::Arc const *a=NULL, cyclus::ExchangeTranslationContext< cyclus::Material > const *ctx=NULL) const
provides a conversion for the SWU required
SWUConverter(double feed_commod, double tails)
virtual bool operator==(Converter &other) const