Sunday, June 15, 2014

How does World Cup Spray work?


World Cup ball
Hassan Ammar/Associated Press

In this World Cup, I was surprised when I saw a referee draw a white line on the ground for a free kick. "What a great idea!" I thought. But how does it work? Numerous google searches turned up meaningless articles such as this that basically describe the working principle of the spray as "you spray it on the ground and it leaves a line." NO SHIT SHERLOCK...
So how does it really work? Well, the can is under pressure, probably somewhere around 5 atmospheres of pressure, depending on the strength of the can. The main ingredient is water (80%). A mixture of gases are used to propel the surfactant out of the can, including butane, isobutane, and propane. Once the high pressure mixture of ingredients leave the can and enters the atmosphere, they expand and create a foam on the grass.

The most important ingredient is "polyoxyethylenated sorbitan monolaurate" (aka Tween20 at a concentration of around 1%). This molecule is known as a surfactant (more about this later!) The chemical structure is shown here (from Wikipedia):



Looking at this molecule, the left side is hydrophillic (likes water) and the right side is hydrophobic (likes sticking to hydrocarbon molecules such as butane, isobutane, and propane!) This is the key concept of how a surfactant works: it will stick to the interface between the water and the butane, to form surfaces. This allows the butane to form small drops in water (an emulsion) instead of just phase-separating with all the butane in one half of the can and the water in the other half of the can.

The other key concept is the phase change that Butane undergoes. The hydrocarbons that are under pressure (I would guess 5 atmospheres of pressure) in the can, expand to many times their volume when the enter the atmosphere. This is because Butane is a liquid at room temperature, for pressures greater than 2.5 atmospheres (density of 599 kg/m^3), but it is a gas at pressures below 2.5 atmospheres (density of 2.48 kg/m^3). So the Butane expands to ~250 times its volume when it leaves the can. It turns from a liquid into a gas and expands into massive bubbles. The water in the can doesn't change volume because it's a liquid at both atmospheric and can pressures.

So the expanded butane drops make a foam on the grass, which scatters light and makes it white in appearance. In my drawing, I only showed a few bubbles, but in reality there will be billions of them.

Eventually, the bubbles of propane will combine, pop, and evaporate, leaving only a residue of the surfactant (Tween20) and water on the grass. What makes the bubbles scatter light is the billions of interfaces of differing refractive indexes. Once these interfaces combine to form a thin layer of Tween20, they no longer scatter light, and become invisible.

Now you know: that's how World Cup Spray works!

Some of the other ingredients in the can are: a chelating agent "tetrasodium EDTA acid" at around 2% composition. A chelating agent is basically just a chemical that binds to metal ions. Who cares about metal ions? Well, metal ions (such as those that make up the can) have a tendency to break polymer chains such as the one that is used in the foam. So basically, the chelating agent helps preserve the important Tween20 chains from breaking down during storage in the can.

There are also some preservatives to prevent Bacteria from growing in the spray can if it's left on a shelf for a long time.

I made a schematic diagram of how I understand the can's operating principles. If you have questions, or think that my interpretation is wrong, please let me know and I'll update it! In particular, I'm not sure about the exact state of the foam while it's on the grass surface. Are they bubbles of propane? Or maybe not spherical bubbles?

My interpretation of how the spray works is based mainly on the patent by the inventor that I found here: http://www.google.com/patents/US20120148741

Sunday, February 2, 2014

The thermodynamic limit of bitcoin mining

There has been a trend in improving energy efficiency of Bitcoin mining machines. But how good can they get? What are the fundamental limits to the hashrate? What is the ultimate GH/J?

We can use thermodynamics to explore this possibility. If we treat the computation of a SHA256 hash as a simple operation, with a single bit of entropy required to calculate, then the energy expended to perform the hash is equal to the Landuaer limit: k*T*ln2. The blackbody temperature of outer space (caused by the cosmic microwave background left over from the big bang) is: 2.7K. So if we built a computer that was operating at 2.8 K and was radiating waste heat into outer space at 2.7K, we could theoretically perform each hash at 1.38E-23 J/K * 2.7K = 3.7E-23 J/operation, or inversely, 2.7*10^13 GH/J, or around 13 orders of magnitude better than the current Bitcoin miners! So plenty of room for improvement.

If we assume a Moore's law type improvement in efficiency of doubling every 18 months, then the time it will take before someone develops a thermodynamically limited ASICminer will be 65 years or so. I expect that DNA-based and other soft-matter computers will be much more energy efficient than current CPUs. I think it's not crazy to believe that a soft-matter computer (ie DNA annealing computer) may improve the energy efficiency of Bitcoin mining by a few orders of magnitude. 

So now if we harnessed the entire power of the sun to perform bitcoin operations, with around 3.8*10^26W of power, in theory we could perform: 3.8*10^26W/ 3.7E-23 J/operation =10^49 operations per second. The current Bitcoin mining network performs around 2*10^16 Hash/s, and so there are around 33 orders of magnitude left before the entire power of the sun is consumed calculating Bitcoin hashes.

OK, now what if someone built a hyper-efficient computer? What would happen to the difficulty of mining? Well, currently, the "target" to create a new block while mining on the Bitcoin network is: 0000000000000001F52C00000000000000000000000000000000000000000000
This number means that if a miner stumbles upon a hash that is less than this value, he/she wins the block reward. So around in in every 15 and 1/16 hexadecimals will be rewarded, which is (15 1/16)^17 = 7*10^18 hashes. So we expect each block to be solved in around: 7*10^18 hashes/2*10^16 Hash/s = 350 seconds, or 6 minutes or so. Now if we want to keep the block generation rate of the Bitcoin network the same, but with massively increased hashrate, the target just need to be readjusted. So what would the target have to be if we are using all of the power of the sun in a thermodynamically limited computer that radiates energy into space? Well, the target would have to be 10^33 times more difficult, or 33ln10/(ln16)=27 hexadecimals further to the right. So the target would have to be approximately: 000000000000000000000000000000000000000001F52C00000000000000000

And so, the Bitcoin system is pretty much OK with any foreseeable improvements in computational speed.

If you know how a quantum computer might affect these calculations (I don't), then please comment below!

Saturday, November 30, 2013

Bitcoin mining

For fun, I just put together a Bitcoin mining machine! The machine does brute-force calculations to try to solve the mathematical problem of what input (random string), in combination with the current Bitcoin block header (that contains a list of transactions) will produce the desired output, a series of numbers that starts with a bunch of zeroes. As an example, here is a script that will calculate the hash of Bitcoin Block number 125552:

import hashlib
header_hex = ("01000000" +
"81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
"e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
"c7f5d74d" +
"f2b9441a" +
"42a14695")
header_bin = header_hex.decode('hex')
hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
hash.encode('hex_codec')
testblock=hash[::-1].encode('hex_codec')
print "The hash of block 125552: ", testblock;


I got this from here https://en.bitcoin.it/wiki/Block_hashing_algorithm . You can test this script for yourself by pasting and executing it here: http://www.compileonline.com/execute_python_online.php Note that the first few digits of the resulting hash are zeroes, which is the criteria for mining a new block. This block was mined by trying numbers in the place of the '42a14695' until one of them worked. Note that the number 2504433986 is 9546A142 in hexadecimal, which becomes 42a14695 when re-arranged between little and big endian. So we can speculate that perhaps the miner had to try more than 2 billion combinations before finding the one that worked! All the current Bitcoin miners in the network are brute-force trying numbers, hoping to get lucky and collect the 25 Bitcoin reward. By performing this work, miners verify that the transactions are valid and secure the network as a whole since other miners scrutinize the block header looking for any mistakes that would invalidate it and prevent it from being widely accepted.
The mining setup that I built uses an ASICMiner Erupter Blade. I mounted the Blade in an old broken lab power supply that had a working fan in it already. The power supply is a 12V 10A LED power supply. I read some reports of the wires overheating so I went overkill and put some super beefy wires (AWG 8) between the power supply and the Blade. It took a lot of tinkering to set up. Eventually I settled on using 32 bit bfgminer since it has built in stratum proxy capability. I ran it with "bfgminer --http-port 8330" where I configured the Blade through a browser at 192.168.1.254:8000/Main as follows:

UPDATE: I created a .bat file, and put a shortcut to it in my startup folder. Now, everytime I start up my computer, it automatically starts mining. I had to set the properties of the shortcut to run as administrator in order for it to work. The bat file contains:
"cd Desktop/bfgminer-3.7.0-win32
bfgminer --http-port 8330 -o stratum.btcguild.com:3333 -u username -p 123"

Currently, the device mines approximately 293 micro-BTC/hr, but this is likely to decrease in the near future with faster mining machines. Update: down to 99 micro-BTC/hr :(

Update: I stopped mining because electricity costs became greater than the mining reward!

Comments/questions welcome! And of course donations :) 1EXhFqvXkwcXRfhUxmbaUSZgLhGCsWsUcu

Tuesday, October 23, 2012

DIY sonar using PC speaker and microphone

Together with my friend and colleague John Berezney, I decided to make a sonar system using a microphone and speaker. The idea is to make an active sonar system using PC speakers as output and a microphone as an input. I got some inspiration for this project from this website: http://eddiem.com/projects/chirp/chirp.htm

The first step is to make a chirp, which is just a type of pulse that changes frequency (see Figure). The audio speakers I have can only make pulses up to 20kHz (I think?), so I make chirps that vary between around 4kHz and 16kHz. I used Labview software to program the chirp and make it come out of my speakers.
The equation for this chirp, C(t) is a function of the pulse length T as well as the minimum and maximum frequencies in the chirp f_min and f_max. Typically I would choose a pulse length of T=2 milliseconds and f_min=4kHz and f_max=12kHz. The first part of the equation with the exponential is just an envelope function that prevents the frequency content from leaking into adjacent frequencies. The equation is:

Once we have a chirp coming out of the speakers, the next trick is to process the recorded audio that is coming in through the microphone. There are many ways to do this. I chose to use a matched filter. The idea is that whenever the microphone picks up a chirp that matches the one I sent, it makes a spike. This trick (matched filters) is used in radar all the time. The math for turning the microphone recording R(t) into a useful sonar signal S(t) using a matched filter is:

Note that we have to take the complex conjugate of the Fourier tranform of the chirp signal, multiply that by the Fourier transform of the Recording in frequency space, and then inverse Fourier transform to get a signal as a function of time. The signal S(t) has spikes wherever there is a reflection. Here you see S(t) which has a strong signal where the microphone picks up the direct wave, and a weaker signal for all the reflections.

The final step is to keep making chirps (my program could make around 4 per second) and then plot the intensity vs distance vs time (yes a 3D graph on a 2D plot!). To do this, I made an intensity graph, where height represents distance away in the reflection, and the time scrolls horizontally. I was holding a sound-reflecting clipboard, and walked away around 3 meters, and then returned to the computer. You can see that as a high intensity reflection going vertical on the graph (far away) and then closer.

John and I have some fun ideas for improving our sonar, I will keep the world updated as we make more improvements! I would be happy to hear if you guys have some fun ideas for improvements! I did all the signal processing and speaker output using Labview software. I am happy to give you the source code if you are interested.

Friday, April 13, 2012

Single laser wavelength STED

On around August 2009, during a late-night brain-storm session with my colleague Erik Garbacik, I came up with the idea for my MSc project at the University of Twente: STED microscopy with a single laser wavelength. A few months later, a patent surfaced by Stephen Baer which basically said exactly the same thing as my MSc project proposal did. However, Baer didn't have any experimental proof in his patent, and so I figured I would go ahead and be the first to get results in the form of a Master's thesis.

Since I finished my MSc, a few more papers have surfaced (one by Baer: still no experimental proof!) and a few more from research groups in France and Italy that experimentally demonstrated the concept.

I am very curious to see what happens to the single wavelength STED microscope, especially whether or not it will indeed be used to make scientific discoveries about biology on the nanoscale. If you have any updates I'd be happy to hear them!

Sunday, September 11, 2011

Magnetic Tweezers

So I thought I'd just write down what I'm working on for the average person who's curious. I work on an instrument called a magnetic tweezer. We use magnetic tweezers to study biophysics. We can take a single strand of DNA and bond a magnetic bead to one end of the DNA and a glass slide to the other. Since the bead is paramagnetic, we can stretch a single strand of DNA when we bring a magnet close by. By changing the distance of the external magnet we can change the force on the DNA, and thus we can do force spectroscopy (a fancy word for measuring DNA length as a function of force). Within the Saleh Lab where I work, there are a few main topics of research using magnetic tweezers: ion-DNA interactions, DNA-DNA interactions, and protein-DNA interactions.

I work on protein-DNA interactions. Specifically, I am interested in a class of proteins called helicases. These proteins unzip genes and are therefore the subject of many biology-related pickup lines. Perhaps even more interesting is that they are involved in replication and all sorts of biological functions. You have trillions and trillions of helicase molecules in your body. Helicases are the bulldozer at the front of the replication machinery. We have classified a bunch of different types of helicases, but we don't yet understand how helicases move. We know that they burn ATP, but do they take single base-pair step for each ATP consumed? Or do they take steps of multiple base-pairs? Right now we don't know, and I hope to use magnetic tweezers to measure the step-size of helicase molecules.

There are numerous technical challenges standing in the way of answering fundamental questions about how helicases move along DNA. First of all, we can't actually see the DNA or the helicase. All we can see is the magnetic bead and use that bead as a probe to deduce the position of the protein. We typically use a hairpin of DNA, whereby each base-pair that is unzipped results in the magnetic bead moving towards the magnets by about 0.6 nanometers per base-pair unzipped. To put that in perspective: that's very small!

Measuring helicase steps are further complicated by the fact that the magnetic beads are undergoing Brownian motion from being bumped around by the surrounding water molecules. So when we see the bead move, we never really know for sure if it was because the helicase unzipped a single base-pair or if the water molecules bumped the bead and stretched the DNA a bit. The only way to get around the thermal noise is to take lots of measurements and average out the noise. So that's the reason I have been playing with a high-speed camera a lot lately. Oh, and everything is cooler in sloooowww moootttiiiooonnnn.

I'm trying to make the best of your tax-payer dollars, but if you have any questions or comments I'd be happy to hear them.

Thursday, July 14, 2011

Bitcoin

What is the future of bitcoins? In the short term, I see one major opportunity: point-of-sale terminals. In the medium term, I see one major potential problem: deflation. In the long term, I believe that some sort of hybrid Bitcoin system will take hold that allows for variable inflation rates.

What is Bitcoin? You can download a Bitcoin program at www.bitcoin.org. This program creates a digital wallet for you with a balance of 0.00 BC (bitcoins). To fill up your wallet you can do one of 2 things. You can either buy bitcoins from someone in exchange for some good or other currency, or you can mine your own bitcoins. Don't bother trying to mine though if you don't have at least a high end graphics card, it's not worth the electricity costs. I personally have mined around $0.50 equivalent in bitcoins over the course of a few weeks. Not much, but for me it's about the idea not so much the money.

One immediate opportunity that I see and would love to get involved with is a point-of-sale (POS) terminal. Veriphone makes POS terminals, and these can apparently be programmed in C/C++. Unfortunately, you have to be accredited to be officially allowed to make applications for them, and I'm too cheap to do that so I can't. These terminals could be set up to process Bitcoins through custom-made smart-cards loaded with a private key. A smart card costs less than $1USD, so this should be feasible. I imagine that stores could request their Veriphone terminals to be loaded with a Bitcoin program. Alternatively, someone could make their own POS terminal to process Bitcoin transactions. If I was a store owner, I think that I would like to have a physical device that sits on my counter and accepts Bitcoin cards. I don't like the idea of using a computer or smartphone to process a transaction, which is unfortunately the only way to do things right now. The hardware should be physically there, but again that's just my opinion. A bitcoin POS terminal doesn't currently exist, so it's a great opportunity for someone!

Deflation? Well, there are only ever going to be around 21 million bitcoins in existence because the mining that myself and others are doing is becoming more and more difficult. Some people have argued that this could lead to a deflationary spiral, where hoarders hold their bitcoins hoping that they will gain value, and as a result nobody buys anything until eventually nobody is using the currency anymore. It's difficult to say for sure whether or not this will happen, but I do see it as a major threat. A bigger threat I see to Bitcoins is more fundamental.

To me, the idea that anyone can mine the currency into existence (and secure everyone else's transactions Bitcoins the process) isn't necessarily the only way for a cryptocurrency to exist. The way US dollars are created is that the Federal Reserve buys US Treasury Bonds on the free market. In other words, they create a dollar by backing it with a promise to pay it back with 5% interest per year. That is not currently the case with Bitcoins. There is no free-market buying of securities to ensure the long-term stability of Bitcoins. On the one hand, this means that Bitcoins are completely decentralized, which is attractive to many. On the other hand, the inability to dynamically grow and shrink the money supply is a serious limitation to the potential upside. I believe that Bitcoin would be much more effective if it could expand the money supply quickly (or contract if need be). Since Bitcoin cannot expand/contract the money supply dynamically in response to pressures and can only grow at an arbitrary predetermined rate, it is missing a key piece of the recipe for success.

I predict that a future cryptocurrency will allow for dynamic inflation rates to be set by users in a peer-to-peer network. If a user or group sets the inflation rate too high, they will eventually go belly-up. If the inflation rate is too low, that person or organization will get out-competed by more aggressive growers. It's actually very similar to what is happening now, just without a bunch of bankers and politicians determining the correct rates and bailing out their "too-big-to-fail" friends. It could be a nice future, one where 40% of the economy is not based on the financial sector, but is instead based on real things.

I think that this is an exciting time to be witnessing these thought experiments in finance turn into multi-million dollar ideas.

At this time, the value of all the Bitcoins in existence is: $95.4 Million USD