SIP350 Update carbon accounting + plant mortality - #360
Merged
Alomir merged 4 commits intoAug 3, 2026
Merged
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] [#350] Update carbon accounting and plant mortality
SIP350 Update carbon accounting + plant mortality
Aug 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts plant mortality event output behavior to respect the ctx.events flag (preventing computed-event writes when event output isn’t enabled), and adds new unit tests to validate plant mortality behavior and key flux calculations (including N resorption flux handling).
Changes:
- Guard
PLANTDEATHcomputed event output behindctx.eventsincheckForMortality(). - Add new unit tests for plant mortality transitions and for wood/leaf/root flux calculations (including accounting delta behavior).
- Extend nitrogen-cycle unit tests with coverage for
updateNResorptionFlux()and register the new test binaries in the modeling test Makefile.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/sipnet/sipnet.c |
Prevents computed plant-death event output when events are disabled (ctx.events == 0). |
tests/sipnet/test_modeling/testPlantMortality.c |
New unit tests covering initPlantSurvivalTracker() and checkForMortality() scenarios (alive/dead/re-emergence, litter/no-litter, N-cycle). |
tests/sipnet/test_modeling/testFluxCalculations.c |
New unit tests for calcWoodAndLeafFluxes() and calcRootFluxes(), including accounting-delta and negative-NPP cases. |
tests/sipnet/test_modeling/testNitrogenCycle.c |
Adds a focused unit test for updateNResorptionFlux() behavior (basic/additive/negative cases). |
tests/sipnet/test_modeling/Makefile |
Adds the new modeling test sources to the build/run list. |
Suppressed comments (3)
tests/sipnet/test_modeling/testPlantMortality.c:243
- These context flags aren’t fully reset after the nitrogen-cycle test (which sets ctx.anaerobic/waterHResp=1), so this test can inherit unrelated context and become order-dependent. Reset the coupled flags here to keep the suite isolated.
int testMortalityReemergence(void) {
int status = 0;
logTest("Running testMortalityReemergence\n");
tests/sipnet/test_modeling/testPlantMortality.c:265
- This test only resets litterPool/nitrogenCycle, but earlier tests enable ctx.anaerobic/waterHResp. That makes the suite order-dependent and can cause surprises if mortality logic later consults those flags. Reset them here to keep tests independent.
int testMortalityWithAccountingDelta(void) {
int status = 0;
tests/sipnet/test_modeling/testFluxCalculations.c:283
- After the negative-NPP root test enables litterPool/anaerobic/waterHResp, this test resets only ctx.nitrogenCycle. Reset the other coupled context flags too so this test remains independent of execution order.
status |= checkFlux(fluxes.leafOffNResorption, 0.024,
"leafOffNResorption (negative NPP roots)");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Alomir
deleted the
copilot/sip350-update-carbon-accounting-plant-mortality
branch
August 3, 2026 16:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NOTE: THIS REPLACES #353
How was this change tested?
New unit tests in
tests/sipnet/test_modeling/:testPlantMortality.c— tests forinitPlantSurvivalTrackerandcheckForMortality(plant stays alive, dies with/without litter pool, dies with nitrogen cycle, dead stays dead, plant re-emerges)testFluxCalculations.c— tests forcalcWoodAndLeafFluxes(positive/negative NPP, leaf deficit case, accounting delta, additivity) andcalcRootFluxes(positive/negative NPP with N resorption, additivity)testNitrogenCycle.c— addedtestUpdateNResorptionFluxfor the newupdateNResorptionFluxhelperAll existing unit and smoke tests continue to pass.
Checklist