Calculation of moles and ions