Exemplo n.º 1
0
        public double ApplyToRecipe(IRecipe targetRecipe)
        {
            var og        = targetRecipe.GetEstimatedOriginalGravity();
            var forReturn = ((og - 1) - ((og - 1) * this.Attenuation / 100)) + 1;

            return(forReturn);
        }
Exemplo n.º 2
0
        /// <summary>
        /// assumes tinseth for now. later refactor a strategy to inject  forumulas
        /// </summary>
        /// <param name="targetRecipe"></param>
        /// <returns></returns>
        private double Utilization(IRecipe targetRecipe)
        {
            double utilization = 0;

            if (targetRecipe.BatchVolume > 0)
            {
                double part1 = Math.Pow((double)0.000125, ((double)targetRecipe.GetEstimatedOriginalGravity() - (double)1));
                double part2 = Math.Pow(2.72, (-0.04 * (double)this.BitterCalculationTime));
                utilization = ((double)1.65 * (double)part1) * ((double)1 - (double)part2) / (double)4.14;
            }
            return(utilization);
        }
Exemplo n.º 3
0
        public void ApplyFermentableToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance
            //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness
            ingredient        = myIngredientFactory.GetIngredient(IngredientType.BitterSeason);
            ingredient.Amount = 1.5;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var og = myRecipe.GetEstimatedOriginalGravity();

            Assert.AreEqual(myRecipe.Fermentables.Count, 1);
            Assert.AreEqual(Math.Round(og, 3), 1.043);
        }
Exemplo n.º 4
0
        public void ApplyFermenterToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var og = myRecipe.GetEstimatedOriginalGravity();

            Assert.AreEqual(myRecipe.Fermentables.Count, 1);
            Assert.AreEqual(Math.Round(og, 3), 1.043);
            ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermenter);
            (ingredient as IFerment).PitchType   = FermenterPitchType.Dry;
            (ingredient as IFerment).Attenuation = 75;
            myRecipe.Ingredients.Add(ingredient);
            var fg = myRecipe.GetEstimatedFinalGravity();

            Assert.AreEqual(Math.Round(fg, 3), 1.011);
        }