Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leaf biophysics refactor and functional unit tests #1262

Open
wants to merge 68 commits into
base: main
Choose a base branch
from

Conversation

rgknox
Copy link
Contributor

@rgknox rgknox commented Oct 14, 2024

Description:

Leaf biophysics (photosynthesis, stomatal conductance and leaf respiration) has been refactored. Major objectives in this refactor were to 1) extract relevant routines that occur at the leaf-scale and place them in their own module that does not use the fates scaling data structures (cohort, patch and site agnostic) and 2) to have functional unit tests that exercise each of these functions.

These methods do not yet use features in our other brand of unit tests (but could!), particularly the use of cmake and parameter reading.

Design Notes

Notes on Bisection and finding bounding (starter) values

Notes on re-deriving the Medlyn solve with a boundary layer

Colab Notebook that runs the unit test: link

Fixes: #1222
Addresses: #719 (which is now a discussion)

Collaborators:

@adrifoster @ckoven

Expectation of Answer Changes:

There may be subtle differences in our standard integration tests. I do not expect the same results within round-off, but the diffs should be looked through to see if anything is very large.

Checklist

If this is your first time contributing, please read the CONTRIBUTING document.

All checklist items must be checked to enable merging this pull request:

Contributor

  • The in-code documentation has been updated with descriptive comments
  • The documentation has been assessed to determine if updates are necessary

Integrator

  • FATES PASS/FAIL regression tests were run
  • Evaluation of test results for answer changes was performed and results provided

Documentation

Test Results:

TBD

CTSM (or) E3SM (specify which) test hash-tag:

CTSM (or) E3SM (specify which) baseline hash-tag:

FATES baseline hash-tag:

Test Output:

@rgknox rgknox added the status: Not Ready The author is signaling that this PR is a work in progress and not ready for integration. label Oct 14, 2024
@rgknox rgknox force-pushed the leaf_funcunit_tests branch from de09c8e to c7af3ef Compare October 22, 2024 01:48
@rgknox
Copy link
Contributor Author

rgknox commented Nov 4, 2024

Full model regression testing is now showing nigh-indistinguishable results with base:

Test description: BCI, inventory initialization, ST3, 5 years, 2-stream rad, 1 tropical evergreen PFT, parameter defaults otherwise:

https://drive.google.com/file/d/1HJadTpwo_MAdL5Sr8qWK4EFV98WPTlXy/view?usp=sharing

Removing draft status

Next steps:

  1. evaluate gridded comparison while still retaining code that ensures near-b4b?
  2. incrementally remove b4b preservation code and evaluate differences
  3. clean up comments
  4. evaluate timing differences (particularly related to ci precision)
  5. introduce updates to btran (ie remove from stomatal intercept and add to Jmax)?

@rgknox rgknox removed the status: Not Ready The author is signaling that this PR is a work in progress and not ready for integration. label Nov 4, 2024
Copy link
Contributor

@mpaiao mpaiao left a comment

Choose a reason for hiding this comment

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

Sorry for not reviewing this earlier! I think the refactoring looks great and helps a lot to understand the photosynthesis code, thanks!

I just have some minor questions and suggestions.

@rgknox rgknox added the inputs: parameter file Pertaining to changes to the FATES parameter file label Jan 17, 2025
Copy link
Contributor

@glemieux glemieux left a comment

Choose a reason for hiding this comment

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

I really like the work you did to continue modularizing the code. I have a couple of questions and identified a couple of commented out pieces of code.

Comment on lines 1075 to 1082
!if(maxval(psn_z(:,1,1))>nearzero)then
! currentCohort => currentPatch%tallest
! do while (associated(currentCohort)) ! Cohort loop
! print*,currentCohort%gpp_tstep,currentCohort%pft,currentCohort%canopy_layer
! currentCohort => currentCohort%shorter
! enddo
! stop
!end if
Copy link
Contributor

Choose a reason for hiding this comment

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

Code for future work, or temporary code to be removed?

@glemieux glemieux mentioned this pull request Feb 17, 2025
4 tasks
Refactors and cleans up the patch numbering and nocomp checks
glemieux added a commit to glemieux/fates that referenced this pull request Feb 18, 2025
PR NGEET#1262 will be incorporated at a later date, but we are adding
the parameters to the default here to coincide with a minor API update.
glemieux added a commit to glemieux/fates that referenced this pull request Feb 18, 2025
PR NGEET#1262 will be incorporated at a later date, but we are adding
the parameters to the default here to coincide with a minor API update.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inputs: parameter file Pertaining to changes to the FATES parameter file type: refactor Restructures code without changing functionality type: testing Related to improvements in code testing (e.g. unit, regression, etc)
Projects
Status: Final Testing
Development

Successfully merging this pull request may close these issues.

leaf photosynthesis does not check for leaf area/stems and day/night correctly
3 participants