Phase transition related stress in ferroelectric thin films