Fundamentals of statistical and thermal physics