caseydavenport / biermacht

Homebrewer's Companion for Android
Apache License 2.0
23 stars 10 forks source link

Milk Sugar should be treated like unfermentable #64

Closed sharathcshekhar closed 7 years ago

sharathcshekhar commented 7 years ago

I was playing with the app and like most of the apps, Biermacht treats lactose like a fermentable while calculating FG. This will mess with ABV estimation while designing a Milk Stout. I looked in to the code and it appears like only Malto Dextrine malts are treated as a special case. Can you consider adding Lactose too? Here is the diff.

diff --git a/src/com/biermacht/brews/utils/BrewCalculator.java b/src/com/biermacht/brews/utils/BrewCalculator.java index bb52011..c76c7c3 100644 --- a/src/com/biermacht/brews/utils/BrewCalculator.java +++ b/src/com/biermacht/brews/utils/BrewCalculator.java @@ -176,7 +176,8 @@ public class BrewCalculator {

// Returns the number of non fermentable gravity points for the given ingredient public static double NonFermentableGravityPoints(Recipe r, Ingredient i) {

sharathcshekhar commented 7 years ago

When I testing this, I found another bug. Dextrin malts which are calculated as non-fermentables are also calculated in fermentables. As a result if I use Dextrin malt in a all-grain recipe, its gravity points are added twice in OG. The same was observed for lactose. So we would need another fix. Something like this:

else if (f.getFermentableType().equals(Fermentable.TYPE_SUGAR)) {
        if (i.getName().equalsIgnoreCase("Milk Sugar (Lactose)")) {
          pts = 5 * Units.kilosToPounds(f.getBeerXmlStandardAmount())
/Units.litersToGallons(r.getBeerXmlStandardBatchSize());
        } else {
          pts = Units.kilosToPounds(f.getBeerXmlStandardAmount()) * f.getPpg() /
Units.litersToGallons(r.getBeerXmlStandardBatchSize());
        }
      }

And

else {

          if (i.getName().equalsIgnoreCase("Malto-Dextrine") ||
                  i.getName().equalsIgnoreCase("Dextrine Malt")) {
            pts = 5 * Units.kilosToPounds(f.getBeerXmlStandardAmount())
                    / Units.litersToGallons(r.getBeerXmlStandardBatchSize());
          } else {
            // Either a partial mash or all grain recipe
            pts = r.getEfficiency() * Units.kilosToPounds(f.getBeerXmlStandardAmount()) * f.getPpg() / Units.litersToGallons(r.getBeerXmlStandardBatchSize()) / 100;
          }

Lastly, we would need to handle Carapils malt as well.

sharathcshekhar commented 7 years ago

I have created a pull request for this. It is not a perfect fix, but an estimate which works for me. Pull it if you like or feel free to modify.

caseydavenport commented 7 years ago

@sharathcshekhar thanks! I've merged the PR as is. I'll take a look at the values it gives and get it out in a release this week.

sharathcshekhar commented 7 years ago

Cool. Will wait for the official update! Thanks again for the wonderful app!