Skip to content

Fixing incorrect plant growth#962

Merged
davidorme merged 6 commits intodevelopfrom
961-incorrect-plant-growth
Jul 24, 2025
Merged

Fixing incorrect plant growth#962
davidorme merged 6 commits intodevelopfrom
961-incorrect-plant-growth

Conversation

@davidorme
Copy link
Copy Markdown
Collaborator

@davidorme davidorme commented Jul 21, 2025

Description

This PR contains fixes for incorrect plant growth calculations. The culprits are:

  1. The PlantsModel._setup updated the turnover traits for the time step of the model, but did so in the wrong direction. The trait values are expressed in the models as reciprocals, and so $\tau_r = \tau_r / 12$ increases the speed of turnover in the model by a factor of $12^2 = 144$ compared to the correct $\tau_r = \tau_r \times 12$.

  2. The PlantsMode._setup was not updating respiration rates for the time step of the model at all - so the full annual respiration costs were being removed at each time step. These rates are straightforward factors depending on masses, so are simply divided by the number of time steps.

  3. The subcanopy vegetation biomass (should be kg C) was being updated with µg C values, so implausibly then contained 10 million tons of carbon per m2. That pushed the equations in the abiotic_simple so far outside bounds that canopy temperature plummeted to -20°C and the plants then all slowly shrank to death.

There are likely to be more issues, but hopefully this gets the model into territory where we can calibrate it.

I had to update the test values in one of the stochiometry tests - I'm assuming these are code-derived values from the previous aberrant behaviour.

Fixes #961

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@davidorme davidorme linked an issue Jul 21, 2025 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.21%. Comparing base (4278c74) to head (6cd7348).
⚠️ Report is 1502 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #962      +/-   ##
===========================================
- Coverage    94.27%   94.21%   -0.06%     
===========================================
  Files           79       79              
  Lines         6513     6518       +5     
===========================================
+ Hits          6140     6141       +1     
- Misses         373      377       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@davidorme davidorme marked this pull request as ready for review July 22, 2025 11:26
@davidorme davidorme requested a review from sallymatson July 22, 2025 11:45
Copy link
Copy Markdown
Collaborator

@sallymatson sallymatson left a comment

Choose a reason for hiding this comment

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

LGTM

@davidorme davidorme enabled auto-merge July 24, 2025 09:22
@davidorme davidorme merged commit ed350be into develop Jul 24, 2025
16 checks passed
@davidorme davidorme deleted the 961-incorrect-plant-growth branch January 9, 2026 14:27
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.

Incorrect calculations in estimating plant growth.

3 participants