From a1da770a36e012256c221ab1b448df978c8ca881 Mon Sep 17 00:00:00 2001 From: holos-aafc <95769272+holos-aafc@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:54:38 -0600 Subject: [PATCH] Treat grass silage as perennial --- .../Initialization/InitializationServiceTest.cs | 4 ++-- H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs | 4 ++-- .../Animals/AnimalInitializationService.Methane.cs | 6 +++--- .../Animals/AnimalInitializationService.cs | 2 +- .../Animals/IAnimalInitializationService.cs | 4 ++-- .../Crops/CropInitializationService.Yield.cs | 2 +- .../Services/Initialization/InitializationService.cs | 10 +++++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/H.Core.Test/Services/Initialization/InitializationServiceTest.cs b/H.Core.Test/Services/Initialization/InitializationServiceTest.cs index 025eef43..d7a2df3a 100644 --- a/H.Core.Test/Services/Initialization/InitializationServiceTest.cs +++ b/H.Core.Test/Services/Initialization/InitializationServiceTest.cs @@ -871,7 +871,7 @@ public void InitializeOtherLivestockCh4EmissionFactor() farm.Components.Add(deerComponent); - _initializationService.InitializeAnnualManureMethaneEmissionRate(farm); + _initializationService.InitializeDailyManureMethaneEmissionRate(farm); Assert.AreEqual(0.000603, deer.ManagementPeriods.First().ManureDetails.DailyManureMethaneEmissionRate); } @@ -1008,7 +1008,7 @@ public void InitializeOtherLivestockCh4EmissionFactorNullArguments() Farm farm = new Farm(); try { - _initializationService.InitializeAnnualManureMethaneEmissionRate(farm);// passing farm with null dairyComponent + _initializationService.InitializeDailyManureMethaneEmissionRate(farm);// passing farm with null dairyComponent } catch (Exception ex) { diff --git a/H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs b/H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs index 4a3ca13f..c7839929 100644 --- a/H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs +++ b/H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs @@ -432,7 +432,7 @@ public double CalculateCarbonInputFromRoots( return 0; } - if (currentYearViewItem.CropType.IsPerennial()) + if (currentYearViewItem.CropType.IsPerennial() || currentYearViewItem.CropType == CropType.GrassSilage) { return this.CalculateCarbonInputFromRootsForPerennials( previousYearViewItem: previousYearViewItem, @@ -487,7 +487,7 @@ public double CalculateCarbonInputFromExtraroot( return 0; } - if (currentYearViewItem.CropType.IsPerennial()) + if (currentYearViewItem.CropType.IsPerennial() || currentYearViewItem.CropType == CropType.GrassSilage) { return this.CalculateCarbonInputFromExtrarootsForPerennials( previousYearViewItem: previousYearViewItem, diff --git a/H.Core/Services/Initialization/Animals/AnimalInitializationService.Methane.cs b/H.Core/Services/Initialization/Animals/AnimalInitializationService.Methane.cs index bb0091e1..59061960 100644 --- a/H.Core/Services/Initialization/Animals/AnimalInitializationService.Methane.cs +++ b/H.Core/Services/Initialization/Animals/AnimalInitializationService.Methane.cs @@ -13,18 +13,18 @@ public partial class AnimalInitializationService /// Reinitialize the DailyMethaneEmissionRate for each ManagementPeriod of each farm /// /// Contains the that needs to be reinitialized to default - public void InitializeAnnualManureMethaneEmissionRate(Farm farm) + public void InitializeDailyManureMethaneEmissionRate(Farm farm) { if (farm != null) { foreach (var managementPeriod in farm.GetAllManagementPeriods()) { - this.InitializeAnnualManureMethaneEmissionRate(managementPeriod); + this.InitializeDailyManureMethaneEmissionRate(managementPeriod); } } } - public void InitializeAnnualManureMethaneEmissionRate(ManagementPeriod managementPeriod) + public void InitializeDailyManureMethaneEmissionRate(ManagementPeriod managementPeriod) { if (managementPeriod != null && managementPeriod.ManureDetails != null) { diff --git a/H.Core/Services/Initialization/Animals/AnimalInitializationService.cs b/H.Core/Services/Initialization/Animals/AnimalInitializationService.cs index 17de9477..6c2afc87 100644 --- a/H.Core/Services/Initialization/Animals/AnimalInitializationService.cs +++ b/H.Core/Services/Initialization/Animals/AnimalInitializationService.cs @@ -85,7 +85,7 @@ public void InitializeFarm(Farm farm) this.InitializeManureExcretionRate(farm); this.InitializeNitrogenExcretionRate(farm); this.InitializeManureCompositionData(farm); - this.InitializeAnnualManureMethaneEmissionRate(farm); + this.InitializeDailyManureMethaneEmissionRate(farm); this.InitializeAnnualEntericMethaneEmissionRate(farm); this.InitializeMethaneProducingCapacityOfManure(farm); this.InitializeMilkProduction(farm); diff --git a/H.Core/Services/Initialization/Animals/IAnimalInitializationService.cs b/H.Core/Services/Initialization/Animals/IAnimalInitializationService.cs index c7b02e1a..10789200 100644 --- a/H.Core/Services/Initialization/Animals/IAnimalInitializationService.cs +++ b/H.Core/Services/Initialization/Animals/IAnimalInitializationService.cs @@ -14,7 +14,7 @@ public interface IAnimalInitializationService /// Reinitialize the DailyMethaneEmissionRate for each ManagementPeriod of each farm /// /// Contains the ManagementPeriod.ManureDetails.DailyMAnureMethaneEmissionRate that needs to be reinitialized to default - void InitializeAnnualManureMethaneEmissionRate(Farm farm); + void InitializeDailyManureMethaneEmissionRate(Farm farm); /// /// Reinitialize each 's volatile solid excretion manure detail within a @@ -179,7 +179,7 @@ void InitializeDefaultEmissionFactors( void InitializeGainCoefficient(Farm farm); void InitializeNitrogenExcretionRate(Farm farm); void InitializeManureCompositionData(Farm farm); - void InitializeAnnualManureMethaneEmissionRate(ManagementPeriod managementPeriod); + void InitializeDailyManureMethaneEmissionRate(ManagementPeriod managementPeriod); void InitializeVolatileSolids(Farm farm); List GetValidDietAdditiveTypes(); void InitializeTotals(ManagementPeriod managementPeriod); diff --git a/H.Core/Services/Initialization/Crops/CropInitializationService.Yield.cs b/H.Core/Services/Initialization/Crops/CropInitializationService.Yield.cs index 640dc209..d8368850 100644 --- a/H.Core/Services/Initialization/Crops/CropInitializationService.Yield.cs +++ b/H.Core/Services/Initialization/Crops/CropInitializationService.Yield.cs @@ -193,7 +193,7 @@ public void InitializeSilageCropYield(CropViewItem silageCropViewItem, Farm farm // No defaults for any grass silages so we use SAD data if (silageCropViewItem.CropType == CropType.GrassSilage) { - this.InitializeYield(silageCropViewItem, farm); + this.InitializeYieldUsingSmallAreaData(silageCropViewItem, farm); silageCropViewItem.CalculateWetWeightYield(); } } diff --git a/H.Core/Services/Initialization/InitializationService.cs b/H.Core/Services/Initialization/InitializationService.cs index 8f793b1a..7c3ae870 100644 --- a/H.Core/Services/Initialization/InitializationService.cs +++ b/H.Core/Services/Initialization/InitializationService.cs @@ -91,7 +91,7 @@ public void ReInitializeFarms(IEnumerable farms) this.InitializeDefaultEmissionFactors(farm); //Table 38 - this.InitializeAnnualManureMethaneEmissionRate(farm); + this.InitializeDailyManureMethaneEmissionRate(farm); // Table 44 this.InitializeManureMineralizationFractions(farm); @@ -403,9 +403,9 @@ public void InitializeGrazingViewItem(GrazingViewItem grazingViewItem, Managemen } - public void InitializeAnnualManureMethaneEmissionRate(Farm farm) + public void InitializeDailyManureMethaneEmissionRate(Farm farm) { - _animalInitializationService.InitializeAnnualManureMethaneEmissionRate(farm); + _animalInitializationService.InitializeDailyManureMethaneEmissionRate(farm); } public void InitializeVolatileSolidsExcretion(Farm farm) @@ -635,9 +635,9 @@ public void InitializeManureCompositionData(Farm farm) _animalInitializationService.InitializeManureCompositionData(farm); } - public void InitializeAnnualManureMethaneEmissionRate(ManagementPeriod managementPeriod) + public void InitializeDailyManureMethaneEmissionRate(ManagementPeriod managementPeriod) { - _animalInitializationService.InitializeAnnualManureMethaneEmissionRate(managementPeriod); + _animalInitializationService.InitializeDailyManureMethaneEmissionRate(managementPeriod); } public void InitializeVolatileSolids(Farm farm)