Calculating the modal volume of a cavity mode