Skip to content

SIP350 Update carbon accounting + plant mortality - #359

Open
Alomir wants to merge 16 commits into
masterfrom
SIP350-Redux-Revamp-C-N-Handling
Open

SIP350 Update carbon accounting + plant mortality#359
Alomir wants to merge 16 commits into
masterfrom
SIP350-Redux-Revamp-C-N-Handling

Conversation

@Alomir

@Alomir Alomir commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • What: Revamp handling of the C pseudo-storage pool
  • Motivation: Current handling is broken.

NOTE: THIS REPLACES #353

How was this change tested?

  • Existing unit tests updated
  • New unit tests added to cover new functionality
  • Smoke tests run and updated; diff results below

smoke_check.txt

Related issues

Checklist

  • Related issues are listed above. PRs without an approved, related issue may not get reviewed.
  • PR title has the issue number in it ("[#] <concise description of proposed change>")
  • Tests added/updated for new features (if applicable)
  • Documentation updated (if applicable)
  • docs/CHANGELOG.md updated with noteworthy changes
  • Code formatted with clang-format (run git clang-format if needed)

Note: See CONTRIBUTING.md for additional guidance. This repository uses automated formatting checks; if the pre-commit hook blocks your commit, run git clang-format to format staged changes.

@Alomir Alomir changed the title Initial implementation of C-N revamp plus associated changes SIP350 Update carbon accounting + plant mortality Aug 3, 2026
@Alomir

Alomir commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot please open a PR to update the unit tests in tests/sipnet to cover these changes. Create new similar tests if needed.

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@Alomir I've opened a new pull request, #360, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits August 3, 2026 12:47
* Initial plan

* Add unit tests for carbon accounting and plant mortality changes

* Update for clang-format

* Update context handling

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Mike Longfritz <Mike.Longfritz@gmail.com>
@Alomir
Alomir marked this pull request as ready for review August 3, 2026 16:58
@Alomir
Alomir requested review from dlebauer and mdietze as code owners August 3, 2026 16:58
Copilot AI review requested due to automatic review settings August 3, 2026 16:58
@Alomir
Alomir requested a review from mswilburn as a code owner August 3, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR revamps SIPNET’s carbon “accounting/buffer” handling (renaming plantWoodCStorageDeltaplantCAccountingDelta), adds a plant mortality/reemergence tracker with event output, updates restart/debug-log serialization to include the new tracker and event fields, and refreshes the Python viewer tools plus unit/smoke coverage accordingly.

Changes:

  • Rework biomass C flux calculations to account for negative mean NPP and to use the carbon accounting delta consistently; add plant mortality detection and plantdeath event output.
  • Extend restart/debug logging schemas (survival tracker + expanded event trackers) and update unit tests/new modeling tests.
  • Refactor sipnet-view / sipnet-debug-view tooling (shared arg parser, plot controls, toolbar hover display), plus smoke harness updates (optional debug-log runs).

Reviewed changes

Copilot reviewed 30 out of 34 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tools/sipnet_view.py Adds configurable viewer window title; switches to shared default CLI parser.
tools/sipnet_view_common.py Adds shared CLI parser helper, plot display controls, and custom toolbar hover reporting.
tools/sipnet_debug_view.py Adds configurable window title; uses shared default CLI parser; minor perf copy before sorting/merging.
tests/smoke/russell_3/events.out Updates expected computed event outputs after new accounting/mortality behavior.
tests/smoke/russell_2/events.out Updates expected computed event outputs after new accounting/mortality behavior.
tests/smoke/russell_1/sipnet.config Updates recorded “Final config” timestamp from smoke run.
tests/smoke/russell_1/events.out Updates expected computed event outputs after new accounting/mortality behavior.
tests/smoke/run_smoke.sh Adds optional debug-log generation mode for smoke runs.
tests/sipnet/test_sipnet_infrastructure/testDebugLogFiles.c Updates debug-log header expectations; adds init/cleanup to avoid leaving modified files behind.
tests/sipnet/test_restart_infrastructure/mock_state.c Updates restart schema drift mocking to use renamed accounting field.
tests/sipnet/test_modeling/testPlantMortality.c New unit test suite for mortality + pool transfers (with/without litter and nitrogen).
tests/sipnet/test_modeling/testNitrogenCycle.c Adds focused unit test for the new incremental N resorption flux helper.
tests/sipnet/test_modeling/testFluxCalculations.c New unit tests for wood/leaf/root flux calculation behavior under positive/negative NPP.
tests/sipnet/test_modeling/Makefile Adds new modeling test files to the test build.
tests/sipnet/test_events_types/testEventHarvest.c Updates event test setup to use renamed carbon accounting delta field.
src/sipnet/state.h Renames carbon accounting pool; introduces PlantSurvivalTracker; expands EventTrackers.
src/sipnet/state.c Adds global plantSurvivalTracker and reorders globals.
src/sipnet/sipnet.c Refactors flux calculations; adds plant survival init + mortality checks; updates trackers behavior.
src/sipnet/restart.c Updates restart schema layout + read/write logic to include survival tracker + expanded event trackers.
src/sipnet/nitrogen.h Renames N demand function; adds N resorption helper API; clarifies docs.
src/sipnet/nitrogen.c Implements renamed demand function and new updateNResorptionFlux() helper.
src/sipnet/limitations.c Updates nitrogen limitation logic to use renamed demand function.
src/sipnet/events.h Adds PLANTDEATH event type; expands EventTrackers; fixes typo in comment.
src/sipnet/events.c Adds plantdeath type-string support; tracks harvest fractions; extends event printing.
src/sipnet/depeffects.c Adds missing include needed after header reshuffle.
src/sipnet/debug_log.c Updates debug field lists and outputs to include survival tracker state.
src/sipnet/balance.c Updates carbon accounting pool name and improves warning numeric formatting.
Makefile Adds smokedebug target and debug-log cleanup in cleanall.
docs/CHANGELOG.md Documents new debug viewer, plant mortality event output, and carbon accounting changes.
.github/copilot_instructions.md Adds changelog formatting guidelines for Copilot-generated text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sipnet/sipnet.c
Comment thread tools/sipnet_view_common.py
Comment thread src/sipnet/restart.c
Comment thread src/sipnet/restart.c
Comment thread tests/sipnet/test_sipnet_infrastructure/testDebugLogFiles.c
Comment thread tools/sipnet_debug_view.py
Comment thread src/sipnet/events.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revamp biomass N handling

3 participants