My book says that the opportunity cost of purchase of a specialized equipment that has no alternative use is zero and hence such an expenditure is a sunk cost. However, while calculating the user cost of capital, it takes into account how much interest one could have got had one not purchased the capital and invested the money somewhere else. So, why the same treatment has not been applied on the specialized equipment. Rather than buying it for $ \$20000$ (say), I could have invested the money somewhere else and earned a return of $ \$2000$ (say). So, shouldn't my opportunity cost amount to $\$22000$ rather than 0
I think the point that the author was trying to make was that opportunity cost refers to the "best alternative use" of something. The measure is used to understand marginal decision making. Suppose you have just purchased an Oven which can either bake cakes or bake bread. Now if you decide to bake cakes, your opportunity cost is the number of loaves of bread that you could have baked at the same time. However, all this analysis is done keeping in mind that - "once the oven is purchased".
The machine in your example has no alternative use and hence has zero opportunity cost. Your analysis about the interest is regarding the money using which the machine was purchased. Sure that money could have been put to some other use - like buying a Netflix suscription or putting into bank deposit and hence will have an opportunity cost. Bust as far as the machine is concerned " once it is purchased", on the margins, it has no alternative use hence no opporunity cost.