Variational thermomechanical processes and chemical reactions in distributed systems