Tuesday, February 11, 2014

Matlab spconvert function - undocumented "feature"

Matlab has a useful function for loading data that is in a sparse format - spconvert.  Basically, you create a file where each row contains the row, column, and data of the matrix you wish to load.  The first column is indicates the destination row, the second column indicates the destination column and the third column indicates the value at that row and column.  You load that into matlab (using, e.g., csvread):
sparse = csvread('mydata.csv');

example:
sparse = [1 1 2
2 1 3
2 2 5
3 3 7];

"sparse" is now have a N by 3 matrix, where N is the number of non-zero entries in your data.  With the command:
mat = spconvert(sparse)

yields:
2 0 0
3 5 0
0 0 7

Warning!!!! This doesn't appear to be documented!!! If you repeat a location in sparse, the value that appears in the result (mat) will be the sum of the entries in sparse.  For example, if sparse is modified to be:
sparse = [1 1 2
2 1 3
2 2 5
3 3 7
1 1 11];

then mat = spconvert(sparse) yields:
13 0 0
3 5 0
0 0 7

Note that the (1,1) entry of mat is 13, the sum of 2 + 11, the first and last rows of sparse.

Monday, February 10, 2014

Straightening the steering tube of my bianchi

Do not try this yourself, ever.  According to everyone I've talked to it is the most dangerous thing you can do, you will die a horrible, burning death if you try this.

My bianci is awesome.  It's a steel frame, red, I bought it from Stos & Alicia for $75 a few years ago.  I think they got it off of Craigslist.  It is a great commuter bike because it is rugged but goes fast - the frame actually fits me.  Unfortunately it is hard to get parts for it.  The rear axle broke awhile back and none of the bike shops had one or could get one.  I finally went to Harris Cyclery, and they had one that was close to the right size, so I bought it and a hack saw, made a rough measurement using the broken pieces of the old axle, and voila!  Back in the saddle.  This was after I partially rebuilt the rear wheel (replacing dead spokes, truing).

Not long after that, while I was riding along the Charles to work one morning, the front brake fell off, lodged in the front wheel, and I went flying over the handle bars.

Saturday, January 25, 2014

Follow up to Carob Porter - racking into secondary

Just a quick note - today I racked the Carob Porter beer from the primary fermenter into a secondary.  It's been about 3 weeks.  The beer was bitter but not spoiled, and was not sweet, so I'm hopeful the yeast got through all / most of the sugar.

There was a layer of material floating at the top, and of course a layer of muck at the bottom.  I suspect the layer of top material is what would normally get blown off during fermentation - this was a half batch, the carboy is only half full, and in a full batch a good amount of material is carried out through the airlock during the fermentation.  Because the top of the liquid was much further from the airlock, I suspect it is one reason it didn't happen this time (also the fermentation was not that vigorous).  I managed to avoid most of the material (top and bottom) during the transfer, although some did make it over.  Hopefully it will settle to the bottom during this stage.

Sunday, January 5, 2014

Brewing a chocolate ... whoops, carob ... porter. Crude heat capacity calculations...

I started a batch of homebrew today, aiming for a chocolate carob* porter.  My overall goal is to make a peanut butter porter, and possibly even a chocolate-peanut butter porter, but since I haven't brewed in a while I thought I'd start with an established recipe, and if that works try the peanut butter.

* turns out I used carob instead of chocolate...

Wednesday, December 25, 2013

Adjusting water hardness and pH of a beer mash

I had the opportunity earlier this week to work at my brother-in-law Chris's microbrewery, and it was a blast.  The day before that we had stopped by and he showed me around.  It was amazing to me that they had started from nothing not too long ago (< 1 year), and now they had a row of fermenters, grain mill, and several other pieces of equipment whose names I don't know, but I know what they do from home-brewing experience.  What was exciting for me personally was that a lot of the technology and equipment was familiar to me from grad school!  I studied surface science: how Nickel metal can catalyze chemical reactions.  We used steel chambers under ulta-high vacuum, and so we had lots of pumping systems, cooling systems, pneumatic systems, and the chambers were connected to gases via steel lines.  All of this is present at the brewery as well other equipment.  Anyway, it was great to "see some old friends" as we used to say when we'd see a familiar piece of equipment in a different setting.

The main thing we worked on was investigating the pH (acidity) of the mash.  A general recommendation is that the pH of the mash should be in the range 5.1 to 5.4 but Chris had consistently been measuring it to be 5.7.  Not a huge problem, but in the quest for better beer it seemed like a good idea to figure out what was going on.  We started discussing on the way there.  The city water was reported as being pH 8, and Chris had a pH meter and had made measurements at various locations by sampling the water there and under various conditions.  We decided to do something similar, write it all down, and then try a mini-mash and see if by adding some salts and/or phosphoric acid we get the pH into 5.1 - 5.4 range.

Edit:  pH is important because it affects the enzyme activity during the mash, and the yeast activity during the fermentation:
http://byo.com/fruit-beer/item/1493-the-power-of-ph
http://www.howtobrew.com/section3/chapter15-2.html

Sunday, April 14, 2013

Horseshoes, hand grenades but not black hole event horizons: Being close to the horizon is not good enough

I do not currently really understand the math of general relativity, but based on some stated rules about the behavior of light around black holes I've created a model in my mind that I would like to write down and then explore and/or destroy.

Start with an event horizon:
http://en.wikipedia.org/wiki/Event_horizon
In general relativity, an event horizon is a boundary in spacetime beyond which events cannot affect an outside observer. In layman's terms it is defined as "the point of no return" i.e. the point at which the gravitational pull becomes so great as to make escape impossible. 
Outside the event horizon of black hole is another interesting boundary - the photon sphere:
http://en.wikipedia.org/wiki/Photon_sphere
photon sphere is a spherical region of space where gravity is strong enough that photons are forced to travel in orbits. The radius of the photon sphere, which is also the lower bound for any stable orbit, is:
r = \frac{3GM}{c^{2}}
which is one and half times the Schwarzschild radius.