We will calculate the number of vials that can be put into a lyophilization tray.

Step 1: Identify the length and width of the tray available for fill. Remember to subtract out any tray ring dimensions or spacers that manufacturing may be using when pushing vials into the tray.

Step 2: Identify the outer diameter of a vial.
In any rectangular tray filled with round vials, there are two kinds of rows. We will call them "corner" rows and "stagger" rows.
Depending on the width of a tray, corner rows may contain 1 more vial than stagger rows.
Were you putting these vials into the tray by hand, it would be possible to place them such that the width and length were reversed. That often results in getting more vials into the tray, but it isn't how most pharmaceutical loading equipment works.
Step 3: The number of vials in a corner row can be determined easily by rounding down the Width/Diameter.
<= num of vials in a corner vial row.
Step 4: The number of vials in a stagger row lose at least one radius from the width of the tray.
<= num of vials in a stagger vial row.
When counting down, each row save the first and last have a length of [sin(60 deg) x O.D.]. Furthermore, the first and last row each use one additional vial radius. Finally, there is one more row of vials than the row length divided into the distance available.

Step 5: Calculate the total number of rows, top to bottom.
<= total number of rows.
Step 6: The number of stagger rows is half the total, rounded down.
<= Number of stagger rows.
Step 7: The number of corner rows is the total number of rows less the stagger rows.
<= Number of corner rows.
Step 8: Compute the number of vials from the number of rows and columns.
<= Number of vials in a tray