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  return UraniumAssayAtom(rsrc);
38 }
39 
40 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
42  double value;
43  MatQuery mq(rsrc);
44  double u235 = mq.atom_frac(922350000);
45  double u238 = mq.atom_frac(922380000);
46 
47  LOG(LEV_DEBUG1, "CEnr") << "Comparing u235 atom fraction : "
48  << u235 << " with u238 atom fraction: "
49  << u238;
50 
51  if (u235 + u238 > 0) {
52  value = u235 / (u235 + u238);
53  } else {
54  value = 0;
55  }
56  return value;
57 }
58 
59 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61  double value;
62  MatQuery mq(rsrc);
63  double u235 = mq.mass_frac(922350000);
64  double u238 = mq.mass_frac(922380000);
65 
66  LOG(LEV_DEBUG1, "CEnr") << "Comparing u235 mass fraction : "
67  << u235 << " with u238 mass fraction: "
68  << u238;
69 
70  if (u235 + u238 > 0) {
71  value = u235 / (u235 + u238);
72  } else {
73  value = 0;
74  }
75  return value;
76 }
77 
78 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
79 double UraniumQty(Material::Ptr rsrc) {
80  MatQuery mq(rsrc);
81  return mq.mass(922350000) + mq.mass(922380000);
82 }
83 
84 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
85 double FeedQty(double product_qty, const Assays& assays) {
86  double factor =
87  (assays.Product() - assays.Tails())
88  /
89  (assays.Feed() - assays.Tails());
90  return product_qty * factor;
91 }
92 
93 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 double TailsQty(double product_qty, const Assays& assays) {
95  double factor =
96  (assays.Product() - assays.Feed())
97  /
98  (assays.Feed() - assays.Tails());
99  return product_qty * factor;
100 }
101 
102 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
103 double ValueFunc(double frac) {
104  if (frac < 0) {
105  std::stringstream msg;
106  msg << "The provided fraction (" << frac
107  << ") is lower than the acceptable range.";
108  throw ValueError(msg.str());
109  }
110 
111  if (frac >= 1) {
112  std::stringstream msg;
113  msg << "The provided fraction (" << frac
114  << ") is higher than the acceptable range.";
115  throw ValueError(msg.str());
116  }
117 
118  return (1 - 2 * frac) * std::log(1 / frac - 1);
119 }
120 
121 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122 double SwuRequired(double product_qty, const Assays& assays) {
123  double feed = FeedQty(product_qty, assays);
124  double tails = TailsQty(product_qty, assays);
125  double swu =
126  product_qty * ValueFunc(assays.Product()) +
127  tails * ValueFunc(assays.Tails()) -
128  feed * ValueFunc(assays.Feed());
129  return swu;
130 }
131 
132 } // namespace toolkit
133 } // namespace cyclus
double Product() const
Definition: enrichment.cc:26
Assays(double feed, double product, double tails)
Constructor.
Definition: enrichment.cc:15
double SwuRequired(double product_qty, const Assays &assays)
Definition: enrichment.cc:122
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:85
double UraniumAssayMass(Material::Ptr rsrc)
Definition: enrichment.cc:60
double UraniumQty(Material::Ptr rsrc)
inline double UraniumAssay(Material::Ptr mat) { return UraniumAssay(mat.get()); } ...
Definition: enrichment.cc:79
double mass_frac(Nuc nuc)
Returns the mass fraction of nuclide nuc in the material.
Definition: mat_query.cc:23
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
double UraniumAssayAtom(Material::Ptr rsrc)
Definition: enrichment.cc:41
A class that provides convenience methods for querying a material&#39;s properties.
Definition: mat_query.h:12
double Tails() const
Definition: enrichment.cc:31
double UraniumAssay(Material::Ptr rsrc)
Definition: enrichment.cc:36
Code providing rudimentary logging capability for the Cyclus core.
double ValueFunc(double frac)
Definition: enrichment.cc:103
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 Feed() const
Definition: enrichment.cc:21
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:94
#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