50 ->
AddVal(
"PrevDecayTime", prev_decay_time_)
65 return boost::static_pointer_cast<Resource>(
ExtractQty(qty));
75 throw ValueError(
"mass extraction causes negative quantity");
94 other->prev_decay_time_ = prev_decay_time_;
119 prev_decay_time_ =
mat->prev_decay_time_;
138 if (ctx_ !=
NULL && ctx_->
time() > prev_decay_time_) {
139 prev_decay_time_ = ctx_->
time();
145 throw ValueError(
"Attempted to extract more quantity than exists.");
153 other->prev_decay_time_ = prev_decay_time_;
157 other->tracker_.Package(&tracker_);
161 return boost::static_pointer_cast<Resource>(
other);
176 double min =
p->fill_min();
177 double max =
p->fill_max();
178 if (qty_ >=
min && qty_ <= max) {
181 throw ValueError(
"Material quantity is outside of package fill limits.");
190 throw ValueError(
"decay cannot use default time with NULL context");
207 bool decay =
c.size() > 100;
218 CompMap::const_reverse_iterator
it;
219 for (
it =
c.rbegin();
it !=
c.rend(); ++
it) {
239 double decay_heat = 0.;
244 if (!std::isnan(nuc.second)) {
245 decay_heat += nuc.second;
252 throw Error(
"comp() const is deprecated - use non-const comp() function."
253 " Recompilation should fix the problem.");
269 package_name_(package_name) {
271 prev_decay_time_ = ctx->
time();
283 return package_name_;
The abstract base class used by all types of agents that live and interact in a simulation.
static Ptr CreateFromMass(CompMap v)
Creates a new composition from v with its components having appropriate mass-based ratios.
boost::shared_ptr< Composition > Ptr
A simulation context provides access to necessary simulation-global functions and state.
Datum * NewDatum(std::string title)
See Recorder::NewDatum documentation.
SimInfo sim_info() const
Return static simulation info.
Package::Ptr GetPackage(std::string name)
Retrieve a registered package.
virtual int time()
Returns the current simulation timestep.
Datum * AddVal(const char *field, boost::spirit::hold_any val, std::vector< int > *shape=NULL)
Add an arbitrary field-value pair to the datum.
void Record()
Record this datum to its Recorder.
A generic mechanism to manually manage exceptions.
The material class is primarily responsible for enabling basic material manipulation while helping en...
virtual std::string package_name()
Returns the package id.
virtual Resource::Ptr Clone() const
Creates an untracked copy of this material object.
virtual void Decay(int curr_time=-1)
Updates the material's composition by performing a decay calculation.
Material(Context *ctx, double quantity, Composition::Ptr c, std::string package_name=Package::unpackaged_name())
Ptr ExtractQty(double qty)
Same as ExtractComp with c = this->comp().
static const ResourceType kType
double DecayHeat()
Returns a double with the decay heat of the material in units of W/kg.
virtual void Record(Context *ctx) const
Records the internal nuclide composition of this resource.
virtual Resource::Ptr ExtractRes(double qty)
Splits the resource and returns the extracted portion as a new resource object.
Composition::Ptr comp()
Returns the nuclide composition of this material.
virtual int qual_id() const
Returns the id of the material's internal nuclide composition.
virtual std::string units() const
Returns "kg".
virtual void ChangePackage(std::string new_package_name=Package::unpackaged_name())
Changes the package id.
void Transmute(Composition::Ptr c)
Changes the material's composition to c without changing its mass.
virtual double quantity() const
Returns the mass of this material in kg.
virtual Resource::Ptr PackageExtract(double qty, std::string new_package_name=Package::unpackaged_name())
boost::shared_ptr< Material > Ptr
virtual void Absorb(Ptr mat)
Combines material mat with this one. mat's quantity becomes zero.
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.
Ptr ExtractComp(double qty, Composition::Ptr c, double threshold=eps_rsrc())
Creates a new material by extracting from this one.
virtual const ResourceType type() const
Returns Material::kType.
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...
boost::shared_ptr< Package > Ptr
static std::string unpackaged_name()
void Modify()
Should be called when the state of a resource changes (e.g.
void Extract(ResTracker *removed)
Should be called when a resource has some quantity removed from it (e.g.
void Package(ResTracker *parent=NULL)
Should be called when a resource's package gets modified.
void Absorb(ResTracker *absorbed)
Should be called when a resource is combined with another.
void DontTrack()
Prevent a resource's heritage from being tracked and recorded.
const int state_id() const
Returns the unique id corresponding to this resource and its current state.
boost::shared_ptr< Resource > Ptr
uint64_t dt
Duration in seconds of a single time step in the simulation.
std::string decay
"manual" if use of the decay function is allowed, "never" otherwise
For values that are too big, too small, etc.
Material composed of nuclides.
const uint64_t kDefaultTimeStepDur
Code providing rudimentary logging capability for the Cyclus core.
CompMap Sub(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result.
void ApplyThreshold(CompMap *v, double threshold)
All nuclides with quantities below threshold will have their quantity set to zero.
CompMap Add(const CompMap &v1, const CompMap &v2)
Does component-wise subtraction of the nuclide quantities of v1 and v2 and returns the result.
void Normalize(CompMap *v, double val)
The sum of quantities of all nuclides of v is normalized to val.
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....
double eps_rsrc()
an epsilon value to be used by resources
std::map< Nuc, double > CompMap
a raw definition of nuclides and corresponding (dimensionless quantities).
double eps()
a generic epsilon value
T OptionalQuery(InfileTree *tree, std::string query, T default_val)
a query method for optional parameters
Material::Ptr NewBlankMaterial(double quantity)
Creates and returns a new material with the specified quantity and a default, meaningless composition...
double decay_const(int nuc)
Returns the decay constant for a nuclide nuc.