I understand octane pretty good is cetane in the same vain and diesel is distilled something like moonshine?
Sort of. The moonshine distillation is the process of evaporating the alcohol (which boils at a lower temperature than water) and collecting the steam before condensing it back into liquid form. Once the steam is collected, it condenses back into a liquid and is pretty much all alcohol. With moonshine, you're basically dealing with just the two boiling points, that of alcohol and that of water, and all you need to do is keep the temperature high enough to boil the alcohol but low enough to keep the water from boiling.
Crude oil is a mixture of many different hydrocarbons (chains of hydrogen and carbon), with each kind of hydrocarbon having a different length of molecule chains. The same way that water and alcohol have very different vapor points, each length of hydrocarbon chain in crude oil has its own unique boiling (or vapor) point. Longer hydrocarbon chains (tar) have a higher boiling point than those of shorter lengths (propane). Refineries take advantage of the boiling point differences to separate out individual petrochemicals from the crude mixture. The crude oil is placed in a distillation column, and then heated to allow more volatile petrochemicals (shorter lengths) to boil off while the remaining chemicals remain in liquid form. Propane, gasoline and other lighter chemicals are boiled off and collected first, then the crude is heated a little more to get things like diesel, lubricating oil and other products.
The gasoline and diesel collected at the distillation stage is just dirt cheap. But gasoline must be further processed by catalytic cracking, which further breaks down the chains into smaller chains to get the desired compounds of gasoline. Polymerization, the opposite of cracking, combines the smaller chains into the desired length for gasoline. What you end up with is essentially two pure volatile liquids, heptane and isooctane. Pure heptane, a much lighter fuel, burns so hot and so quickly that it produces a great amount of knocking in an engine. Pure isooctane evaporates slowly and produces virtually no knocking. The ratio of heptane to isooctane is measured by the octane rating. The greater the percentage of isooctane, the less knocking. An octane rating of 87 is literally a mixture of 87% isooctane and 13% heptane. So raw gasoline is distilled, but must be further refined (cracked and polymerized) to get usable gasoline fuel for engines.
Diesel is perfectly usable right at the distillation stage, and that's exactly how it used to be used, which is why it's so cheap at that point, but it's also full of sulfur and other pollutants. Once diesel is initially obtained at the distillation stage, it is further distilled multiple times to reduce the sulfur and other stuff. The resulting refined low-sulphur diesel burns much cleaner, but it's also much more expensive. But when you distill the diesel, the cetane number you get is what you get, and it can be all over the place depending on the type of crude you started with (light, heavy, tar sands, etc.). Normally (and naturally) diesel at the distillation stage is going to be right in that minimum 40 cetane range, Light crude has more, heavy crude has less.
Cetane isn't a chemical or a compound, like heptane or isooctane is. It's simply a measure of the combustibility of the fuel. You can't go to the store and buy cetane, but you can buy a cetane
improver. When you need to raise the cetane level, you add chemicals that will raise the combustibility of the fuel to get it to a certain cetane index.
The various cetane specs can severely limit diesel production at a refinery, because when you distill the diesel, you get the cetane that you get, period. If it's 42 at the distillation, that's what it is. Cetane can really only be measured with a test engine, and it's expensive, so most refineries don't have one on hand for testing. But they can use certain correlations, like distillation density, viscosity, cold flow, sulfur, T90, TP150, the amount and composition of cracked cracked and aromatic compounds, etc. The correlations are laid out in various ASTM and API documents.
What refiners do is add in a fair amount of LCO (Light Crude Oil) and synthetic crudes to the process in order to achieve the desired cetane number. So with the relatively recent introduction of sulfur and cetane specifications, diesel has become more of a manufactured product, though not nearly as much as gasoline.
Here are the formulas, in case you want to do your own testing.
With cetane and octane, it's definitely not a case of "if a little is good, more must be better" like it might be with, say, 60 year old Scotch. Both gas engines and diesel engines are designed to work optimally with fuel that has a specific octane or cetane rating. If the rating of the fuel is too low, you get performance issues in both kinds of engines. So if a diesel engine needs a 50 cetane fuel (as with the case of VW Jettas and many European vehicles), and you can only get 42 cetane, adding a cetane improver will definitely give you real benefit.
But if you have the same engine (that needs 50 cetane), and your diesel fuel is already 50 cetane, more won't make it better. In both gas and diesel engines, using fuel in excess of what the engine needs isn't really going to do anything substantive. In the case of diesel, however, there are some combustibility benefits with reduced soot, but when you pay an extra 20-30 cents a gallon for premium fuel with higher ratings, it's a little iffy as to whether that's really cost effective. Using too low a cetane will definitely get you a hit on fuel economy, but bringing the cetane up to the level the engine requires is all you need to do. Using a higher cetane than the engine requires won't give you any better fuel economy.
You will hear that diesel is all the same, it comes out of the same pipe. That's no longer the case. It used to be true when all we used was naturally distilled diesel with it's 40-42 cetane rating, but with cetane specs and other things like sulfur reduction, we have the standard rack-rate diesel that all comes out of the same pipe (so to speak) and we have branded premium diesels with the higher-than-minimum cetanes.
I usually get diesel at PFJ or Speedway, and I know that PFJ/Loves/Valero/Sheetz/Wawa/Walmart/Speedway all generally use the rack diesel, so all I can rely on is about a 42 cetane. For that I use Power Service to boost the cetane. I also know that BP (Amoco branded), Countrymark Diesel-R, Chevron, and ConocoPhillips are all going to be at least 49 cetane, so I don't add Power Service when I get fuel at those places.