Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…-Implement-methane-production
Co-authored-by: David LeBauer <dlebauer@gmail.com>
…-Implement-methane-production
There was a problem hiding this comment.
Pull request overview
Implements methane (CH₄) production in the SIPNET model when the anaerobic context/CLI option is enabled, including new parameters, new flux bookkeeping, output reporting, and supporting tests/docs.
Changes:
- Added methane production parameters (
soilMethaneRate,litterMethaneRate) and methane flux calculation, including pool updates and mass-balance accounting. - Populated the
ch4output column and added tracker support for timestep methane production. - Updated model docs and extended/adjusted unit tests and test parameters to cover new anaerobic/methane dependencies.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/sipnet/state.h |
Adds methane parameters, flux fields, and a methane tracker. |
src/sipnet/sipnet.c |
Reads new params, computes methane flux, updates pools/trackers, and outputs CH₄. |
src/sipnet/balance.c |
Incorporates methane into carbon outputs for balance checks. |
docs/model-structure.md |
Documents methane production and adds methane terms to pool ODEs. |
docs/CHANGELOG.md |
Adds an unreleased changelog line for methane production. |
tests/smoke/russell_2/sipnet.param |
Adds methane rates to smoke test parameters. |
tests/sipnet/test_modeling/balance.param |
Adds methane rates (and adjusts other params) for balance regression testing. |
tests/sipnet/test_modeling/testMethane.c |
New unit test for methane flux/pool impacts. |
tests/sipnet/test_modeling/testDependencyFunctions.c |
Updates context setup and adds validation checks around dependency function tests. |
tests/sipnet/test_modeling/testNitrogenCycle.c |
Updates context setup and adds validation checks. |
tests/sipnet/test_modeling/testBalance.c |
Updates context setup, adds a “no litter pool” balance scenario, and minor output handling tweaks. |
tests/sipnet/test_modeling/Makefile |
Adds the new methane test to the modeling test build. |
tests/sipnet/test_sipnet_infrastructure/Makefile |
Cleans up an additional generated artifact. |
tests/sipnet/test_events_types/testEventFertilization.c |
Ensures context flag dependencies are satisfied in the fertilization event test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dlebauer
left a comment
There was a problem hiding this comment.
Yay, this is a huge milestone!
This does not block this PR, but to consider:
Since CH4 flux from non-flooded cropland is 1) rare and 2) very very tiny or negative (we don't represent methane oxidation that consumes CH4 because it is orders of magnitude smaller than typical flooded rice emissions.
For now, I think it will be sufficient to set the new rate parameters default to 0.
We discussed having a flag that would allow methane off when n2o is on. But I don't think that is a great solution. I think having anaerobic on/off makes more sense.
To simulate CH4 from flooded rice, we can change the parameter from the default, and have this associated with the PFT.
Setting these to 0 is an unsatisfying hack, but sufficient for now. It is analogous to linking drainage rate to Rice - practical but not mechanistic. One solution would be to add time dependence to the anaerobic scheme to actually capture the development of the anoxic state. I started a discussion in Slack.
Co-authored-by: David LeBauer <dlebauer@gmail.com>
Co-authored-by: David LeBauer <dlebauer@gmail.com>
Summary
How was this change tested?
List steps taken to test this change, with appropriate outputs if applicable
If changes are needed for any
sipnet.outfiles in thetest/smokesubdirectories, then include output fromtools/smoke_check.pyby running the commands below and pasting the output at the end of this PR. Note thatthis must be run BEFORE submitting changes to any
sipnet.outfiles.Run
python tools/smoke_check.py helpfor more info.Reproduction steps
If appropriate, list steps to reproduce the change locally
Related issues
Checklist
docs/CHANGELOG.mdupdated with noteworthy changesclang-format(rungit clang-formatif 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-formatto format staged changes.