diff --git a/.github/workflows/changelog_test.yml b/.github/workflows/changelog_test.yml index 07225b5ca5..67a149f425 100644 --- a/.github/workflows/changelog_test.yml +++ b/.github/workflows/changelog_test.yml @@ -11,18 +11,11 @@ env: jobs: changelog_update: runs-on: ubuntu-latest - container: - image: alpine:3.14 name: Is Changelog up-to-date ? steps: - - name: Install latest git - run: | - apk add --no-cache bash git openssh - git --version - - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v7 - run: | git config --global --add safe.directory ${GITHUB_WORKSPACE} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 124576d127..163eaeb13b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -39,6 +39,7 @@ Since last release * Users can specify for random seed to be created for random number generation (#1950) **Changed:** +* Absorb back to respect manual decay mode and the logic of the decay conditional (#1918) * Modified cycpp.py to fix a few whitespace-related bugs, and allow cyclus vars to be initialized (#1954) * Changed the epsilon (eps) in Material::Decay to 1e-4 allowing 1 day decay of tritium (#1946) * Changed the schema for recipes to require oneOrMore instead of zeroOrMore (#1940) diff --git a/src/material.cc b/src/material.cc index 0670266fc5..fcb9358ebe 100644 --- a/src/material.cc +++ b/src/material.cc @@ -103,29 +103,34 @@ Material::Ptr Material::ExtractComp(double qty, Composition::Ptr c, } void Material::Absorb(Material::Ptr mat) { + + bool tracked = HasContext(); + bool mat_tracked = mat->HasContext(); - // Handle absorb-specific decay rules - int common_decay_time; - if (HasContext() != mat->HasContext()) { + if (tracked != mat_tracked) { throw cyclus::Error("Cannot combine a tracked and untracked material!"); - } else if (!HasContext()) { - // both materials are untracked + } + + if (!tracked) { if (mat->prev_decay_time_ > prev_decay_time_) { - throw ValueError("Cannot absorb a material that is more decayed than this one"); - } else { - common_decay_time = prev_decay_time_; + throw ValueError( + "Cannot absorb a material that is more decayed than this one"); } - } else { - // both materials are tracked - common_decay_time = ctx_->time(); - } - mat->Decay(common_decay_time); - this->Decay(common_decay_time); + // Synchronize the incoming material with this material. + mat->Decay(prev_decay_time_); + } else if (ctx_->sim_info().decay == "lazy") { + // NOTE: Absorb will only Decay materials like this if the decay mode is + // set to lazy. If more decay modes are introduced in the future which + // want Absorb to decay, this will need to be changed + int common_decay_time = ctx_->time(); + + mat->Decay(common_decay_time); + Decay(common_decay_time); - // manually update decay time in case the change was so small - // that no decay was invoked - this->prev_decay_time_ = common_decay_time; + // Decay may return early when the change is below its threshold. + prev_decay_time_ = common_decay_time; + } // these calls force lazy evaluation if in lazy decay mode Composition::Ptr c0 = comp(); diff --git a/tests/material_tests.cc b/tests/material_tests.cc index 48442fa58b..e7cd5aefa8 100644 --- a/tests/material_tests.cc +++ b/tests/material_tests.cc @@ -454,6 +454,12 @@ TEST_F(MaterialTest, TransmutePrevDecay) { TEST_F(MaterialTest, AbsorbPrevDecay) { FakeContext* fake_ctx = new FakeContext(&ti, &rec); + + // FakeContexts get generated with "manual" decay by default, + // so we need to set it to lazy to get Absorb to decay. + SimInfo lazy_si(100, 2015, 1, "", "lazy"); + fake_ctx->InitSim(lazy_si); + TestFacility* fake_fac = new TestFacility(fake_ctx); double untracked_qty = 1.0;