Added ionDensityHistory and generalized computeWeightedAverage.