Potential temperature profiles derived from the NASA Mars rover Spirit's miniature thermal emission spectrometer scans of the atmosphere were used as a validation for boundary-layer (BL) simulations on a dusty and a dustless solar day (sol), and the 1D model's heating rates were studied to clarify the mechanisms which drive the observed diurnal variation. The optical properties of dust were first charted by Mie calculations, the single-scattering albedo and asymmetry parameter being fairly insensitive to the dust size distribution.During a dusty and warm late summer day, the simulated potential temperatures, θ, were reasonably close to those observed. The morning and midday θ(z) display a strongly superadiabatic surface layer up to 150 m with a convective BL (CBL) aloft. The diurnal evolution of the model's CBL is not very sensitive to the wind speed and is consistent with large-eddy simulations. After sunset, a stable surface layer evolves by turbulent cooling so conventional similarity theory is applicable (unlike in the radiation-driven CBL). Strong long-wave (LW) cooling dominates aloft, building the inversion and the stable BL upwards. During windy nights with a nocturnal low-level jet, shear-driven turbulence assists the LW cooling, while during calm Martian nights turbulent cooling is limited to the lowest few metres only.The less dusty late autumn simulation appeared to be close to the observed evolution. The BL mechanisms were similar to those during the dusty sol but with moderated radiative heating rates due to the small dust amounts and the lower emission temperatures.