Generalized thermomechanics with internal variables