Closed BrianCollinss closed 5 years ago
@hol353 Hi Dean. By any chance, is there anyone I can mention and share this with to double check? These growth conditions rarely occur and as the RUE model is mostly used, this problem may have been neglected. I worked on it over the weekend and might have fixed it in my new commit. Just need a second pair of eyes. Thanks for reading this anyway.
@HamishBrownPFR can you comment on this?
Wheat.zip
In this specific experiment from Wheat validation dataset, in which CanopyPhotosynthesis is used as the Photosynthesis model instead of the default RUE model, I get this error towards the end of the season:
NaN (not a number) found when getting variable: [Leaf].Live.Wt
I tried to fix this by making sure maintenance respiration was not assigned to organs with zero metabolic and storage dry matter. But that would lead to another error telling me that mass balance was not met (in Leaf, line 1664). I don't get the same error when I use the default RUE model for photosynthesis since there is no maintenance respiration explicitly accounted for in the RUE model.
In OrganArbitrator, the method SubtractMaintenanceRespiration determines maintenance respiration of all organs. If respiration is more than daily assimilation, for example when VPD is too high, part of maintenance respiration is assigned to organs and deducted from live storage and metabolic DMs. However, in Leaf (the only organ that seems to check the DM balance!), this amount is not accounted for when the DM balance of the day is checked at the end of the method SetDryMatterAllocation.
In my branch, I added a line to check how much DM is lost at the end of the day and that exactly amounted to the maintenance respiration of the leaves. The maintenance respiration IS deducted from the leaf DM, but it is not accounted for when the daily balance of DM is calculated, which results in an Exception. Maybe we should just get rid of that DM-balance part. It doesn't exist in other organs.