CYCLUS
Loading...
Searching...
No Matches
composition.h
Go to the documentation of this file.
1#ifndef CYCLUS_SRC_COMPOSITION_H_
2#define CYCLUS_SRC_COMPOSITION_H_
3
4#include <map>
5#include <stdint.h>
6#include <boost/shared_ptr.hpp>
7
8class SimInitTest;
9
10namespace cyclus {
11
12class Context;
13
14typedef int Nuc;
15
16/// a raw definition of nuclides and corresponding (dimensionless quantities).
17typedef std::map<Nuc, double> CompMap;
18
19/// An immutable object responsible for holding a nuclide composition. It tracks
20/// decay lineages to prevent duplicate calculations and output recording and is
21/// able to record its composition data to output when told. Each composition
22/// keeps a pointer to references to every other composition that is a result of
23/// decaying this or a previously decayed-from composition.
24///
25/// Compositions are immutable and thus their state must be created/defined
26/// entirely at their creation. Compositions are created by passing in a
27/// CompMap (a map of nuclides to quantities). In general CompMaps are
28/// not assumed to be normalized to any particular value. A Uranium dioxide
29/// composition can be created as follows:
30///
31/// @code
32/// CompMap v;
33/// v[922350000] = 2.4;
34/// v[80160000] = 4.8;
35/// Composition c = Composition::CreateFromAtom(v);
36/// @endcode
37///
39 friend class SimInit;
40 friend class ::SimInitTest;
41
42 public:
43 typedef boost::shared_ptr<Composition> Ptr;
44
45 /// Creates a new composition from v with its components having appropriate
46 /// atom-based ratios. v does not need to be normalized to any particular
47 /// value.
49
50 /// Creates a new composition from v with its components having appropriate
51 /// mass-based ratios. v does not need to be normalized to any particular
52 /// value.
54
55 /// Returns a unique id associated with this composition. Note that multiple
56 /// material objects can share the same composition. Also Note that the id is
57 /// not the same for two compositions that were separately created from the
58 /// same CompMap.
59 int id();
60
61 /// Returns the unnormalized atom composition.
62 const CompMap& atom();
63
64 /// Returns the unnormalized mass composition.
65 const CompMap& mass();
66
67 /// Returns a decayed version of this composition (decayed delta timesteps)
68 /// assuming a time step is 1/12 of one year in duration. This composition
69 /// remains unchanged.
70 Ptr Decay(int delta);
71
72 /// Returns a decayed version of this composition (decayed
73 /// delta timesteps) using the seconds to timestep conversion specified.
75
76 /// Records the composition in output database Compositions table (if
77 /// not done previously).
78 void Record(Context* ctx);
79
80 protected:
81 /// a chain containing compositions that are a result of decay from a common
82 /// ancestor composition. The key is the total amount of time a composition
83 /// has been decayed from its root parent.
84 typedef std::map<int, Composition::Ptr> Chain;
85
86 typedef boost::shared_ptr<Chain> ChainPtr;
87
89
91
92 private:
93 /// This constructor allows the creation of decayed versions of
94 /// compositions while avoiding extra memory allocations.
96
97 /// Performs a decay calculation and creates a new decayed composition.
98 Ptr NewDecay(int delta, uint64_t secs_per_timestep);
99
100 static int next_id_;
101 int id_;
102 bool recorded_;
103 CompMap atom_;
104 CompMap mass_;
105
106 /// the total time delta this composition has been decayed from its root ancestor.
107 int prev_decay_;
108};
109
110} // namespace cyclus
111
112#endif // CYCLUS_SRC_COMPOSITION_H_
a holding class for information related to a TradeExecutor
An immutable object responsible for holding a nuclide composition.
Definition composition.h:38
static Ptr CreateFromMass(CompMap v)
Creates a new composition from v with its components having appropriate mass-based ratios.
const CompMap & mass()
Returns the unnormalized mass composition.
const CompMap & atom()
Returns the unnormalized atom composition.
boost::shared_ptr< Composition > Ptr
Definition composition.h:43
static Ptr CreateFromAtom(CompMap v)
Creates a new composition from v with its components having appropriate atom-based ratios.
void Record(Context *ctx)
Records the composition in output database Compositions table (if not done previously).
std::map< int, Composition::Ptr > Chain
a chain containing compositions that are a result of decay from a common ancestor composition.
Definition composition.h:84
Ptr Decay(int delta)
Returns a decayed version of this composition (decayed delta timesteps) assuming a time step is 1/12 ...
boost::shared_ptr< Chain > ChainPtr
Definition composition.h:86
int id()
Returns a unique id associated with this composition.
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
Handles initialization of a simulation from the output database.
Definition sim_init.h:24
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