CYCLUS
Loading...
Searching...
No Matches
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
12namespace cyclus {
13
14class Context;
15
16namespace units {
17const double kg = 1.0;
18const double g = kg* .001;
19const double mg = kg* .000001;
20const 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///
71class 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.
86
87 /// Creates a new material resource that does not actually exist as part of
88 /// the simulation and is untracked.
90
91 /// Returns the id of the material's internal nuclide composition.
92 virtual int qual_id() const;
93
94 /// Returns Material::kType.
95 virtual const ResourceType type() const;
96
97 /// Creates an untracked copy of this material object.
98 virtual Resource::Ptr Clone() const;
99
100 /// Records the internal nuclide composition of this resource.
101 virtual void Record(Context* ctx) const;
102
103 /// Returns "kg"
104 virtual std::string units() const;
105
106 /// Returns the mass of this material in kg.
107 virtual double quantity() const;
108
109 virtual Resource::Ptr ExtractRes(double qty);
110
111 /// Same as ExtractComp with c = this->comp().
112 Ptr ExtractQty(double qty);
113
114 /// Creates a new material by extracting from this one.
115 ///
116 /// @param qty the mass quantity to extract
117 /// @param c the composition the extracted/returned material
118 /// @param threshold an absolute mass cutoff below which constituent nuclide
119 /// quantities of the remaining unextracted material are set to zero.
120 /// @return a new material with quantity qty and composition c
121 Ptr ExtractComp(double qty, Composition::Ptr c,
122 double threshold = eps_rsrc());
123
124 /// Combines material mat with this one. mat's quantity becomes zero.
125 virtual void Absorb(Ptr mat);
126
127 /// Changes the material's composition to c without changing its mass. Use
128 /// this method for things like converting fresh to spent fuel via burning in
129 /// a reactor.
131
132 /// Updates the material's composition by performing a decay calculation.
133 /// This is a special case of Transmute where the new composition is
134 /// calculated automatically. The time delta is calculated as the difference
135 /// between curr_time and the last time the material's composition was
136 /// updated with a decay calculation (i.e. prev_decay_time). This may or may
137 /// not result in an updated material composition. Does nothing if the
138 /// simulation decay mode is set to "never" or none of the nuclides' decay
139 /// constants are significant with respect to the time delta.
140 /// @param curr_time current time to use for the decay calculation
141 /// (default: -1 forces the decay to the context's current time)
142 virtual void Decay(int curr_time = -1);
143
144 /// Returns the last time step on which a decay calculation was performed
145 /// for the material. This is not necessarily synonymous with the last time
146 /// step the material's Decay function was called.
147 int prev_decay_time() { return prev_decay_time_; }
148
149 /// Returns a double with the decay heat of the material in units of
150 /// W/kg.
151 double DecayHeat();
152
153 /// Returns the nuclide composition of this material.
155
156 /// DEPRECATED - use non-const comp() function.
157 Composition::Ptr comp() const;
158
159 virtual std::string package_name();
160
161 virtual Resource::Ptr PackageExtract(double qty,
163
164 /// Changes the package id. Checks that the resource fits the package
165 /// type minimum and maximum mass criteria.
166 virtual void ChangePackage(std::string new_package_name = Package::unpackaged_name());
167
168 protected:
170 std::string package_name = Package::unpackaged_name());
171
172 private:
173 Context* ctx_;
174 double qty_;
175 Composition::Ptr comp_;
176 int prev_decay_time_;
177 ResTracker tracker_;
178 std::string package_name_;
179};
180
181/// Creates and returns a new material with the specified quantity and a
182/// default, meaningless composition. This is intended only for testing
183/// purposes.
185
186} // namespace cyclus
187
188#endif // CYCLUS_SRC_MATERIAL_H_
a holding class for information related to a TradeExecutor
The abstract base class used by all types of agents that live and interact in a simulation.
Definition agent.h:49
boost::shared_ptr< Composition > Ptr
Definition composition.h:43
A simulation context provides access to necessary simulation-global functions and state.
Definition context.h:145
The material class is primarily responsible for enabling basic material manipulation while helping en...
Definition material.h:71
virtual std::string package_name()
Returns the package id.
Definition material.cc:282
virtual Resource::Ptr Clone() const
Creates an untracked copy of this material object.
Definition material.cc:38
virtual void Decay(int curr_time=-1)
Updates the material's composition by performing a decay calculation.
Definition material.cc:186
Material(Context *ctx, double quantity, Composition::Ptr c, std::string package_name=Package::unpackaged_name())
Definition material.cc:263
Ptr ExtractQty(double qty)
Same as ExtractComp with c = this->comp().
Definition material.cc:68
static const ResourceType kType
Definition material.h:76
double DecayHeat()
Returns a double with the decay heat of the material in units of W/kg.
Definition material.cc:238
virtual void Record(Context *ctx) const
Records the internal nuclide composition of this resource.
Definition material.cc:45
virtual Resource::Ptr ExtractRes(double qty)
Splits the resource and returns the extracted portion as a new resource object.
Definition material.cc:64
Composition::Ptr comp()
Returns the nuclide composition of this material.
Definition material.cc:256
virtual int qual_id() const
Returns the id of the material's internal nuclide composition.
Definition material.cc:30
int prev_decay_time()
Returns the last time step on which a decay calculation was performed for the material.
Definition material.h:147
virtual std::string units() const
Returns "kg".
Definition material.cc:56
virtual void ChangePackage(std::string new_package_name=Package::unpackaged_name())
Changes the package id.
Definition material.cc:164
void Transmute(Composition::Ptr c)
Changes the material's composition to c without changing its mass.
Definition material.cc:127
virtual double quantity() const
Returns the mass of this material in kg.
Definition material.cc:60
virtual Resource::Ptr PackageExtract(double qty, std::string new_package_name=Package::unpackaged_name())
Definition material.cc:143
boost::shared_ptr< Material > Ptr
Definition material.h:75
virtual ~Material()
Definition material.cc:15
virtual void Absorb(Ptr mat)
Combines material mat with this one. mat's quantity becomes zero.
Definition material.cc:101
static Ptr Create(Agent *creator, double quantity, Composition::Ptr c, std::string package_name=Package::unpackaged_name())
Creates a new material resource that is "live" and tracked.
Definition material.cc:17
Ptr ExtractComp(double qty, Composition::Ptr c, double threshold=eps_rsrc())
Creates a new material by extracting from this one.
Definition material.cc:72
virtual const ResourceType type() const
Returns Material::kType.
Definition material.cc:34
static Ptr CreateUntracked(double quantity, Composition::Ptr c)
Creates a new material resource that does not actually exist as part of the simulation and is untrack...
Definition material.cc:24
static std::string unpackaged_name()
Definition package.h:68
Tracks and records the state and parent-child relationships of resources as they are changed.
Definition res_tracker.h:21
Resource defines an abstract interface implemented by types that are offered, requested,...
Definition resource.h:22
boost::shared_ptr< Resource > Ptr
Definition resource.h:27
Handles initialization of a simulation from the output database.
Definition sim_init.h:24
const double g
Definition material.h:18
const double ug
Definition material.h:20
const double kg
Definition material.h:17
const double mg
Definition material.h:19
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
Definition agent.cc:14
double eps_rsrc()
an epsilon value to be used by resources
Definition cyc_limits.h:19
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
std::string ResourceType
Definition resource.h:17
Material::Ptr NewBlankMaterial(double quantity)
Creates and returns a new material with the specified quantity and a default, meaningless composition...
Definition material.cc:277