CYCLUS
material.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_MATERIAL_H_
2 #define CYCLUS_SRC_MATERIAL_H_
3 
4 #include <list>
5 #include <boost/shared_ptr.hpp>
6 
7 #include "composition.h"
8 #include "cyc_limits.h"
9 #include "resource.h"
10 #include "res_tracker.h"
11 
12 namespace cyclus {
13 
14 class Context;
15 
16 namespace units {
17 const double kg = 1.0;
18 const double g = kg* .001;
19 const double mg = kg* .000001;
20 const double ug = kg* .000000001;
21 } // namespace units
22 
23 /// The material class is primarily responsible for enabling basic material
24 /// manipulation while helping enforce mass conservation. It also provides the
25 /// ability to easily decay a material up to the current simulation time; it
26 /// does not perform any decay related logic itself.
27 ///
28 /// There are four basic operations that can be performed on materials: create,
29 /// transmute (change material composition - e.g. fission by reactor), absorb
30 /// (combine materials), extract (split a material). All material
31 /// handling/manipulation will be performed using these operations - and all
32 /// operations performed will be tracked and recorded. Usage examples:
33 ///
34 /// * A mining facility that "creates" new material
35 ///
36 /// @code
37 /// Composition::Ptr nat_u = ...
38 /// double qty = 10.0;
39 ///
40 /// Material::Ptr m = Material::Create(qty, nat_u, ctx);
41 /// @endcode
42 ///
43 /// * A conversion facility mixing uranium and flourine:
44 ///
45 /// @code
46 /// Material::Ptr uf6 = uranium_buf.Pop();
47 /// Material::Ptr f = flourine_buf.Pop();
48 ///
49 /// uf6.Absorb(f);
50 /// @endcode
51 ///
52 /// * A reactor transmuting fuel:
53 ///
54 /// @code
55 /// Composition::Ptr burned_comp = ... // fancy code to calculate burned nuclides
56 /// Material::Ptr assembly = core_fuel.Pop();
57 ///
58 /// assembly.Transmute(burned_comp);
59 /// @endcode
60 ///
61 /// * A separations plant extracting stuff from spent fuel:
62 ///
63 /// @code
64 /// Composition::Ptr comp = ... // fancy code to calculate extracted nuclides
65 /// Material::Ptr bucket = spent_fuel.Pop();
66 /// double qty = 3.0;
67 ///
68 /// Material::Ptr mox = bucket.ExtractComp(qty, comp);
69 /// @endcode
70 ///
71 class Material: public Resource {
72  friend class SimInit;
73 
74  public:
75  typedef boost::shared_ptr<Material> Ptr;
76  static const ResourceType kType;
77 
78  virtual ~Material();
79 
80  /// Creates a new material resource that is "live" and tracked. creator is a
81  /// pointer to the agent creating the resource (usually will be the caller's
82  /// "this" pointer). All future output data recorded will be done using the
83  /// creator's context.
84  static Ptr Create(Agent* creator, double quantity, Composition::Ptr c);
85 
86  /// Creates a new material resource that does not actually exist as part of
87  /// the simulation and is untracked.
88  static Ptr CreateUntracked(double quantity, Composition::Ptr c);
89 
90  /// Returns the id of the material's internal nuclide composition.
91  virtual int qual_id() const;
92 
93  /// Returns Material::kType.
94  virtual const ResourceType type() const;
95 
96  /// Creates an untracked copy of this material object.
97  virtual Resource::Ptr Clone() const;
98 
99  /// Records the internal nuclide composition of this resource.
100  virtual void Record(Context* ctx) const;
101 
102  /// Returns "kg"
103  virtual std::string units() const;
104 
105  /// Returns the mass of this material in kg.
106  virtual double quantity() const;
107 
108  virtual Resource::Ptr ExtractRes(double qty);
109 
110  /// Same as ExtractComp with c = this->comp().
111  Ptr ExtractQty(double qty);
112 
113  /// Creates a new material by extracting from this one.
114  ///
115  /// @param qty the mass quantity to extract
116  /// @param c the composition the extracted/returned material
117  /// @param threshold an absolute mass cutoff below which constituent nuclide
118  /// quantities of the remaining unextracted material are set to zero.
119  /// @return a new material with quantity qty and composition c
120  Ptr ExtractComp(double qty, Composition::Ptr c,
121  double threshold = eps_rsrc());
122 
123  /// Combines material mat with this one. mat's quantity becomes zero.
124  void Absorb(Ptr mat);
125 
126  /// Changes the material's composition to c without changing its mass. Use
127  /// this method for things like converting fresh to spent fuel via burning in
128  /// a reactor.
129  void Transmute(Composition::Ptr c);
130 
131  /// Updates the material's composition by performing a decay calculation.
132  /// This is a special case of Transmute where the new composition is
133  /// calculated automatically. The time delta is calculated as the difference
134  /// between curr_time and the last time the material's composition was
135  /// updated with a decay calculation (i.e. prev_decay_time). This may or may
136  /// not result in an updated material composition. Does nothing if the
137  /// simulation decay mode is set to "never" or none of the nuclides' decay
138  /// constants are significant with respect to the time delta.
139  void Decay(int curr_time);
140 
141  /// Returns the last time step on which a decay calculation was performed
142  /// for the material. This is not necessarily synonymous with the last time
143  /// step the material's Decay function was called.
144  int prev_decay_time() { return prev_decay_time_; }
145 
146  /// Returns a double with the decay heat of the material in units of
147  /// W/kg.
148  double DecayHeat();
149 
150  /// Returns the nuclide composition of this material.
151  Composition::Ptr comp();
152 
153  /// DEPRECATED - use non-const comp() function.
154  Composition::Ptr comp() const;
155 
156  protected:
157  Material(Context* ctx, double quantity, Composition::Ptr c);
158 
159  private:
160  Context* ctx_;
161  double qty_;
162  Composition::Ptr comp_;
163  int prev_decay_time_;
164  ResTracker tracker_;
165 };
166 
167 /// Creates and returns a new material with the specified quantity and a
168 /// default, meaningless composition. This is intended only for testing
169 /// purposes.
170 Material::Ptr NewBlankMaterial(double qty);
171 
172 } // namespace cyclus
173 
174 #endif // CYCLUS_SRC_MATERIAL_H_
const double mg
Definition: material.h:19
boost::shared_ptr< Composition > Ptr
Definition: composition.h:43
int prev_decay_time()
Returns the last time step on which a decay calculation was performed for the material.
Definition: material.h:144
boost::shared_ptr< Material > Ptr
Definition: material.h:75
static const ResourceType kType
Definition: material.h:76
std::string ResourceType
Definition: resource.h:12
Tracks and records the state and parent-child relationships of resources as they are changed...
Definition: res_tracker.h:22
Resource defines an abstract interface implemented by types that are offered, requested, and transferred between simulation agents.
Definition: resource.h:19
double eps_rsrc()
an epsilon value to be used by resources
Definition: cyc_limits.h:19
const double g
Definition: material.h:18
const double kg
Definition: material.h:17
const double ug
Definition: material.h:20
Material::Ptr NewBlankMaterial(double quantity)
Creates and returns a new material with the specified quantity and a default, meaningless composition...
Definition: material.cc:232
A simulation context provides access to necessary simulation-global functions and state...
Definition: context.h:128
boost::shared_ptr< Resource > Ptr
Definition: resource.h:24
The abstract base class used by all types of agents that live and interact in a simulation.
Definition: agent.h:51
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
The material class is primarily responsible for enabling basic material manipulation while helping en...
Definition: material.h:71
Handles initialization of a simulation from the output database.
Definition: sim_init.h:24