Add nitrogen fixation to the soil model#724
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #724 +/- ##
===========================================
+ Coverage 94.70% 94.73% +0.02%
===========================================
Files 73 73
Lines 4946 4974 +28
===========================================
+ Hits 4684 4712 +28
Misses 262 262 ☔ View full report in Codecov by Sentry. |
dalonsoa
left a comment
There was a problem hiding this comment.
No idea about the science, but the code looks sensible. I've just made a couple of comments.
| "leaf_turnover_c_p_ratio", | ||
| "plant_reproductive_tissue_turnover_c_p_ratio", | ||
| "root_turnover_c_p_ratio", | ||
| "nitrogen_fixation_carbon_supply", |
There was a problem hiding this comment.
If this is initially populated by the plants model, it seems more reasonable to make the plants model own this process, I think. You have already mentioned this, so just supporting the idea.
Having said that, and looking at the code, I wonder why this needs to be initialised by the plants instead of the soil model. Is it to avoid an unfeasible model execution order or something like that?
There was a problem hiding this comment.
I guess it needs to be populated by the plants model because this variable represents the amount of carbon plants are prepared to supply to microbes living in the soil to fix nitrogen. At the moment this is just a constant that gets passed from the plants model to the soil model, but down the line it should depend on plant productivity, which means the plant model will need to run before it can be populated.
I think down the line it might make sense for symbiotic nitrogen fixation to be represented within the plants module, because there is a grey area here about whose domain this falls into. But when me and @davidorme discussed it we thought it is best to have it contained in the soil model to begin with
| :cite:t:`brzostek_modeling_2014`. As the function is not defined below zero degrees | ||
| celsius if a negative temperature is input an infinite cost is returned. | ||
|
|
||
| TODO - I could not sensibly convert this empirically derived function from Celsius |
There was a problem hiding this comment.
It's a piecewise function with a cut-off threshold, so the way you have handled it seems totally reasonable specially considering that the input soil_temp is already in Celsius. I don't see any problem with it.
There was a problem hiding this comment.
Yeah I think this TODO more speaks to an anxiety I have about how a lot of the models I am drawing from make use of temperature, rather than anything wrong with the function implementation. I've made a broader issue for this #728, so I think it makes sense to make this a comment rather than a TODO
Description
This PR adds nitrogen fixation to the soil model. There are two distinct types, fixation by free-living microbes and fixation by plant associated microbes. At some point in the future it might make sense for the plant associated fixation to happen within the
plantsmodel, but for now keeping it the soil seems simplest.To get this to work I had to add code to the plants model so @davidorme if you could take a look and check that my changes seem reasonable that would be great.
Again this is a PR with fairly dense scientific content, but any feedback on code style etc would be appreciated.
Fixes #708
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks