Ideal distance between chainring and chain stay I am building a single speed bicycle, and I have most of the drivetrain parts:


Rear hub
18T rear cog (40-40.5mm ideal rear chainline -- wheel undished)
1/8" chain
crankset with 40T chainring


I used the formulae in the answers of How do I calculate the diameter of a chainring from the number of teeth? and calculated that a 32T or smaller front chainring is needed to maintain the chainline for an undished rear wheel (otherwise the chainring would rub the chain stay of my specific frame, and I will be forced to increase the chainline, adjust spacers on the rear hub, and dish the rear wheel). 

But 32/18 is too low of a gear ratio, so I made a compromise and chose a 40T chainring which I intend to place as close as possible to the chain stay, in order to have a front chainline as close as possible to 40mm, for a rear wheel as undished as possible (because it will be stronger, from what I've read). 

The last part that I need is a bottom bracket cartridge with the proper spindle length, that will dictate the front chainline and how close the chainring seats to the chain stay. For the proper spindle length I need to take into consideration (and maybe other factors as well):


JIS vs ISO square taper types -- I think I need to add 4.5mm to the chainline just to leave room for a non-ideal combination of the 2 standards that may result now, or with future replacements; But using this knowledge:  How can I tell the difference between a J.I.S. and ISO square taper bottom bracket? I think I can avoid mixing them wrong.
Flexing of the steel chain stay and frame while riding which may cause the chainring to hit;
After being used for some time, the crank hole might get larger, thus needing to be screwed in farther on the spindle, closer to the frame;
The chainring might slightly bend with time. I don't want the lightest hit to cause it to rub.


No crankset chainline info is specified. But I have an old spindle, I will install the crankset on it, make some measurements, then calculate the proper spindle length and symmetry relative to this one that I have.

How should I proceed with the measurements? What would be the optimal chainring - chain stay distance to aim for? I don't have enough experience to know how much each of the above mentioned factors weighs into the equation.

UPDATE: It turns out that in order to have the 40T chainring placed at 4-5mm away from the chain stay, the rear wheel needs a 4mm dish. How much will 4mm dish weaken the rear wheel?
4mm at the closest point is about the safe spot. 3mm is about the sane bare minimum you can go to if you want to push things. Less is asking for trouble. Note that frames, cranks, rings, and spindles do vary in how flexy they are and riders vary in habits and strength, so one can only approximate here. If you stacked the movement from a bunch of flexy things under a strong rider, 4mm probably wouldn't be enough. But it works well as a rule of thumb.

A simple way to actually do this kind of measuring is slipping an allen wrench in the gap, essentially using it as a feeler gauge, or just eyeballing it with one. 2, 2.5, 3, and 4mm wrenches are conveniently sized for the purpose.

It sounds like you're sacrificing an optimal chainline to make use of an 18t cog you already have. I kind of hate that idea; having perfect chainline is one of the big payoffs to all the work you're doing here, and makes fixed/singlespeed bikes work like they should. If this is fixed I would just go for a 14t cog instead. It's true that it will wear out faster, but I think it's worth it. 

With steel, another approach is just to dimple the frame, if the clearance that could be gained by doing so would be enough. It's less of a big deal than it may seem like. Frames get squished in the chainstay area at the factory in ways that aren't terribly sophisticated. Usually techniques for doing this involve making a wood form to cradle the back of the stay while you push something rounded into the front, using a vise or clamp.