Residual stress in diamond films: origins and modelling