Skip to content

Commit

Permalink
Treat grass silage as perennial
Browse files Browse the repository at this point in the history
  • Loading branch information
holos-aafc committed Sep 13, 2024
1 parent 8d7b4e2 commit a1da770
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions H.Core/Calculators/Carbon/ICBMCarbonInputCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public partial class AnimalInitializationService
/// Reinitialize the DailyMethaneEmissionRate for each ManagementPeriod of each farm
/// </summary>
/// <param name="farm"> Contains the <see cref="ManureDetails.DailyManureMethaneEmissionRate"/> that needs to be reinitialized to default</param>
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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IAnimalInitializationService
/// Reinitialize the DailyMethaneEmissionRate for each ManagementPeriod of each farm
/// </summary>
/// <param name="farm"> Contains the ManagementPeriod.ManureDetails.DailyMAnureMethaneEmissionRate that needs to be reinitialized to default</param>
void InitializeAnnualManureMethaneEmissionRate(Farm farm);
void InitializeDailyManureMethaneEmissionRate(Farm farm);

/// <summary>
/// Reinitialize each <see cref="ManagementPeriod"/>'s volatile solid excretion manure detail within a <see cref="Farm"/>
Expand Down Expand Up @@ -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<DietAdditiveType> GetValidDietAdditiveTypes();
void InitializeTotals(ManagementPeriod managementPeriod);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
10 changes: 5 additions & 5 deletions H.Core/Services/Initialization/InitializationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void ReInitializeFarms(IEnumerable<Farm> farms)
this.InitializeDefaultEmissionFactors(farm);

//Table 38
this.InitializeAnnualManureMethaneEmissionRate(farm);
this.InitializeDailyManureMethaneEmissionRate(farm);

// Table 44
this.InitializeManureMineralizationFractions(farm);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a1da770

Please sign in to comment.