Determination of ion populations and solvent content as functions of redox state and pH in polyaniline