Beispiel #1
0
        public RecipeProjectedOutcome GetRecipeProjectedOutcome(float recipeSize, List <IFermentableIngredient> fermentableIngredients,
                                                                List <IHopIngredient> hopIngredients,
                                                                BeerRecipeCore.Yeast.Yeast yeast, int extractionEfficiency)
        {
            if (recipeSize == 0)
            {
                throw new ArgumentException("Recipe size cannot be zero.", nameof(recipeSize));
            }
            if (fermentableIngredients.Count == 0)
            {
                throw new ArgumentException("There are no fermentable ingredients.", nameof(fermentableIngredients));
            }
            if (hopIngredients.Count == 0)
            {
                throw new ArgumentException("There are no hop ingredients.", nameof(hopIngredients));
            }

            var og = AlcoholUtility.GetOriginalGravity(fermentableIngredients, recipeSize, extractionEfficiency);
            var fg = AlcoholUtility.GetFinalGravity(og, yeast.Characteristics.Attenuation);

            return(new RecipeProjectedOutcome
            {
                Abv = AlcoholUtility.GetAlcoholByVolume(og, fg),
                ColorSrm = (int)Math.Round(ColorUtility.GetColorInSrm(fermentableIngredients, recipeSize), 0, MidpointRounding.ToEven),
                Ibu = BitternessUtility.GetBitterness(hopIngredients, recipeSize, og)
            });
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        public void UpdateRecipeOutcome()
        {
            if (m_size == 0)
            {
                return;
            }

            OriginalGravity = AlcoholUtility.GetOriginalGravity(m_fermentableIngredients, m_size, ExtractionEfficiency);
            if (OriginalGravityStyleComparison != null)
            {
                OriginalGravityStyleComparison.Compare(m_originalGravity);
            }

            if (m_yeastIngredient != null && m_yeastIngredient.YeastInfo != null)
            {
                FinalGravity = AlcoholUtility.GetFinalGravity(m_originalGravity, m_yeastIngredient.YeastInfo.Characteristics.Attenuation);
                if (FinalGravityStyleComparison != null)
                {
                    FinalGravityStyleComparison.Compare(m_finalGravity);
                }
            }

            if (m_finalGravity != 0)
            {
                AlcoholByVolume = AlcoholUtility.GetAlcoholByVolume(m_originalGravity, m_finalGravity);
                if (AbvStyleComparison != null)
                {
                    AbvStyleComparison.Compare(m_alcoholByVolume);
                }
            }

            AlcoholByWeight = AlcoholUtility.GetAlcoholByWeight(m_alcoholByVolume);
            Bitterness      = BitternessUtility.GetBitterness(m_hopsIngredients, m_size, m_originalGravity);
            if (BitternessStyleComparison != null)
            {
                BitternessStyleComparison.Compare(m_bitterness);
            }
            Color = ColorUtility.GetColorInSrm(m_fermentableIngredients, m_size);
            if (ColorStyleComparison != null)
            {
                ColorStyleComparison.Compare((float)m_color);
            }
        }
Beispiel #4
0
        public void GetBitternessTest()
        {
            var fugglesInRecipe = new Mock <IHopIngredient>();

            fugglesInRecipe.Setup(h => h.Amount).Returns(1f);
            fugglesInRecipe.Setup(h => h.HopInfo).Returns(new Hop("Fuggles", new HopCharacteristics(4.50f, 2.00f, 0), "Test Notes", "UK"));
            fugglesInRecipe.Setup(h => h.Time).Returns(60);

            var goldingsInRecipe = new Mock <IHopIngredient>();

            goldingsInRecipe.Setup(h => h.Amount).Returns(1f);
            goldingsInRecipe.Setup(h => h.HopInfo).Returns(new Hop("Goldings", new HopCharacteristics(5.00f, 3.50f, 0), "Test Notes", "UK"));
            goldingsInRecipe.Setup(h => h.Time).Returns(15);

            var hopsUsed = new List <IHopIngredient> {
                fugglesInRecipe.Object, goldingsInRecipe.Object
            };
            var bitterness = BitternessUtility.GetBitterness(hopsUsed, 5f, 1.054f);

            bitterness.Should().Be(23);
        }