Thermodynamic model of magnetic calorimeters