Ion-energy distribution in a plasma under a diverging magnetic field