Method for calculating Stud bolt lengths

The stud bolt theoretical length can be calculated by means of the formula:
L = 2 (s + n + h + rf) + g

Method for calculating stud bolt length