Allow animal consumption of soil pools#917
Conversation
…onsumption on every timestep
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #917 +/- ##
===========================================
+ Coverage 94.00% 94.08% +0.08%
===========================================
Files 78 78
Lines 6067 6172 +105
===========================================
+ Hits 5703 5807 +104
- Misses 364 365 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
TaranRallings
left a comment
There was a problem hiding this comment.
Am I following the logic correctly?
We keep the decay classes, the new one mirrors the litter pool.
I forage from the soil pool objects directly.
The new soil code auto-calculates the loss to animals and feeds that back into your new data variables?
Yep exactly! With the idea being that the foraging code does not touch the soil model variables in the data object at all (the possibility for bugs going that route feels limitless) |
dalonsoa
left a comment
There was a problem hiding this comment.
I've a couple of suggestions here and there, and a few comments, but nothing major. All looks good!
| self.microbial_c_n_p_ratios: dict[str, dict[str, float]] | ||
| """The CNP ratios of the different microbial functional groups.""" |
There was a problem hiding this comment.
I think I ask this every time I see CNP somewhere. Were not a dataclass to handle this specific data structure consistently across the codebase?
There was a problem hiding this comment.
Yeah that could be useful. It would be somewhat tricky as the representation varies between models.
For the microbial groups, the soil model does not track the stoichiometry explicitly it just assumes that each group has a fixed stoichiometry (which is an input parameter). This is basically to keep the amount of pools that the integration has to track lower (there's a huge number anyway).
I guess it probably does make sense to think about a unified approach to this at some point, but I think it probably has to wait until plant stoichiometry is implemented so that we know what all models require the general system to do
| ] | ||
| ) | ||
|
|
||
| pom_consumption_carbon = pom_initial_stock - pom_final_stock |
There was a problem hiding this comment.
Is there any risk of this ever becoming negative? If so, what should happen?
There was a problem hiding this comment.
There shouldn't be any processes in the animal model that can increase the size of the SoilPool pools. These are designed to just track the consumption within one animal model evaluation step, so there shouldn't be any changes from any other models to the pool within the relevant time frame. So, pom_final_stock can only ever be equal to or smaller than pom_initial_stock
There was a problem hiding this comment.
Here we have a collection of subtractions. I guess you are on top of them and it is not possible, but just checking that they cannot lead to negative numbers, ever.
There was a problem hiding this comment.
The changes in pools that are being calculated here can be negative. In terms of preventing the pools from going negative, I haven't been able to think of a reasonable way to stop this from happening. As the animal and soil model run in sequence the total consumption is calculated based on old soil pool sizes and then subtracted from the soil pools at the next simulation step, so if the abundance of the pool suddenly drops the consumption rate won't allowing the pool to potentially go negative.
This happening would be an indication that something is wrong in how animal consumption has been parameterised, but I'm not really sure what makes sense to do in response. Pools that are negative could be replaced with zero values, but I feel like that just masks the problem, as well as breaking stoichiometric conservation (because the animals receive more CNP from the soil than they remove)
Description
This PR adds
SoilPoolobjects which animals can consume from. These follow the basic structure of theLitterPoolswhich are already used for animal consumption of litter. They mainly serve to convert from the quantities used in the soil model into those used by the animal. They also serve to group the pools available for animal consumption into ones that animals could feasibly specialise in eating (i.e. particulate organic matter, bacteria, fungi), rather than allowing them to feed from every single pool as a discrete resource or to feed from nonsensical pools (e.g. soil enzymes)As part of the PR I've had to modify the animal model code, so feedback on whether the changes seem sensible/in keeping with the overall code style would be useful.
Fixes #904
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks