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

Add soil enzymes to model #341

Merged
merged 36 commits into from
Dec 5, 2023
Merged

Add soil enzymes to model #341

merged 36 commits into from
Dec 5, 2023

Conversation

jacobcook1995
Copy link
Collaborator

Description

This pull request changes the soil carbon model to make it an enzyme explicit model, i.e. one where carbon flows are controlled by enzymes pools which are included in the model. This is unfortunately quite a large pull request, as I couldn't find a sensible place to stop midway.

The largest structural change I've made is moving the calculations of environmental factors impact on biogeochemical rates into a separate submodule. I did this as soil.carbon felt like it was becoming too large.

I've also started to make use of core constants as well as model constants. So feedback on how I've done this would be useful.

Generally looking for feedback on the structure, but if @vgro is able to check that the leaching function I've added is sensible that would be great.

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

placeholder: float = 123.4
"""A placeholder configurable constant."""
depth_of_active_soil_layer: float = 0.25
"""Depth of the biogeochemically active soil layer [m].
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on previous discussions, we set the top soil layer to 50cm. Would it be worth changing that to get a better representation of the active zone?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also wonder if that is actually a core constant? It is very soil microbe specific

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason this is in core constants is because both the soil and litter models use it, but agree that it is confusing when the abiotic model also defined a soil layer height

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've changed the default 1st soil layer height to -0.25m. I also made this issue to record our discussion, #348

Copy link
Collaborator

Choose a reason for hiding this comment

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

The depth of the soil layers is defined in the core schemer and initialized by the plant model. We could add the 0.25m as an additional layer or replace it; for the abiotic model it does not matter what the values are.

Copy link
Collaborator

@vgro vgro left a comment

Choose a reason for hiding this comment

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

This looks overall good to me, I didn't look into the details of the tests.

We need to sit down and talk about the vertical flow units and definition to make sure we are on the same page. Other points to agree on are the temperature conversion (brings us back to the constants conversation and scipy) and the soil water retention curve parameter (which we both use).

Copy link
Collaborator

@davidorme davidorme left a comment

Choose a reason for hiding this comment

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

Nothing to add really to the existing comments

@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (49e159c) 95.71% compared to head (891abbe) 95.91%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #341      +/-   ##
===========================================
+ Coverage    95.71%   95.91%   +0.20%     
===========================================
  Files           51       52       +1     
  Lines         2541     2596      +55     
===========================================
+ Hits          2432     2490      +58     
+ Misses         109      106       -3     

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

Copy link
Collaborator

@alexdewar alexdewar left a comment

Choose a reason for hiding this comment

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

I've made a few minor comments, but otherwise LGTM.

@jacobcook1995
Copy link
Collaborator Author

Thanks for all the feedback, I made a few changes in response to it, but mainly I made a lot of issues as a lot of the problems raised didn't make sense to tackle in this PR. The new issues are as follows: #342, #344, #345, #346, #347, #348

Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

It looks good! And it makes total sense to open issues in response to comments when not directly relevant for this PR. You just need to not forget tackling them at some point!

pH=dummy_carbon_data["pH"],
bulk_density=dummy_carbon_data["bulk_density"],
soil_moisture=np.array([0.5, 0.7, 0.6, 0.2]),
soil_moisture=dummy_carbon_data["soil_moisture"][
top_soil_layer_index
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought you had replaced all soil_moisture with matric_potential, should we keep the soil moisture in for now? See #345

Copy link
Collaborator

@vgro vgro left a comment

Choose a reason for hiding this comment

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

This looks good to me, a few minor comments

@jacobcook1995 jacobcook1995 merged commit 235815d into develop Dec 5, 2023
@jacobcook1995 jacobcook1995 deleted the feature/add_enzymes branch December 5, 2023 14:16
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.

6 participants