SIP370 Add guard to check for leach+vol -> negative min N - #375
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a defensive guard in SIPNET’s nitrogen-cycle limitation flow to prevent combined volatilization + leaching from over-drawing the mineral N pool (and cascading into negative growth-reduction factors), with regression tests to cover the edge case.
Changes:
- Add a mineral-N loss guard that scales volatilization/leaching when their combined timestep loss would exceed available mineral N.
- Add unit test coverage for “excess volatilization” and “excess leaching” scenarios.
- Add a release-note entry for the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/sipnet/limitations.c |
Introduces and wires in a guard to bound volatilization + leaching against available mineral N before running the general N limitation logic. |
tests/sipnet/test_modeling/testNitrogenCycle.c |
Adds regression tests validating the guard’s scaling behavior and end-of-step mineral N behavior. |
docs/CHANGELOG.md |
Notes the new guard in the Unreleased changelog. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dlebauer
approved these changes
Aug 19, 2026
6 tasks
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
Details
How was this change tested?
Related issues
Checklist
docs/CHANGELOG.mdupdated with noteworthy changesclang-format(rungit clang-formatif needed)