Materials compendium fix

I rewrote large portions of the code to fix #610 - sorry, review-ers! On the bright side the actual code is much shorter now and, I think, a little easier to read/understand. However it's possible that there is something subtle in the old code I missed the second time around.

I added a quick test file to check if the output has the right compositions of materials, though I haven't checked the .h5 output. 
That too :)