Calculation of magnetostriction constants