Method for calculating Stud Bolt length

The Stud Bolt theoretical length can be calculated
by means of the formula:

L = 2 (s + n + h + rf) + g

s free threads (equals 1/3 time bolt diameter)
n nut height (equals nominal bolt diameter)
h flange (plate) thickness
rf height of raised face
g gasket thickness
The height of a nut for a Stud Bolt is the same as the diameter of the thread rod