APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
130 stars 160 forks source link

Error grazing plantain - Stock tries to remove more leaf than exists #2697

Closed sno036 closed 6 years ago

sno036 commented 6 years ago

@rcichota @her123

I am developing a simulation where the Stock component is grazing Plantain (eventually will be generic for any pasture/forage type plant) on a rotational basis. All is OK for the first year. At the start of the second year the grazing starts when there is a very high proportion of leaf on the plant and the error is that more leaf than exists is being attempted to remove.

I've attached the simulation and the error messae detail is below.

Thanks, Val

PlantainGrazing.zip

System.Exception: ERROR in file: C:\Work\ApsimX\Tests\Simulation\DairyFarmManager\DairyFarmManager.apsimx Simulation name: PlantainGrazing The sum of FractionToResidue and FractionToRemove for Leaf is greater than one for live biomass. Had this exception not been triggered, the biomass for BiomassRemovalDefaults would go negative ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: The sum of FractionToResidue and FractionToRemove for Leaf is greater than one for live biomass. Had this exception not been triggered, the biomass for BiomassRemovalDefaults would go negative at Models.PMF.Library.BiomassRemoval.CheckRemoveFractions(String name, OrganBiomassRemovalType amount) in C:\Work\ApsimX\Models\Plant\Library\BiomassRemoval.cs:line 184 at Models.PMF.Library.BiomassRemoval.RemoveBiomass(String biomassRemoveType, OrganBiomassRemovalType amount, Biomass Live, Biomass Dead, Biomass Removed, Biomass Detached, Boolean writeToSummary) in C:\Work\ApsimX\Models\Plant\Library\BiomassRemoval.cs:line 54 at Models.PMF.Organs.GenericOrgan.RemoveBiomass(String biomassRemoveType, OrganBiomassRemovalType amountToRemove) in C:\Work\ApsimX\Models\Plant\Organs\GenericOrgan.cs:line 251 at Models.GrazPlan.ForageProvider.RemoveHerbageFromPlant() in C:\Work\ApsimX\Models\Stock\stock_padd.cs:line 1139 at Models.GrazPlan.Stock.OnDoStock(Object sender, EventArgs e) in C:\Work\ApsimX\Models\Stock\stock.cs:line 4223 at Models.Clock.OnDoCommence(Object sender, CommenceArgs e) in C:\Work\ApsimX\Models\Clock.cs:line 268

sno036 commented 6 years ago

Encountering or not this error seems to be a bit flakey. I doubled the number of stock (resulting in shorter grazing durations) and no issues encountered for the first two years at least.

her123 commented 6 years ago

I'm examining the issue and it is likely to be in the calculations in Stock. Working on the fix now.

hol430 commented 6 years ago

@her123 I see you closed your pull request #2700 and deleted your forageconsumption branch. Is this issue resolved now?

her123 commented 6 years ago

Yes. I haven't had any follow up requests so it should be closed. Thanks.