Skip to content

SIP147 Retool events as fluxes - #148

Merged
Alomir merged 11 commits into
masterfrom
SIP147-retool-events-as-fluxes
Aug 28, 2025
Merged

SIP147 Retool events as fluxes#148
Alomir merged 11 commits into
masterfrom
SIP147-retool-events-as-fluxes

Conversation

@Alomir

@Alomir Alomir commented Aug 25, 2025

Copy link
Copy Markdown
Collaborator

Fixes #147

This PR:

  • Retools event handling as flux calculations, instead of mixed fluxes/pool updates
  • Moves processEvents() to earlier in updateState() [specifically, before soilDegradation()] to preserve fluxes-then-pools flow; minor updates to soilDegradation() to accommodate.
  • Fixes discovered bug with how evaporated irrigation water was handled (never took climate->length into account)
  • Updates tests for changes; in particular, all events.out have changed with this change to fluxes
  • Adds context check to prevent events and microbes from both being on

Notes:

  • initial retool as fluxes is in the first commit, which shows that sipnet.out has not changed in the smoke tests (events.out has been updated, though, with expected changes). Second commit updates tests (and found some issues, hurray tests!). Second commit has the green check :-)
  • uncovered a bug in that we were NOT handling our one prior flux addition (to fluxes.immedEvap) correctly; test updated to reflect this
  • I have resisted splitting soilDegradation into separate fluxes and pool updates, to keep this PR smaller (and, that code change should not be a functionality change, so best to leave it out)

@Alomir
Alomir marked this pull request as ready for review August 26, 2025 18:23
@Alomir
Alomir requested review from dlebauer and infotroph August 26, 2025 18:32

@dlebauer dlebauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks nice - I like the change to flux-based event handler and the general direction of ordering flux calcs then pool updates! And thanks for catching the bug in how immedEvap was handled.

  • Since I only see changes to the irrig flux, I assume that this PR doesn't actually change the values or implied units written out, it only changes how they are internally calculated. Correct?
  • see two inline comments:
    • check for climLen <=0?
    • change comment from (update pools --> update fluxes).

Comment thread src/sipnet/sipnet.c
trackers.yearlyLitter += fluxes.leafLitter;
}

void resetEventFluxes(void) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

Comment thread src/sipnet/sipnet.c Outdated
Comment thread src/sipnet/sipnet.c
// should.
const int climYear = climate->year;
const int climDay = climate->day;
const double climLen = climate->length;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not really related to this PR, except that this is so often a demoninator: is there or should there be a check that climLen > 0?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, definitely - never assume your data is good!

@Alomir

Alomir commented Aug 28, 2025

Copy link
Copy Markdown
Collaborator Author

Since I only see changes to the irrig flux, I assume that this PR doesn't actually change the values or implied units written out, it only changes how they are internally calculated. Correct?

@dlebauer : I think this IS changing the implied units, from pool amounts (eg g C/m^2) to fluxes (eg g C/m^2/day)

@Alomir
Alomir merged commit 345bd13 into master Aug 28, 2025
9 checks passed
@Alomir
Alomir deleted the SIP147-retool-events-as-fluxes branch August 28, 2025 21:24
@dlebauer

Copy link
Copy Markdown
Member

@Alomir

I think this IS changing the implied units, from pool amounts (eg g C/m^2) to fluxes (eg g C/m^2/day)

What I meant was probably unclear but it was just that when units were previously mass/area, the daily time step implicitly added the /d even if this wasn't explicit. Which is why the outputs don't change.

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.

Retool event handling as fluxes

2 participants