Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/models/plants/test_plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ def test_PlantsModel_allocate_gpp(fxt_plants_model, fixture_core_components):
# Ensure that leaf and root turnover exist and are > 0
assert fxt_plants_model.data["leaf_turnover"][cell_id] > 0
assert fxt_plants_model.data["root_turnover"][cell_id] > 0
assert fxt_plants_model.data["plant_reproductive_tissue_turnover"][cell_id] > 0
assert fxt_plants_model.data["propagule_c_mass"][cell_id] > 0
assert fxt_plants_model.data["non_propagule_c_mass"][cell_id] > 0
assert fxt_plants_model.data["root_carbohydrate_exudation"][cell_id] > 0
assert fxt_plants_model.data["plant_symbiote_carbon_supply"][cell_id] > 0


def test_PlantsModel_update(
Expand Down Expand Up @@ -228,9 +233,6 @@ def test_PlantsModel_calculate_turnover(fxt_plants_model, fixture_config):
consts = fxt_plants_model.model_constants

# Check that all expected variables are generated and have the correct value
assert np.allclose(
fxt_plants_model.data["plant_reproductive_tissue_turnover"], 0.003
)
assert np.allclose(fxt_plants_model.data["stem_lignin"], consts.stem_lignin)
assert np.allclose(
fxt_plants_model.data["senesced_leaf_lignin"], consts.senesced_leaf_lignin
Expand Down
6 changes: 6 additions & 0 deletions virtual_ecosystem/models/plants/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,9 @@ class PlantsConsts(ConstantsDataclass):

root_turnover_c_p_ratio: float = 656.7
"""Carbon to Phosphorous ratio of root turnover."""

root_exudates: float = 0.5
"""Fraction of GPP topslice allocated to root exudates."""

propagules_mass: float = 0.5
"""Fraction of reprodutive tissue allocated to propagules."""
50 changes: 40 additions & 10 deletions virtual_ecosystem/models/plants/plants_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,17 @@ def allocate_gpp(self) -> None:
# Reset turnover to 0 as turnover from previous steps should have been allocated
self.data["leaf_turnover"] = xr.full_like(self.data["elevation"], 0)
self.data["root_turnover"] = xr.full_like(self.data["elevation"], 0)
self.data["plant_reproductive_tissue_turnover"] = xr.full_like(
self.data["elevation"], 0
)
self.data["propagule_c_mass"] = xr.full_like(self.data["elevation"], 0)
self.data["non_propagule_c_mass"] = xr.full_like(self.data["elevation"], 0)
self.data["root_carbohydrate_exudation"] = xr.full_like(
self.data["elevation"], 0
)
self.data["plant_symbiote_carbon_supply"] = xr.full_like(
self.data["elevation"], 0
)

# Loop over each grid cell
for cell_id in self.communities.keys():
Expand All @@ -622,12 +633,38 @@ def allocate_gpp(self) -> None:
# TODO: dimension mismatch (1d vs 2d array) - check in pyrealm
cohorts.dbh_values = cohorts.dbh_values + cohort_allocation.delta_dbh

# Calculate total turnover from all cohorts in a grid cell
# Sum of turnover from all cohorts in a grid cell
# TODO: Pyrealm provides annual turnover values. Divide by 12 to get monthly
# turnover values is naive and will overestimate turnover. This should
# be updated eventually to a more sophisticated approach.
self.data["leaf_turnover"][cell_id] = np.sum(
cohort_allocation.foliage_turnover
cohort_allocation.foliage_turnover / 12
)
self.data["root_turnover"][cell_id] = np.sum(
cohort_allocation.fine_root_turnover
cohort_allocation.fine_root_turnover / 12
)
self.data["plant_reproductive_tissue_turnover"][cell_id] = np.sum(
cohort_allocation.reproductive_tissue_turnover / 12
)

# Reproductive tissue mass allocation to fruit
self.data["propagule_c_mass"][cell_id] = np.sum(
community.stem_allometry.reproductive_tissue_mass
* self.model_constants.propagules_mass
)
self.data["non_propagule_c_mass"][cell_id] = np.sum(
community.stem_allometry.reproductive_tissue_mass
* (1 - self.model_constants.propagules_mass)
)

# Allocate the topsliced GPP to root exudates with remainder as active
# nutrient pathways
self.data["root_carbohydrate_exudation"][cell_id] = np.sum(
cohort_allocation.gpp_topslice * self.model_constants.root_exudates
)
self.data["plant_symbiote_carbon_supply"][cell_id] = np.sum(
cohort_allocation.gpp_topslice
* (1 - self.model_constants.root_exudates)
)

# Update community allometry with new dbh values
Expand Down Expand Up @@ -681,10 +718,6 @@ def calculate_turnover(self) -> None:
the variables it returns.
"""

self.data["plant_reproductive_tissue_turnover"] = xr.full_like(
self.data["elevation"], 0.003
)

# Lignin concentrations
self.data["stem_lignin"] = xr.full_like(
self.data["elevation"], self.model_constants.stem_lignin
Expand Down Expand Up @@ -733,9 +766,6 @@ def calculate_turnover(self) -> None:
self.data["nitrogen_fixation_carbon_supply"] = xr.full_like(
self.data["elevation"], 0.01
)
self.data["root_carbohydrate_exudation"] = xr.full_like(
self.data["elevation"], 0.025
)

def calculate_nutrient_uptake(self) -> None:
"""Calculate uptake of soil nutrients by the plant community.
Expand Down