First principles total energy study of ferroelectric transitions in LiNbO3