The thermodynamics of frost damage to porous solids