Change mycorrhizal supply calculation to prevent negative populations#1163
Change mycorrhizal supply calculation to prevent negative populations#1163jacobcook1995 merged 7 commits intodevelopfrom
Conversation
…emperature guess and an actual calculation of matric potential
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1163 +/- ##
========================================
Coverage 94.35% 94.36%
========================================
Files 70 70
Lines 7055 7058 +3
========================================
+ Hits 6657 6660 +3
Misses 398 398 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| soil_water_potential = np.full_like( | ||
| self.data["pH"].to_numpy(), | ||
| self.model_constants.soil_microbe_water_potential_optimum, | ||
| # As soil temperature hasn't be calculated yet we assume that it matches the |
There was a problem hiding this comment.
soil temperature is initialised in the abiotic simple model but no values are assigned
# create soil temperature array
self.data["soil_temperature"] = self.layer_structure.from_template()
I think it would make sense to just add the mean annual temperature there. I'm happy for you to do that if that helps here
There was a problem hiding this comment.
Oh yeah that massively simplifies the work flow on my side!
There was a problem hiding this comment.
Actually, scratch that I would need both the soil temperature and the air temperature (for the surface temperature) to be populated. I guess populating the soil temperature with the mean annual temperature is an acceptable initial guess but that doing the same with air temperature wouldn't be?
There was a problem hiding this comment.
yeah that's true. The abiotic model initializes everything but the abiotic_simple doesn't. Ideally they would have the same set of variables initialized and updated...I think for now your solution is good, it might be worth changing the init of the simple model in case that comes up elsewhere, but that can be my TODO.
There was a problem hiding this comment.
Okay, I'll add a TODO to the docstring of abiotic simple model init about this
vgro
left a comment
There was a problem hiding this comment.
Looks sensible to me, I agree that moving the initialization to the abiotic and hydrology model might make it simpler and I'm happy for you to do that. The set of variables that are initialized with values was purely based on my requirements, there is no reason why that shouldn't include more variables.
Let me know when you made the changes and I'll approve the PR
…mperialCollegeLondon/virtual_ecosystem into bugfix/symbiotic_supply_limits
|
I've moved the matric potential calculation into the soil hydrology init, let me know if that all seems reasonable! I kept the soil temperature stuff unchanged as I didn't think populating the air temperature with the mean annual temperature seemed like a sane thing to do (though I agreed that it seemed reasonable for the soil temperature). |
…AbioticSimpleModel._setup docstring
Description
Negative mycorrhizal populations were occurring after the initial time step because the calculation of the maximum amount of nutrient that they can supply to the plant was using guesses for temperature and matric potential. This resulted in mycorrhizal fungi promising far more nutrient than they could provide (even from their existing biomass). I have partially addressed this overpromising by using mean annual temperature as a guess for the soil temperature (which is a fairly common assumption) and by calculating initial values for matric potential based on the initial values for soil moisture.
This partly addresses #835, but does not fully resolve it, as there is still no initial value for soil temperatures, and the initial value of matric potential could be significantly off. This is arguably an issue that won't be completely fixed until we have decided an approach to model spin up.
@vgro, one thing we should decide is whether the calculations make sense in their current location, or are better moved to the hydrology model init? (happy to do the work to move them if so)
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks