CYCLUS
enrichment.cc
Go to the documentation of this file.
1 #include "enrichment.h"
2 
3 #include <cmath>
4 #include <sstream>
5 
6 #include "error.h"
7 #include "cyc_limits.h"
8 #include "logger.h"
9 #include "mat_query.h"
10 
11 namespace cyclus {
12 namespace toolkit {
13 
14 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 Assays::Assays(double feed, double product, double tails)
16  : feed_(feed),
17  product_(product),
18  tails_(tails) {}
19 
20 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
21 double Assays::Feed() const {
22  return feed_;
23 }
24 
25 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26 double Assays::Product() const {
27  return product_;
28 }
29 
30 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
31 double Assays::Tails() const {
32  return tails_;
33 }
34 
35 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37  double value;
38  MatQuery mq(rsrc);
39  double u235 = mq.atom_frac(922350000);
40  double u238 = mq.atom_frac(922380000);
41 
42  LOG(LEV_DEBUG1, "CEnr") << "Comparing u235 atom fraction : "
43  << u235 << " with u238 atom fraction: "
44  << u238;
45 
46  if (u235 + u238 > 0) {
47  value = u235 / (u235 + u238);
48  } else {
49  value = 0;
50  }
51  return value;
52 }
53 
54 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
55 double UraniumQty(Material::Ptr rsrc) {
56  MatQuery mq(rsrc);
57  return mq.mass(922350000) + mq.mass(922380000);
58 }
59 
60 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61 double FeedQty(double product_qty, const Assays& assays) {
62  double factor =
63  (assays.Product() - assays.Tails())
64  /
65  (assays.Feed() - assays.Tails());
66  return product_qty * factor;
67 }
68 
69 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70 double TailsQty(double product_qty, const Assays& assays) {
71  double factor =
72  (assays.Product() - assays.Feed())
73  /
74  (assays.Feed() - assays.Tails());
75  return product_qty * factor;
76 }
77 
78 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79 double ValueFunc(double frac) {
80  if (frac < 0) {
81  std::stringstream msg;
82  msg << "The provided fraction (" << frac
83  << ") is lower than the acceptable range.";
84  throw ValueError(msg.str());
85  }
86 
87  if (frac >= 1) {
88  std::stringstream msg;
89  msg << "The provided fraction (" << frac
90  << ") is higher than the acceptable range.";
91  throw ValueError(msg.str());
92  }
93 
94  return (1 - 2 * frac) * std::log(1 / frac - 1);
95 }
96 
97 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98 double SwuRequired(double product_qty, const Assays& assays) {
99  double feed = FeedQty(product_qty, assays);
100  double tails = TailsQty(product_qty, assays);
101  double swu =
102  product_qty * ValueFunc(assays.Product()) +
103  tails * ValueFunc(assays.Tails()) -
104  feed * ValueFunc(assays.Feed());
105  return swu;
106 }
107 
108 } // namespace toolkit
109 } // namespace cyclus
Assays(double feed, double product, double tails)
Constructor.
Definition: enrichment.cc:15
double SwuRequired(double product_qty, const Assays &assays)
Definition: enrichment.cc:98
For values that are too big, too small, etc.
Definition: error.h:41
boost::shared_ptr< Material > Ptr
Definition: material.h:75
double FeedQty(double product_qty, const Assays &assays)
inline double UraniumQty(Material::Ptr mat) { return UraniumQty(mat.get()); }
Definition: enrichment.cc:61
double UraniumQty(Material::Ptr rsrc)
inline double UraniumAssay(Material::Ptr mat) { return UraniumAssay(mat.get()); } ...
Definition: enrichment.cc:55
double Tails() const
Definition: enrichment.cc:31
A simple container class for enrichment assays.
Definition: enrichment.h:12
double atom_frac(Nuc nuc)
returns the atom/mole fraction of nuclide nuc in the material.
Definition: mat_query.cc:38
A class that provides convenience methods for querying a material&#39;s properties.
Definition: mat_query.h:12
double UraniumAssay(Material::Ptr rsrc)
Definition: enrichment.cc:36
double Feed() const
Definition: enrichment.cc:21
double Product() const
Definition: enrichment.cc:26
Code providing rudimentary logging capability for the Cyclus core.
double ValueFunc(double frac)
Definition: enrichment.cc:79
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
debugging information - least verbose
Definition: logger.h:58
double mass(Nuc nuc)
Returns the mass in kg of nuclide nuc in the material.
Definition: mat_query.cc:15
Top-level enrichment functionality.
double TailsQty(double product_qty, const Assays &assays)
Definition: enrichment.cc:70
#define LOG(level, prefix)
allows easy logging via the streaming operator similar to std::cout; this is the primary way to use t...
Definition: logger.h:35