Residual stress in ion-assisted coatings