The dynamics of thermostatically controlled loads for power system frequency control