Models for the change in electrostatic charge and for the adsorption of anions and of cations by variable charge surfaces involve sets of simultaneous equations. A method for solving these equations was developed and incorporated in a computer program. This was linked to an optimization program so that values of the parameters of the models could be selected objectively. The program was used to test and to compare the fit of various models to observations on the charging behaviour of goethite in solutions of sodium chloride, sodium sulfate, and calcium chloride. A good description of the observed behaviour was obtained, provided that terms to describe specific adsorption of the electrolyte ions were included. Models in which the specifically adsorbed electrolyte ions were assigned to a separate plane did not improve the description of charge over simpler models, but gave more realistic values for electrostatic potentials.