@@ -103,29 +103,34 @@ Material::Ptr Material::ExtractComp(double qty, Composition::Ptr c,
103103}
104104
105105void Material::Absorb (Material::Ptr mat) {
106+
107+ bool tracked = HasContext ();
108+ bool mat_tracked = mat->HasContext ();
106109
107- // Handle absorb-specific decay rules
108- int common_decay_time;
109- if (HasContext () != mat->HasContext ()) {
110+ if (tracked != mat_tracked) {
110111 throw cyclus::Error (" Cannot combine a tracked and untracked material!" );
111- } else if (!HasContext ()) {
112- // both materials are untracked
112+ }
113+
114+ if (!tracked) {
113115 if (mat->prev_decay_time_ > prev_decay_time_) {
114- throw ValueError (" Cannot absorb a material that is more decayed than this one" );
115- } else {
116- common_decay_time = prev_decay_time_;
116+ throw ValueError (
117+ " Cannot absorb a material that is more decayed than this one" );
117118 }
118- } else {
119- // both materials are tracked
120- common_decay_time = ctx_->time ();
121- }
122119
123- mat->Decay (common_decay_time);
124- this ->Decay (common_decay_time);
120+ // Synchronize the incoming material with this material.
121+ mat->Decay (prev_decay_time_);
122+ } else if (ctx_->sim_info ().decay == " lazy" ) {
123+ // NOTE: Absorb will only Decay materials like this if the decay mode is
124+ // set to lazy. If more decay modes are introduced in the future which
125+ // want Absorb to decay, this will need to be changed
126+ int common_decay_time = ctx_->time ();
127+
128+ mat->Decay (common_decay_time);
129+ Decay (common_decay_time);
125130
126- // manually update decay time in case the change was so small
127- // that no decay was invoked
128- this -> prev_decay_time_ = common_decay_time;
131+ // Decay may return early when the change is below its threshold.
132+ prev_decay_time_ = common_decay_time;
133+ }
129134
130135 // these calls force lazy evaluation if in lazy decay mode
131136 Composition::Ptr c0 = comp ();
0 commit comments