20 m->tracker_.Create(creator);
50 ->
AddVal(
"PrevDecayTime", prev_decay_time_)
75 throw ValueError(
"mass extraction causes negative quantity");
95 other->prev_decay_time_ = prev_decay_time_;
97 tracker_.
Extract(&other->tracker_);
119 if (qty_ < mat->qty_) {
120 prev_decay_time_ = mat->prev_decay_time_;
125 tracker_.
Absorb(&mat->tracker_);
139 if (ctx_ != NULL && ctx_->
time() > prev_decay_time_) {
140 prev_decay_time_ = ctx_->
time();
147 }
else if (curr_time < 0 && ctx_ == NULL) {
148 throw ValueError(
"decay cannot use default time with NULL context");
152 curr_time = ctx_->
time();
155 int dt = curr_time - prev_decay_time_;
161 const CompMap c = comp_->atom();
165 bool decay = c.size() > 100;
176 CompMap::const_reverse_iterator it;
177 for (it = c.rbegin(); it != c.rend(); ++it) {
179 double lambda_timesteps =
pyne::decay_const(nuc) *
static_cast<double>(secs_per_timestep);
180 double change = 1.0 - std::exp(-lambda_timesteps * static_cast<double>(dt));
191 prev_decay_time_ = curr_time;
197 double decay_heat = 0.;
200 std::map<int, double> dec_heat = p_map.
decay_heat();
201 for (
auto nuc : dec_heat) {
203 decay_heat += nuc.second;
210 throw Error(
"comp() const is deprecated - use non-const comp() function." 211 " Recompilation should fix the problem.");
226 prev_decay_time_(0) {
228 prev_decay_time_ = ctx->
time();
SimInfo sim_info() const
Return static simulation info.
void Absorb(ResTracker *absorbed)
Should be called when a resource is combined with another.
void Transmute(Composition::Ptr c)
Changes the material's composition to c without changing its mass.
boost::shared_ptr< Composition > Ptr
CompMap Sub(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
A generic mechanism to manually manage exceptions.
void Decay(int curr_time)
Updates the material's composition by performing a decay calculation.
Composition::Ptr comp()
Returns the nuclide composition of this material.
virtual std::string units() const
Returns "kg".
For values that are too big, too small, etc.
boost::shared_ptr< Material > Ptr
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
static const ResourceType kType
Ptr ExtractComp(double qty, Composition::Ptr c, double threshold=eps_rsrc())
Creates a new material by extracting from this one.
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
virtual double quantity() const
Returns the mass of this material in kg.
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...
Ptr ExtractQty(double qty)
Same as ExtractComp with c = this->comp().
Resource defines an abstract interface implemented by types that are offered, requested, and transferred between simulation agents.
uint64_t dt
Duration in seconds of a single time step in the simulation.
virtual int time()
Returns the current simulation timestep.
static Ptr Create(Agent *creator, double quantity, Composition::Ptr c)
Creates a new material resource that is "live" and tracked.
CompMap Add(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result...
const uint64_t kDefaultTimeStepDur
comp_map decay_heat()
Calculates the decay heat of a material based on the composition and each nuclide's mass...
virtual Resource::Ptr ExtractRes(double qty)
Splits the resource and returns the extracted portion as a new resource object.
virtual const ResourceType type() const
Returns Material::kType.
double DecayHeat()
Returns a double with the decay heat of the material in units of W/kg.
struct pyne::decay decay
a struct matching the '/decay/decays' table in nuc_data.h5.
Context * context() const
Returns this agent's simulation context.
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
std::string decay
"manual" if use of the decay function is allowed, "never" otherwise
virtual int qual_id() const
Returns the id of the material's internal nuclide composition.
void Modify()
Should be called when the state of a resource changes (e.g.
Material::Ptr NewBlankMaterial(double quantity)
Creates and returns a new material with the specified quantity and a default, meaningless composition...
void Extract(ResTracker *removed)
Should be called when a resource has some quantity removed from it (e.g.
void Absorb(Ptr mat)
Combines material mat with this one. mat's quantity becomes zero.
Code providing rudimentary logging capability for the Cyclus core.
A simulation context provides access to necessary simulation-global functions and state...
Material(Context *ctx, double quantity, Composition::Ptr c)
boost::shared_ptr< Resource > Ptr
The abstract base class used by all types of agents that live and interact in a simulation.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
virtual void Record(Context *ctx) const
Records the internal nuclide composition of this resource.
The material class is primarily responsible for enabling basic material manipulation while helping en...
virtual Resource::Ptr Clone() const
Creates an untracked copy of this material object.
double decay_const(int nuc)
Returns the decay constant for a nuclide nuc.
void Record()
Record this datum to its Recorder.
Material composed of nuclides.
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
void Normalize(CompMap *v, double val)
The sum of quantities of all nuclides of v is normalized to val.
double eps()
a generic epsilon value
static Ptr CreateFromMass(CompMap v)
Creates a new composition from v with its components having appropriate mass-based ratios...
void ApplyThreshold(CompMap *v, double threshold)
All nuclides with quantities below threshold will have their quantity set to zero.