This thesis develops a nested sampling algorithm into a black box tool for directly calculating the partition function, and thus the complete phase diagram of a material, from the interatomic potential energy function. It represents a significant step forward in our ability to accurately describe the finite temperature properties of materials. In principle, the macroscopic phases of matter are related to the microscopic interactions of atoms by statistical mechanics and the partition function. In practice, direct calculation of the partition function has proved infeasible for realistic models of atomic interactions, even with modern atomistic simulation methods. The thesis also shows how the output of nested sampling calculations can be processed to calculate the complete PVT (pressure–volume–temperature) equation of state for a material, and applies the nested sampling algorithm to calculate the pressure–temperature phase diagrams of aluminium and a model binary alloy.