Esempio n. 1
0
        public static void GetColdSteepCompensatedWeight(int aGrainWeight, out ColdSteepAddition aColdSteepAddition)
        {
            ColdSteepAddition ret = new ColdSteepAddition();
            ret.Weight = (int)Math.Round((double)aGrainWeight / COLDSTEEP_EFFICIENCY);
            ret.WaterContribution = ((double)ret.Weight * COLDSTEEP_WATER_TO_GRAIN_RATION)/1000d;
            ret.WaterContribution += ret.WaterContribution * COLDSTEEP_VOLUME_TO_SPARGE_RATIO;

            aColdSteepAddition = ret;
        }
Esempio n. 2
0
        public static void GetColdSteepCompensatedWeight(int aGrainWeight, out ColdSteepAddition aColdSteepAddition)
        {
            ColdSteepAddition ret = new ColdSteepAddition();

            ret.Weight             = (int)Math.Round((double)aGrainWeight / COLDSTEEP_EFFICIENCY);
            ret.WaterContribution  = ((double)ret.Weight * COLDSTEEP_WATER_TO_GRAIN_RATION) / 1000d;
            ret.WaterContribution += ret.WaterContribution * COLDSTEEP_VOLUME_TO_SPARGE_RATIO;

            aColdSteepAddition = ret;
        }
Esempio n. 3
0
        private void recalculateGrainBill()
        {
            var sum = Grist.Sum(g => g.Amount);
            if (sum != 100)
            {
                sum = -1;
                GrainBillSize = 0;
            }
            else
            {
                var preBoilTappOffLoss = (Volumes.PreBoilTapOff / (Volumes.PreBoilVolume - Volumes.PreBoilTapOff));

                var TotalGbs = GravityAlgorithms.GetGrainBillWeight(OriginalGravity, Volumes.TotalBatchVolume - Volumes.PreBoilTapOff, Grist.ToList(), gfc.MashEfficiency);


                Volumes.ColdSteepVolume = 0;

                var l = new List<GristPart>();
                foreach (var grain in Grist)
                {
                    if (grain.Stage == FermentableStage.ColdSteep)
                    {
                        var g = (int)Math.Round((double)TotalGbs * ((double)grain.Amount / 100d));
                        ColdSteepAddition csa = new ColdSteepAddition();
                        ColdSteep.GetColdSteepCompensatedWeight(g, out csa);
                        grain.AmountGrams = csa.Weight;
                        Volumes.ColdSteepVolume += csa.WaterContribution;
                    }

                    if (grain.Stage == FermentableStage.Mash)
                    {
                        grain.AmountGrams = (int)Math.Round(TotalGbs * ((double)grain.Amount / 100d));
                        grain.AmountGrams += (int)Math.Round(grain.AmountGrams * (Volumes.PreBoilTapOff / (Volumes.PreBoilVolume - Volumes.PreBoilTapOff)));
                    }

                    if (grain.Stage == FermentableStage.Fermentor)
                    {
                        var boilerLossPercent = 1 - (GrainfatherCalculator.GRAINFATHER_BOILER_TO_FERMENTOR_LOSS / Volumes.TotalBatchVolume);
                        grain.AmountGrams = (int)Math.Round(TotalGbs * ((double)grain.Amount / 100d) * boilerLossPercent);
                    }

                    l.Add(grain);

                }

                var prbg = GravityAlgorithms.GetGravity(Volumes.PreBoilVolume, Grist.Where(x => x.Stage == FermentableStage.Mash).ToList(), gfc.MashEfficiency);

                var pobg = GravityAlgorithms.GetGravityByPart(
                    Volumes.PostBoilVolume, 
                    Grist.Where(x => x.Stage != FermentableStage.Fermentor).ToList(), 
                    TotalGbs,
                    gfc.MashEfficiency);

                Gravitylabel.Content = String.Format("Gravity (pre- and post-boil) [SG]: {0:F3} {1:F3})",
                    prbg,
                    pobg);

                foreach (var grain in l)
                {
                    Grist.Remove(grain);
                    Grist.Add(grain);
                }

                double topUpVolume = 0;
                var mashGrainBillWeight = Grist.Where(x => x.Stage == FermentableStage.Mash).Sum(x => x.AmountGrams);
                if (mashGrainBillWeight > GrainfatherCalculator.SMALL_GRAINBILL || mashGrainBillWeight == 0)
                {
                    TopUpMashWaterVolumeTextBox.Visibility = Visibility.Hidden;
                    TopUpMashWaterVolumeLabel.Visibility = Visibility.Hidden;

                }
                else
                {
                    TopUpMashWaterVolumeTextBox.Visibility = Visibility.Visible;
                    TopUpMashWaterVolumeLabel.Visibility = Visibility.Visible;
                    topUpVolume = TopUpMashWater;

                }
                try
                {

                    var swv = GrainfatherCalculator.CalcSpargeWaterVolume(mashGrainBillWeight,
                        (Volumes.PreBoilVolume),
                        topUpVolume);
                    if (swv < 0)
                        swv = 0;
                    SpargeWaterVolumeLabel.Content = String.Format("Sparge water volume [L]: {0:0.#}", swv);

                    var mwv = GrainfatherCalculator.CalcMashVolume(mashGrainBillWeight);
                    if (mwv < 0)
                        mwv = 0;
                    MashWaterVolumeLabel.Content = String.Format("Mash water volume [L]: {0:0.#}", mwv);
                }
                catch (ArgumentException e)
                {
                    MessageBox.Show(e.Message);
                }
                foreach (GridViewColumn c in MaltsGridView.Columns)
                {
                    c.Width = 0; //set it to no width
                    c.Width = double.NaN; //resize it automatically
                }
                double ecb = ColorAlgorithms.CalculateColor(Grist.ToList(), Volumes);
                string refString = ColorAlgorithms.GetReferenceBeer(ecb);
                ColorLabel.Content = String.Format("Color [ECB]: {0:F1} eqv. to {1}", ecb, refString);

                recalculateIbu();

                var ol = BoilHops.OrderBy(x => x).ToList();
                BoilHops.Clear();
                foreach (HopAddition h in ol)
                    hopsCompositionChanged(h);

            }
        }