Skip to content

SIP180 Adding N demand, fixation, and uptake#265

Merged
mswilburn merged 15 commits intomasterfrom
SIP180-Add-N-demand-and-fixation
Feb 26, 2026
Merged

SIP180 Adding N demand, fixation, and uptake#265
mswilburn merged 15 commits intomasterfrom
SIP180-Add-N-demand-and-fixation

Conversation

@mswilburn
Copy link
Copy Markdown
Contributor

@mswilburn mswilburn commented Feb 14, 2026

Summary

Changes that calculate plant N demand, N fixation, and N uptake fluxes. minN pool updated, fixation and uptake added as output columns, unit test created, new parameters created, balance tracker updated. These changes are motivated by Issue #180 to continue implementation of N cycle.

How was this change tested?

  • Smoke tests
  • Unit test created in testNitrogenCycle
  • Smoke and unit test output attached as files in comment

Reproduction steps

N/A

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.

Comment thread src/sipnet/sipnet.c Outdated
Comment thread src/sipnet/sipnet.c Outdated
Comment thread src/sipnet/state.h Outdated
Comment thread tests/sipnet/test_modeling/balance.param Outdated
Comment thread tests/sipnet/test_modeling/testNitrogenCycle.c Outdated
Comment thread tests/smoke/russell_2/sipnet.param Outdated
Comment thread src/sipnet/balance.c
@mswilburn
Copy link
Copy Markdown
Contributor Author

mswilburn commented Feb 20, 2026

PR265 Smoke Test Output.txt
PR265 Unit Test Output.txt

Smoke and unit test output. Updated smoke test output file after pulling and merging from master.

Copy link
Copy Markdown
Collaborator

@Alomir Alomir left a comment

Choose a reason for hiding this comment

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

Looks great! One doc comment, otherwise just need to get the PR up to date and make sure everything passes.

Comment thread docs/model-structure.md Outdated

\begin{equation}
F^N_\text{demand}=\frac{dN_\text{plant}}{dt} = \sum_{i} \frac{dN_{\text{plant,}i}}{dt}
F^N_\text{demand} = \sum_{i} \frac{F^C_{\text{creation,}i}}{CN_{\text{i}}}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this might be better doc'd as the "creation demand" (or some such), and separately the "leaf on event demand", and then total demand = sum of those two. Putting leafOnCreation in this equation - esp. without the subtraction term here.

Actually, if you want to dump explaining leaf-on here and create a ticket to do so, that would be fine - esp. given that there's a 'TODO' above to explain leaf-on in the first place up in the Leaf Carbon section. (If you do make a ticket, mention that too.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So separate the equation into creation demand + leaf on event demand, remove the little blurb about leaf on handling, and create a separate issue related to the TODO in leaf carbon?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went ahead and separated the N demand calculation in sipnet.c into leafOnDemand, creationDemand, and totalDemand. I removed the blurb about leaf on calculation and added a TODO note to possibly add a better explanation. I also opened Issue #275 to update documentation for leaf on/leaf off mechanics.

@mswilburn mswilburn marked this pull request as ready for review February 21, 2026 16:08
@mswilburn mswilburn requested a review from Alomir February 21, 2026 16:08
Merging documentation changes into branch
@Alomir Alomir mentioned this pull request Feb 24, 2026
6 tasks
Copy link
Copy Markdown
Collaborator

@Alomir Alomir left a comment

Choose a reason for hiding this comment

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

Looks great! Just need to resolve conflicts, then it is good to go.

Comment thread docs/model-structure.md
Comment on lines +615 to +617
Each term in the sum is calculated according to \eqref{eq:plant_n}. Total plant N demand $F^N_{\text{demand,}total}$ is then partitioned between fixation and soil N uptake using \eqref{eq:n_fix_demand} and \eqref{eq:n_uptake_demand}.

**TODO:** possibly include more context about leaf on events
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good!

Comment thread src/sipnet/sipnet.c
/*!
* Calculate plant N demand
*/
double calcPlantNDemand() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

@mswilburn mswilburn merged commit 454e244 into master Feb 26, 2026
12 checks passed
@mswilburn mswilburn deleted the SIP180-Add-N-demand-and-fixation branch February 26, 2026 13:41
@Alomir Alomir mentioned this pull request Mar 17, 2026
4 tasks
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.

Add N gain from fixation

2 participants