A numerical model of the thermal evolution of Mars was developed, solving simultaneously the equations for energy conservation and hydrostatic equilibrium throughout the planet, and using an equation of state that includes the computation of the thermal pressure according to the Debye theory. Based on the known values of the size and mass of Mars, and choosing the value of 0.365 for the inertia factor, we determine the initial mass fractions of different materials constituting the core and mantle of Mars. The abundance ratios of the components are described by three parameters. Two of these parameters are fixed by the radius and inertia factor of Mars, while the third remains free. Several models that match the present radius and inertia factor were found, distinguished by their initial composition. The thermal evolution and present internal state of these models were evaluated, in order to establish constraints on the composition and internal structure of Mars.