private static float GetHopAmount(CommonHop commonHop, RecipeGenerationInfo recipeGenerationInfo, float originalGravity) { var ibuContribution = (float)commonHop.IbuContributionPercentage / 100 * recipeGenerationInfo.Ibu; var hopUtilizationPercentage = BitternessUtility.GetHopUtilization(commonHop.BoilAdditionTime, originalGravity) * 100; return((float)Math.Round(recipeGenerationInfo.Size * ibuContribution / (hopUtilizationPercentage * commonHop.AlphaAcid) / 0.7489f, HopAmountDecimalDigits)); }
public IRecipe GenerateRecipe(RecipeGenerationInfo recipeGenerationInfo) { var grainBill = new GrainBillService().GetGrainBill(recipeGenerationInfo); var hopIngredients = HopService.GetHopIngredients(recipeGenerationInfo, grainBill); return(new Recipe { Name = recipeGenerationInfo.Name, Size = recipeGenerationInfo.Size, BoilTime = RecipeDefaultSettings.BoilTime, Style = recipeGenerationInfo.Style, FermentableIngredients = grainBill, HopIngredients = hopIngredients, YeastIngredient = new YeastIngredient(0, 0, recipeGenerationInfo.Style.CommonYeast) }); }
internal static List <IHopIngredient> GetHopIngredients(RecipeGenerationInfo recipeGenerationInfo, List <IFermentableIngredient> fermentableIngredients) { if (recipeGenerationInfo.Style.CommonHops.Count == 0) { throw new InvalidOperationException($"Style {recipeGenerationInfo.StyleName} is missing common hops"); } var originalGravity = AlcoholUtility.GetOriginalGravity(fermentableIngredients, recipeGenerationInfo.Size); var hopIngredients = new List <IHopIngredient>(); foreach (var commonHop in recipeGenerationInfo.Style.CommonHops) { hopIngredients.Add(new HopIngredient { HopInfo = commonHop.Hop, Time = commonHop.BoilAdditionTime, Amount = GetHopAmount(commonHop, recipeGenerationInfo, originalGravity) }); } return(hopIngredients); }