The formula is based on calculations posited by Pythagoras in ancient Greece, if I remember correctly. I may be wrong about which scholar did the original math, but the main thing is that they are theoretical spacings based on a formula that did not take into account the degree of sharpness added due to the increase in string tension as it is pulled down toward the fret. This discrepancy is particularly apparent at the frets nearest to the nut. This is why a guitar must be intonated to tune acceptably, and provides for Buzz Feiten and a few others to make a living out of selling compensated guitar nuts. (There's got to be a bad pun in there somewhere.!) :)
For your models, take the centre-line of the fret as your mid-scale. The simplest form of intonation involves adjusting the bridge saddle position until the harmonic at the 12th fret matches the note obtained by fretting the string at the 12th fret.