21 "Decayer is deprecated in favor of pyne::decayers::decay");
25 long double atom_count;
26 bool needs_build =
false;
28 std::map<int, double>::const_iterator comp_iter = comp.begin();
29 for (comp_iter = comp.begin(); comp_iter != comp.end(); ++comp_iter) {
30 nuc = comp_iter->first;
31 atom_count = comp_iter->second;
32 if (!IsNucTracked(nuc)) {
38 if (needs_build) BuildDecayMatrix();
40 pre_vect_ =
Vector(parent_.size(), 1);
41 for (comp_iter = comp.begin(); comp_iter != comp.end(); ++comp_iter) {
42 nuc = comp_iter->first;
43 atom_count = comp_iter->second;
44 col = parent_[nuc].first;
45 pre_vect_(col, 1) = atom_count;
52void Decayer::AddNucToMaps(
int nuc) {
56 std::set<int> daughters;
57 std::set<int>::iterator d;
59 if (IsNucTracked(nuc))
return;
61 col = parent_.size() + 1;
67 std::vector<std::pair<int, double>> dvec(daughters.size());
68 for (d = daughters.begin(); d != daughters.end(); ++d) {
70 AddNucToMaps(daughter);
74 daughters_[col] = dvec;
78bool Decayer::IsNucTracked(
int nuc) {
79 return (find(nuclides_tracked_.begin(), nuclides_tracked_.end(), nuc) !=
80 nuclides_tracked_.end());
84void Decayer::AddNucToList(
int nuc) {
85 if (!IsNucTracked(nuc)) {
86 nuclides_tracked_.push_back(nuc);
94 ParentMap::const_iterator parent_iter = parent_.begin();
95 while (parent_iter != parent_.end()) {
96 int nuc = parent_iter->first;
97 int col = parent_.find(nuc)->second.first;
100 if (col <= post_vect_.NumRows()) {
101 double atom_count = post_vect_(col, 1);
103 if (atom_count > 0) {
104 comp[nuc] = atom_count;
107 LOG(
LEV_ERROR,
"none!") <<
"Decay Error - invalid Vector position";
114void Decayer::BuildDecayMatrix() {
115 double decay_const = 0;
117 int n = parent_.size();
118 decay_matrix_ =
Matrix(n, n);
120 ParentMap::const_iterator parent_iter = parent_.begin();
123 while (parent_iter != parent_.end()) {
124 jcol = parent_iter->second.first;
125 decay_const = parent_iter->second.second;
127 if (
static_cast<long double>(exp(-2903040000 * decay_const)) == 0.0)
129 decay_matrix_(jcol, jcol) = -1 * decay_const;
132 if (!daughters_.find(jcol)->second.empty()) {
135 std::vector<std::pair<int, double>>::const_iterator nuc_iter =
136 daughters_.find(jcol)->second.begin();
139 while (nuc_iter != daughters_.find(jcol)->second.end()) {
140 int nuc = nuc_iter->first;
141 int irow = parent_.find(nuc)->second.first;
142 double branch_ratio = nuc_iter->second;
143 decay_matrix_(irow, jcol) =
144 branch_ratio * decay_const;
156 "the cyclus decayer has not yet been benchmarked and "
157 "should be considered experimental.");
void GetResult(CompMap &comp)
set the composition from a CompMap
Decayer(const CompMap &comp)
void Decay(double secs)
decay the material
Code providing rudimentary logging capability for the Cyclus core.
#define LOG(level, prefix)
allows easy logging via the streaming operator similar to std::cout; this is the primary way to use t...
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
@ LEV_ERROR
Use for errors that require agent code or input file modification (use extremely sparingly)
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
std::map< int, std::vector< std::pair< int, double > > > DaughtersMap
A map type to represent all of the daughter nuclides tracked.
std::map< int, std::pair< int, double > > ParentMap
A map type to represent all of the parent nuclides tracked.
void Warn(const std::string &msg)
Issue a warning with the approriate message, accoring to the current warning settings.
std::vector< int > NucList
double decay_const(int nuc)
Returns the decay constant for a nuclide nuc.
std::set< int > decay_children(int nuc)
Returns a set of decay children of a nuc.
double branch_ratio(std::pair< int, int > from_to)
Returns the branch ratio for a parent/child nuclide pair.