Modeling of the thermal behavior and of the chemical differentiation of cometary nuclei