CYCLUS
Loading...
Searching...
No Matches
mat_query.cc
Go to the documentation of this file.
1#include "mat_query.h"
2#include "pyne.h"
3
4#include <cmath>
5
6namespace cyclus {
7namespace toolkit {
8
10
11double MatQuery::qty() {
12 return m_->quantity();
13}
14
15double MatQuery::mass(Nuc nuc) {
16 return mass_frac(nuc) * qty();
17}
18
19double MatQuery::moles(Nuc nuc) {
20 return mass(nuc) / (pyne::atomic_mass(nuc) * units::g);
21}
22
24 CompMap v = m_->comp()->mass();
26 return v[nuc];
27}
28
29double MatQuery::mass_frac(std::set<Nuc> nucs) {
30 double m_tot = 0;
31 std::set<Nuc>::iterator it ;
32 for (it = nucs.begin(); it != nucs.end(); ++it) {
33 m_tot += mass(*it);
34 }
35 return m_tot/qty();
36}
37
39 CompMap v = m_->comp()->atom();
41 return v[nuc];
42}
43
44double MatQuery::atom_frac(std::set<Nuc> nucs) {
45 CompMap v = m_->comp()->atom();
47
48 double frac_tot = 0;
49 std::set<Nuc>::iterator it ;
50 for (it = nucs.begin(); it != nucs.end(); ++it) {
51 if (v.find(*it) != v.end()){
52 frac_tot += v[*it];
53 }
54 }
55 return frac_tot;
56}
57
58double MatQuery::mass(std::string nuc) {
59 return mass(pyne::nucname::id(nuc));
60}
61
62double MatQuery::moles(std::string nuc) {
63 return moles(pyne::nucname::id(nuc));
64}
65
66double MatQuery::mass_frac(std::string nuc) {
67 return mass_frac(pyne::nucname::id(nuc));
68}
69
70double MatQuery::atom_frac(std::string nuc) {
71 return atom_frac(pyne::nucname::id(nuc));
72}
73
75 CompMap n1 = m_->comp()->mass();
76 CompMap n2 = other->comp()->mass();
80}
81
83 CompMap m = m_->comp()->mass();
84 CompMap m_other = c->mass();
85
88
91 CompMap::iterator it;
92 for (it = m_other.begin(); it != m_other.end(); ++it) {
93 Nuc nuc = it->first;
94 double qty_other = it->second;
95 if (m.count(nuc) == 0 && qty_other > 0) {
96 return 0;
97 }
98 double qty = m[nuc];
99
100 double ratio = qty / qty_other;
101 if (ratio < min_ratio) {
102 min_ratio = ratio;
103 limiter = nuc;
104 }
105 }
106
107 double mult = min_ratio * qty();
109 double sum = 0;
110 for (it = m_other.begin(); it != m_other.end(); ++it) {
111 sum += it->second;
112 }
113 return sum;
114}
115
116} // namespace toolkit
117} // namespace cyclus
boost::shared_ptr< Composition > Ptr
Definition composition.h:43
boost::shared_ptr< Material > Ptr
Definition material.h:75
MatQuery(Material::Ptr m)
Creates a new query object inspecting m.
Definition mat_query.cc:9
double atom_frac(Nuc nuc)
returns the atom/mole fraction of nuclide nuc in the material.
Definition mat_query.cc:38
bool AlmostEq(Material::Ptr other, double threshold=eps_rsrc())
Returns true if all nuclide fractions of the material and other are the same within threshold.
Definition mat_query.cc:74
double qty()
Returns the mass in kg of the material.
Definition mat_query.cc:11
double mass_frac(Nuc nuc)
Returns the mass fraction of nuclide nuc in the material.
Definition mat_query.cc:23
double mass(Nuc nuc)
Returns the mass in kg of nuclide nuc in the material.
Definition mat_query.cc:15
double moles(Nuc nuc)
Returns the number of moles of nuclide nuc in the material.
Definition mat_query.cc:19
double Amount(Composition::Ptr c)
Returns the maximum mass quantity of composition c that can be extracted from the material.
Definition mat_query.cc:82
bool AlmostEq(const CompMap &v1, const CompMap &v2, double threshold)
Returns true if all nuclides of v1 and v2 are the same within threshold.
Definition comp_math.cc:93
void Normalize(CompMap *v, double val)
The sum of quantities of all nuclides of v is normalized to val.
Definition comp_math.cc:63
const double g
Definition material.h:18
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
Definition composition.h:17
int Nuc
Definition composition.h:14
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
static const double CY_LARGE_DOUBLE
maximum (+) value for a linear variable
Definition cyc_limits.h:44
int id(int nuc)
Definition pyne.cc:2716
double atomic_mass(int nuc)
Returns the atomic mass of a nuclide nuc.
Definition pyne.cc:10440