Residual stress analysis of thin films