Archive > August 2010

Angel's Share Experiment

05 August 2010 » In Beer » 5 Comments

Fermenting barleywine

I haven’t yet compiled a list of my top 10 beers, but if I did, Lost Abbey Angel’s Share would definitely be on it. I first tasted it at the 2010 Barleywine Festival at Toronado, and it was love from the first sip. The intense, rich maltiness, full body, and surprisingly dry finish — enhanced by the bourbon, oak, and vanilla character developed by aging it in Heaven Hill Wheat Whiskey barrels — make it a beer to savored and appreciated, especially at the end of the day in the company of good friends.
Here in California, we are sometimes lucky enough to find Angel’s Share on draft, and it might even be better than the bottled version. I even love the name, which refers to the portion (share) of a wine or spirit’s volume that is lost to evaporation during aging in the barrels.
Needless to say, I really want to brew a beer approaching this greatness.
The reason is not even economics. A small (375 ml) bottle of Angel’s Share goes
for around $16-18 locally, but I consider that a fair price, given the
ingredients, effort, and time that goes into its making. I would simply like to
extend my skills, learn, and, in the process, hopefully brew a great beer.
Now, there are a few obstacles. First, Lost Abbey does not release the base beer that goes into the bourbon barrels, and there is virtually no information on its composition, aside from a note on the website that it is “brewed with copious amounts of dark caramel malt.” Sources say that it is an English-style barleywine, an Imperial brown ale, or an American strong ale, so developing a clone recipe is a challenge. Second, I don’t have a bourbon barrel to age the beer in, and even if I did, the logistics of brewing 55 gallons of beer, fermenting, aging it a year, and then bottling over 300 bombers (22-oz bottles) are, shall we say, formidable. The closest thing a homebrewer can do to simulate this process is use oak cubes and then add some bourbon at bottling time.
Unable to find a clone recipe of the base beer, I decided to use the recipe from The Mad Fermentationist, who said that it was “inspired by, but not a clone of, Angel’s Share.” I am still learning how to craft beers from scratch, but I couldn’t stay away from tweaking his recipe anyway. I removed the Crystal 55L malt, cut the wheat malt by two thirds, added a good amount of Munich malt, and a bit of Carafa II Special. Whether that was a mistake or not will be shown by the end result. All of the hops I used were leftovers that I’ve been keeping in the fridge, so the alpha acid percentage had to be adjusted down, somewhat. A beer like this doesn’t really need much hop character, so a variety of hops can be used for bittering.
I also decided to brew a smaller batch, since the recipe is very experimental, and I don’t really need 5 gallons of 11% barleywine. An added bonus was that I could brew it on my stovetop, and ferment it in a 3-gallon Better Bottle.
Since this would be the biggest (highest ABV) beer I’ve ever brewed, I wanted to do it properly to ensure that the fermentation doesn’t get stuck halfway. To help with this, I made a 1.5 L starter from a very fresh vial of WLP001 yeast. I also followed the advice in How to brew a really BIG beer article, which suggests doing a long 146/149°F to 154/156°F step mash to make a very fermentable wort. For some reason, I thought that raising the mash temperature by decoction was a good idea. It wasn’t. The decoction boiled, but after adding it back to the main mash, the temperature hardly increased, so I had to improvise. More in the notes.
Given my recipe hacking and the troubles I encountered, I doubt this will be close to Angel’s Share, but I still hope it will be an enjoyable barleywine.

Angel’s Share Experiment
Type: All-grain
Batch Size: 2.5 gal
Total Grain: 9.72 lbs
Expected OG: 1.102
Expected SRM: 22.6
Expected IBU (Rager): 82.1
Brewhouse Efficiency: 75%
Wort boil time: 120 min
Fermentation Temperature: 67°F
6.75 lbs. Maris Otter 66.1%
1.75 lbs. Munich 10L Malt (US) 17.1%
0.32 lbs. White Wheat Malt 3.1%
0.32 lbs. CaraVienna Malt (Belgium) 3.1%
0.32 lbs. CaraMunich Malt (Belgium) 3.1%
0.13 lbs. Special B Malt (Belgium) 1.2%
0.09 lbs. Chocolate Malt (US) 0.9%
0.06 lbs. Carafa II Special (Germany) 0.6%
0.25 lbs. Sugar – Muscovado 4.9%
0.6 oz. Galena [13.8% AA, pellet] @ 60 min.
0.4 oz. Challenger [6.5% AA, pellet] @ 30 min.
0.4 oz. Cascade [6.5% AA, pellet] @ 30 min.
1 Whirlfloc tablet @ 15 min.
1 Servomyces yeast nutrient tablet @ 10 min.
0.8 oz American/Hungarian oak cubes secondary
White Labs WLP001 – California Ale
Water Profile
San Francisco tap
Mash Schedule
Type: step mash
Saccharification rest: 45 min. @ 147°F
Saccharification rest: 60 min. @ 155°F


Brew day, by myself.
Got some dough balls when mashing in, but the temp was 147°F exactly. After 15 minutes, pulled 3 quarts of medium-thickness mash into the kettle, and raised temp to 154°F and held 15 minutes for conversion.
Realized the chocolate malt I added from a leftover bag was uncrushed, so substituted 2.25 oz of crushed pale chocolate malt instead. Raised decoction temp to boiling, boiled for 15 minutes. Added back to the mash tun, but the temperature didn’t seem to go up at all. Infused 3 quarts of boiling water (by infusion calculator), temperature rose to only 151°F. Decided to leave at that, because adding more water would give me more than the desired boil volume. Mashed for another 40 minutes. Collected 3.75 gallons of 1.063 SG wort. Did a sparge with 1 quart to get more sugars out. Added after 30 minutes of the main boil. Obviously, the efficiency suffered a bit with such a small sparge.
Extended pre-hops boil by 30 minutes to evaporate more. Decided to add second batch of hops at -20 minutes to bring down IBUs a tad. Added muscovado sugar at flameout.
Chilled to 70°F, transferred to fermenter. Pre-pitch volume was 2.3 gallons. Aerated well by shaking, then pitched the active starter (made the night before). Placed in cooler with ice pack. Signs of fermentation (krausen and airlock) after only 2.5 hours.
Good strong fermentation going by morning, nice thick krausen. Temp is staying around 64°F.
Realized that Beer Alchemy was set to Tinseth formula instead of Rager while I was tweaking the IBUs, so most likely I over-bittered the barleywine. Womp womp. Dropped 6 oak cubes (3 American, 3 Hungarian) into the carboy.
Swirled the carboy to expel sulfur. Blowoff followed shortly, so attached a blowoff tube.
Temperature is up to 69°F. Gravity is down to 1.019.
Racked to the secondary on top of 0.8 oz of Hungarian-American oak cube mixture that’s been soaking in bourbon.
After a month on oak, the wood character is definitely present. The bitterness is there, but not overwhelming. Probably best to bottle soon.
Bottled with 1.5 oz of dextrose.

The Prime That Wasn't

03 August 2010 » In PHP, Tech » 36 Comments

I’ve seen a lot of problems solved with regular expressions, but last Friday, thanks to Chris and Sean, I found out that one can use them to determine whether a given integer is a prime number. The original articles showed the following regular expression:


You don’t apply this to the integer itself. Instead, you create a string of repeating 1s, where the numbers of 1s is defined by the number you’re testing, and apply the regex to that. If it fails to match, the number is a prime. The regex relies on backtracking and thus would not work with a DFA-based engine, such as PHP’s (now deprecated) ereg* functions. But, it works just fine with the preg_* ones, or so I thought (more on that in a bit).
So, how does it work? It may seem like a brain buster, but it’s actually pretty simple. Ignore the portion before the alternation operator (|), because it’s just a short-circuit case for checking whether the input string is empty or has a single 1. (If the string is empty, it means the number being tested is 0. If the string is a single 1, it means the number being tested is 1. Neither of these are prime.) The portion after the pipe is where the real magic happens.
The (11+?) sub-pattern matches strings 11, 111, etc. The \1+ matches whatever the sub-pattern matched, one or more times. So on the first try, the engine will match 11 and then attempt to match the same thing one or more times in the rest of the string. If it succeeds, the number is not a prime. Why? Because it just proved that the length of the string is divisible by 2 (the length of 11), therefore the original number is divisible by 2. If the overall match fails, the engine backtracks to the beginning and tries to match 111 two or more times and so on successively. If the first sub-pattern gets long enough (n/2 basically), and the overall match still fails, the number is a prime. Beautiful, isn’t it?
Coincidentally, Sean recently created a code evaluation plugin for the Phergie-based IRC bot that runs in the channel we hang out in. The plugin is a simple proxy to, but is helpful for doing quick code tests. We had fun experimenting with this regex pattern implemented in a PHP function that returns the next largest prime number after a given one. The trouble started when Sean fed it 99999999, and the code spit out 100000001. This didn’t seem right, and Wolfram Alpha confirmed; the answer we got was not a prime. (It factors into 17 * 5882353.)
A few similar tests also gave us numbers that were not prime. But, where was the problem? The PHP code was too simple to have a bug, many answers were correct, and the regex algorithm itself was sound. It was time for brute force. I quickly wrote some code to feed increasing odd integers into into regex pattern and check its answers against the normal sieve algorithm to see where it starts failing. The first number to fail was 22201; the regex said it was prime, but it’s actually a perfect square (1492). Past that, the failure rate increased.
It then dawned on me that the culprit might be the backtracking itself, specifically how it was implemented in PCRE, the library at the heart of PHP’s regular expressions. As I mention in my Regex Clinic talk, unbounded backtracking can dramatically slow down the matching and should be well-understood before attempting to write complex patterns. To manage the danger of runaway patterns, PCRE implemented the pcre.backtrack_limit setting a few years ago. In our case, backtracking is used to break up the string of 1s into successively larger chunks, and, with very long strings, the engine may run into this backtracking limit, which is set to 100000 by default. My guess was that with the 22201-character-long string, the default was not enough. Once the limit is reached, the match fails, and the number is declared prime.
I bumped the limit up to 200000, and voilà, 22201 was no longer declared prime. To fix the 100000001 match, the limit had to be raised dramatically, to around 250000000! And, the program took 14 seconds to deliver the verdict on my new i5 MacBook Pro. Needless to say, don’t use this prime determination algorithm for any sort of real-life stuff. Instead, just appreciate it for its elegance. I certainly did, and was glad that my bit of investigative work showed that abstract, pure, good ideas can still fail in the messy world of software and hardware.